Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+108
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SimChooser Payload UI
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-21
|
||||
*/
|
||||
|
||||
#include "nme_shutdown_dialog.h"
|
||||
#include "ui_nme_shutdown_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
NmeShutdownDialog::NmeShutdownDialog(const std::shared_ptr<TrainingAreaBase::Interface::Ftc> &tabFtc,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_selected(false)
|
||||
, m_ui(new Ui::NmeShutdownDialog)
|
||||
, m_tabFtc(tabFtc)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags( Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // hints..
|
||||
|
||||
connect(m_ui->pbQuit, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
m_close = true;
|
||||
close();
|
||||
});
|
||||
|
||||
connect(m_ui->pbShutdownAccept, &QPushButton::clicked,
|
||||
this, &NmeShutdownDialog::onShutdownClicked);
|
||||
|
||||
}
|
||||
|
||||
NmeShutdownDialog::~NmeShutdownDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void NmeShutdownDialog::reject()
|
||||
{
|
||||
if (!m_selected /* do not quit session if this dialog is misused as import dialog for a running app */)
|
||||
emit signalQuit();
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
|
||||
void NmeShutdownDialog::onShutdownClicked()
|
||||
{
|
||||
|
||||
if(!m_tabFtc)
|
||||
return;
|
||||
TrainingAreaBase::SetDevicePowerRequest request;
|
||||
|
||||
request.equipmentNumber(1);// Only the EqNumber 1 will be consumed from NmeaTabPlugin
|
||||
request.powerType(TrainingAreaBase::PowerMethod::PowerOff); //Need to be PowerOff
|
||||
request.subdeviceId(0); // Not used in TAB
|
||||
|
||||
auto cb = [request, this]()
|
||||
{
|
||||
return m_tabFtc->setDevicePowerRequest(request, this);
|
||||
};
|
||||
m_requestHelper->startSingleRequest(cb);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void NmeShutdownDialog::onEnaDisa()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NmeShutdownDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!m_close)
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
void NmeShutdownDialog::onSetDevicePowerReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user