Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Plugins/Buildings/Gui/BuildingInfo/relay_info.cpp
T
torsten 950d669538 Qt6 Migration: BUILD_RTI guards und CMake fixes
- BUILD_RTI conditional compilation für RTI Connext DDS dependencies
- Namespace fixes in core_dtc.h (Core:: → DDS::Core::)
- CMakeLists.txt: BUILD_RTI option und conditional dependencies
- Handler minelayer: namespace closing mit BUILD_RTI guard
- Build erfolgreich mit BUILD_RTI=OFF validiert

Signed-off-by: Torsten Wierschin <torsten.wierschin@life-maps.com>
2026-08-21 18:37:18 +02:00

132 lines
3.8 KiB
C++

#include "relay_info.h"
#include "ui_relay_info.h"
#include <LtsWidgets/lts_led_widget.h>
#include <ngltools/ngltools_dtg.h>
namespace Buildings
{
RelayInfoWidget::RelayInfoWidget(int id, QWidget* parent)
: QWidget(parent), m_id(id), m_state(false), m_ui(new Ui::RelayInfoWidget),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger())
{
DEBUG_LOG(m_logger) << "RelayInfoWidget";
m_ui->setupUi(this);
m_ui->ledStatus->setAspectHint(LtsWidgets::LtsLedWidget::AspectHint::WidthIsHeight);
m_ui->ledStatus->setContentsMargins(5, 5, 5, 5);
setOfflineColor();
connect(m_ui->tbOn, &QToolButton::clicked, this, &RelayInfoWidget::onButtonClicked);
connect(m_ui->tbOff, &QToolButton::clicked, this, &RelayInfoWidget::onButtonClicked);
connect(m_ui->tbAuto, &QToolButton::clicked, this, &RelayInfoWidget::onButtonClicked);
}
RelayInfoWidget::~RelayInfoWidget()
{
delete m_ui;
}
QString RelayInfoWidget::name() const
{
return m_ui->lblName->text();
}
bool RelayInfoWidget::state() const
{
return m_state;
}
int RelayInfoWidget::id() const
{
return m_id;
}
void RelayInfoWidget::setName(const QString& name)
{
m_ui->lblName->setText(name);
}
void RelayInfoWidget::setState(bool state, qint64 stateTime, qint64 offlineTime)
{
if (stateTime > offlineTime)
{
m_state = state;
m_ui->ledStatus->setOnColor(state ? Qt::green : Qt::red);
m_ui->ledStatus->setToolTip(QStringLiteral("%1 - %2").arg(tr("Values from")).arg(DTG::toStringMSec(stateTime)));
m_ui->ledStatus->setStatus(true);
}
else
{
setOfflineColor();
m_ui->ledStatus->setToolTip(QStringLiteral("%1 - %2,\nEGCU offline since: %3")
.arg(tr("Values from"))
.arg(DTG::toStringMSec(stateTime))
.arg(DTG::toStringMSec(offlineTime)));
m_ui->ledStatus->setStatus(true);
}
}
void RelayInfoWidget::setEffectOverride(InfrastructureManagement::EffectOverride override)
{
switch (override.underlying())
{
case InfrastructureManagement::EffectOverride_def::Automatic:
m_ui->tbAuto->setChecked(true);
break;
case InfrastructureManagement::EffectOverride_def::PermanentOn:
m_ui->tbOn->setChecked(true);
break;
case InfrastructureManagement::EffectOverride_def::PermanentOff:
m_ui->tbOff->setChecked(true);
break;
}
}
void RelayInfoWidget::setEffectOverrideEnabled(InfrastructureManagement::EffectOverride override, bool enable)
{
switch (override.underlying())
{
case InfrastructureManagement::EffectOverride_def::Automatic:
m_ui->tbAuto->setEnabled(enable);
break;
case InfrastructureManagement::EffectOverride_def::PermanentOn:
m_ui->tbOn->setEnabled(enable);
break;
case InfrastructureManagement::EffectOverride_def::PermanentOff:
m_ui->tbOff->setEnabled(enable);
break;
}
}
void RelayInfoWidget::setLedVisible(bool enable)
{
m_ui->ledStatus->setVisible(enable);
}
void RelayInfoWidget::onButtonClicked()
{
QAbstractButton* ab = qobject_cast<QAbstractButton*>(sender());
if (!ab)
return;
InfrastructureManagement::EffectOverride eo = InfrastructureManagement::EffectOverride_def::Automatic;
if (ab == m_ui->tbOff)
eo = InfrastructureManagement::EffectOverride_def::PermanentOff;
else if (ab == m_ui->tbOn)
eo = InfrastructureManagement::EffectOverride_def::PermanentOn;
emit effectOverrideChanged(m_id, eo);
}
void RelayInfoWidget::setOfflineColor()
{
QColor offlineColor;
offlineColor.setRgb(120, 92, 37);
m_ui->ledStatus->setOnColor(offlineColor);
}
} // namespace Buildings