- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
93 lines
2.4 KiB
C++
93 lines
2.4 KiB
C++
|
|
|
|
#include "logout_info_dialog.h"
|
|
|
|
#include "ui_logout_info_dialog.h"
|
|
|
|
#include <QTimer>
|
|
|
|
namespace LtsLogin
|
|
{
|
|
|
|
LogoutInformationDialog::LogoutInformationDialog(int timeOut, AssetManagement::ShutdownAction shutdownAction,
|
|
QWidget* parent)
|
|
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal), m_ui(new Ui::LogoutInformationDialog),
|
|
m_timer(new QTimer(this)), m_timeOut(timeOut), m_secsLeft(timeOut)
|
|
{
|
|
m_ui->setupUi(this);
|
|
QString actionText;
|
|
switch (shutdownAction.underlying())
|
|
{
|
|
case AssetManagement::ShutdownAction::NoAction:
|
|
case AssetManagement::ShutdownAction::Logout:
|
|
actionText = tr("logout");
|
|
break;
|
|
case AssetManagement::ShutdownAction::Shutdown:
|
|
actionText = tr("shutdown");
|
|
break;
|
|
case AssetManagement::ShutdownAction::Reboot:
|
|
actionText = tr("reboot");
|
|
break;
|
|
}
|
|
|
|
setText(tr("A %1 was triggered by a remote workstation.").arg(actionText));
|
|
|
|
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this,
|
|
&LogoutInformationDialog::acceptClicked);
|
|
connect(m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this,
|
|
&LogoutInformationDialog::closeClicked);
|
|
connect(m_timer, &QTimer::timeout, this, &LogoutInformationDialog::onTimerTimeout);
|
|
|
|
m_timer->setInterval(1000);
|
|
}
|
|
|
|
LogoutInformationDialog::~LogoutInformationDialog()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
void LogoutInformationDialog::setText(const QString& text)
|
|
{
|
|
m_ui->lblLogoutText->setText(text);
|
|
}
|
|
|
|
void LogoutInformationDialog::onTimerTimeout()
|
|
{
|
|
if (m_secsLeft > 0)
|
|
{
|
|
m_secsLeft--;
|
|
setCloseButtonText(m_secsLeft);
|
|
}
|
|
else
|
|
{
|
|
acceptClicked();
|
|
}
|
|
}
|
|
|
|
void LogoutInformationDialog::acceptClicked()
|
|
{
|
|
m_timer->stop();
|
|
accept();
|
|
}
|
|
|
|
void LogoutInformationDialog::closeClicked()
|
|
{
|
|
m_timer->stop();
|
|
reject();
|
|
}
|
|
|
|
void LogoutInformationDialog::setCloseButtonText(int secsLeft)
|
|
{
|
|
m_ui->buttonBox->getButton(LtsWidgets::DialogButton::Close)->setText(tr("Abort [%1]").arg(secsLeft));
|
|
}
|
|
|
|
void LogoutInformationDialog::showEvent(QShowEvent* event)
|
|
{
|
|
m_secsLeft = m_timeOut;
|
|
setCloseButtonText(m_secsLeft);
|
|
m_timer->start();
|
|
LtsWidgets::LtsFramelessDialog::showEvent(event);
|
|
}
|
|
|
|
} // namespace LtsLogin
|