Add shutdown widget.
This commit is contained in:
@@ -36,6 +36,7 @@ namespace
|
|||||||
{
|
{
|
||||||
const int PREVIEW_IMAGE_WH = 140;
|
const int PREVIEW_IMAGE_WH = 140;
|
||||||
const unsigned int GET_TEMPERATURE_TIME = 60000;
|
const unsigned int GET_TEMPERATURE_TIME = 60000;
|
||||||
|
const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues
|
||||||
const QString DEFAULT_DMS_START_FAILED = "Dms start failed.";
|
const QString DEFAULT_DMS_START_FAILED = "Dms start failed.";
|
||||||
const QString RECON_TRANSFER_PATH = "/home/krad/TestStore";
|
const QString RECON_TRANSFER_PATH = "/home/krad/TestStore";
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ void DeviceManager::initDevice()
|
|||||||
// preview
|
// preview
|
||||||
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan,this, &DeviceManager::startPreview);
|
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan,this, &DeviceManager::startPreview);
|
||||||
//shutdown
|
//shutdown
|
||||||
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdown);
|
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdownDms);
|
||||||
//Drainage
|
//Drainage
|
||||||
connect(EventCenter::Default(), &EventCenter::RequestDrainage, this, [this](QObject* sender, QObject* detail)
|
connect(EventCenter::Default(), &EventCenter::RequestDrainage, this, [this](QObject* sender, QObject* detail)
|
||||||
{
|
{
|
||||||
@@ -126,7 +127,10 @@ void DeviceManager::initDevice()
|
|||||||
mGetSoftwareVersionAction = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
|
mGetSoftwareVersionAction = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
|
||||||
mGetDeviceTemperatureAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_TEMP, this, "responseGetDeviceTemperature(const QString&)", this);
|
mGetDeviceTemperatureAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_TEMP, this, "responseGetDeviceTemperature(const QString&)", this);
|
||||||
mStopTransferAction = new DmsAsyncAction(USRV_XFR, ACT_XFR_STOP, this, "responseStopTransfer(const QString&)", this);
|
mStopTransferAction = new DmsAsyncAction(USRV_XFR, ACT_XFR_STOP, this, "responseStopTransfer(const QString&)", this);
|
||||||
|
mShutDownAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PWRDOWN, this, "responseShutDown(const QString&)", this);
|
||||||
|
mShutDownAction->setTimeoutInterval(SHUT_DOWN_TIMEOUT);
|
||||||
connect(mGetScanProgressAction, &DmsAsyncAction::timeout, this, &DeviceManager::scanTimeout);
|
connect(mGetScanProgressAction, &DmsAsyncAction::timeout, this, &DeviceManager::scanTimeout);
|
||||||
|
connect(mShutDownAction, &DmsAsyncAction::timeout, this, &DeviceManager::shutdownDmsFailed);
|
||||||
|
|
||||||
|
|
||||||
//dmsInfoReceiverThread
|
//dmsInfoReceiverThread
|
||||||
@@ -600,6 +604,10 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
|
|||||||
case ACT_CTL_PUMP:
|
case ACT_CTL_PUMP:
|
||||||
emit responsePumpControl(aContents);
|
emit responsePumpControl(aContents);
|
||||||
break;
|
break;
|
||||||
|
case ACT_CTL_PWRDOWN:
|
||||||
|
emit responseShutDown(aContents);
|
||||||
|
processShutDownDms(aContents);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -731,14 +739,42 @@ void DeviceManager::getScanProcess()
|
|||||||
mGetScanProgressAction->execute();
|
mGetScanProgressAction->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::shutdown()
|
void DeviceManager::shutdownDms()
|
||||||
{
|
{
|
||||||
if(mIsTransfering)
|
if(mIsTransfering)
|
||||||
{
|
{
|
||||||
QString msg = "Data is currently being transmitted, please shut down later.";
|
QString msg = tr("Data is currently being transmitted, please shut down later.");
|
||||||
THROW_ERROR(msg);
|
THROW_ERROR(msg);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
|
|
||||||
|
if(!mShutDownAction->execute())
|
||||||
|
{
|
||||||
|
QString msg = tr("Shut down failed, please push emergency button to shutdown.");
|
||||||
|
THROW_ERROR(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppGlobalValues::setInProcessing(true);
|
||||||
|
emit shutdownDmsSended();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceManager::processShutDownDms(const QString& aResponse)
|
||||||
|
{
|
||||||
|
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||||
|
if(jsonObj.contains("code") && jsonObj["code"].toInt() == 0)
|
||||||
|
{
|
||||||
|
shutdownOperationSystem();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AppGlobalValues::setInProcessing(false);
|
||||||
|
emit shutdownDmsFailed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceManager::shutdownOperationSystem()
|
||||||
|
{
|
||||||
|
qDebug()<< "shut down OS";
|
||||||
|
//QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::insertEmptyScanRecord()
|
void DeviceManager::insertEmptyScanRecord()
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
void startScan(const QString& json, bool empty = false);
|
void startScan(const QString& json, bool empty = false);
|
||||||
void startPreview();
|
void startPreview();
|
||||||
void shutdown();
|
void shutdownDms();
|
||||||
|
void shutdownOperationSystem();
|
||||||
|
|
||||||
//-----------------new
|
//-----------------new
|
||||||
DeviceStatus getDeviceStatus();
|
DeviceStatus getDeviceStatus();
|
||||||
@@ -115,6 +116,7 @@ private:
|
|||||||
void processGetSoftwareVersion(const QString& aSoftwareVersion);
|
void processGetSoftwareVersion(const QString& aSoftwareVersion);
|
||||||
void processDeviceTemperature(const QString& aResponseTemperature);
|
void processDeviceTemperature(const QString& aResponseTemperature);
|
||||||
void processTransferProgress(const QString& aProgress);
|
void processTransferProgress(const QString& aProgress);
|
||||||
|
void processShutDownDms(const QString& aResponse);
|
||||||
|
|
||||||
void insertEmptyScanRecord();
|
void insertEmptyScanRecord();
|
||||||
void insertScanRecord();
|
void insertScanRecord();
|
||||||
@@ -150,6 +152,7 @@ signals:
|
|||||||
void responseSetSimulatorMode(const QString& aResponse);
|
void responseSetSimulatorMode(const QString& aResponse);
|
||||||
void responseSetHeartBeat(const QString& aResponese);
|
void responseSetHeartBeat(const QString& aResponese);
|
||||||
void responseStopTransfer(const QString& aResponse);
|
void responseStopTransfer(const QString& aResponse);
|
||||||
|
void responseShutDown(const QString& aResponse);
|
||||||
//Recon
|
//Recon
|
||||||
void createEmptyScanToRecon(const QString& aScanID, const QString& aPath);
|
void createEmptyScanToRecon(const QString& aScanID, const QString& aPath);
|
||||||
void createScanToRecon(const QString& aScanID, const QString& aPatientID, const QString& aReferenceID, const QString& aPath);
|
void createScanToRecon(const QString& aScanID, const QString& aPatientID, const QString& aReferenceID, const QString& aPath);
|
||||||
@@ -161,6 +164,8 @@ signals:
|
|||||||
void transferStatusUpdated();
|
void transferStatusUpdated();
|
||||||
void startPreviewScanResult(bool aIsSucessful);
|
void startPreviewScanResult(bool aIsSucessful);
|
||||||
void startPumpControlResult(bool aIsSucessful);
|
void startPumpControlResult(bool aIsSucessful);
|
||||||
|
void shutdownDmsSended();
|
||||||
|
void shutdownDmsFailed();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -202,6 +207,7 @@ private:
|
|||||||
DmsAsyncAction* mGetScanProgressAction = nullptr;
|
DmsAsyncAction* mGetScanProgressAction = nullptr;
|
||||||
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
|
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
|
||||||
DmsAsyncAction* mStopTransferAction = nullptr;
|
DmsAsyncAction* mStopTransferAction = nullptr;
|
||||||
|
DmsAsyncAction* mShutDownAction = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
|
|||||||
, mSendData()
|
, mSendData()
|
||||||
{
|
{
|
||||||
mTimer->setSingleShot(true);
|
mTimer->setSingleShot(true);
|
||||||
|
mTimer->setInterval(TIMEOUT_MSEC);
|
||||||
connect(mTimer, &QTimer::timeout, this, &DmsAsyncAction::sendTimeoutSignal);
|
connect(mTimer, &QTimer::timeout, this, &DmsAsyncAction::sendTimeoutSignal);
|
||||||
connect(mObject, ("2" + mResponseSignal).toStdString().c_str(), mTimer, SLOT(stop()));
|
connect(mObject, ("2" + mResponseSignal).toStdString().c_str(), mTimer, SLOT(stop()));
|
||||||
}
|
}
|
||||||
@@ -36,7 +37,7 @@ bool DmsAsyncAction::execute()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mTimer->start(TIMEOUT_MSEC);
|
mTimer->start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,3 +45,8 @@ void DmsAsyncAction::sendTimeoutSignal()
|
|||||||
{
|
{
|
||||||
emit timeout();
|
emit timeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DmsAsyncAction::setTimeoutInterval(int aMsec)
|
||||||
|
{
|
||||||
|
mTimer->setInterval(aMsec);
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
|
|
||||||
bool execute();
|
bool execute();
|
||||||
void setSendData(const QString& aData);
|
void setSendData(const QString& aData);
|
||||||
|
void setTimeoutInterval(int aMsec);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void timeout();
|
void timeout();
|
||||||
|
|||||||
@@ -352,6 +352,11 @@ void DialogManager::raiseDeviceError(QObject *parent, QObject *msg) {
|
|||||||
clearMessageDialog();
|
clearMessageDialog();
|
||||||
auto dialog = new GUIMessageDialog(mTopWidget);
|
auto dialog = new GUIMessageDialog(mTopWidget);
|
||||||
|
|
||||||
|
if(mFunctionDialog->isRunning())
|
||||||
|
{
|
||||||
|
dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint | Qt::BypassWindowManagerHint );
|
||||||
|
}
|
||||||
|
|
||||||
if (nullptr != mTopWidget && mTopWidget->inherits("GUIMessageDialog"))
|
if (nullptr != mTopWidget && mTopWidget->inherits("GUIMessageDialog"))
|
||||||
{
|
{
|
||||||
GUIMessageDialog* parent = qobject_cast<GUIMessageDialog*>(mTopWidget);
|
GUIMessageDialog* parent = qobject_cast<GUIMessageDialog*>(mTopWidget);
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ QLabel {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLabel#Shutdown {
|
||||||
|
color: #fcfcfc;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
QLineEdit {
|
QLineEdit {
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
max-height: 36px;
|
max-height: 36px;
|
||||||
@@ -999,4 +1005,4 @@ QListView#LeftBtnBar::item
|
|||||||
|
|
||||||
QWidget#settingContentWidget QWidget{
|
QWidget#settingContentWidget QWidget{
|
||||||
font-size:26px;
|
font-size:26px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
|
||||||
#include "InitializeWidget.h"
|
#include "InitializeWidget.h"
|
||||||
|
#include "ShutdownWidget.h"
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
#include "forms/TabFormWidget.h"
|
#include "forms/TabFormWidget.h"
|
||||||
#include "forms/recon/ReconFormWidget.h"
|
#include "forms/recon/ReconFormWidget.h"
|
||||||
@@ -31,6 +32,7 @@ MainWindow::MainWindow(QWidget* aParent)
|
|||||||
, mDebugMessageConsole(nullptr)
|
, mDebugMessageConsole(nullptr)
|
||||||
, mTabWidget(new QTabWidget(this))
|
, mTabWidget(new QTabWidget(this))
|
||||||
, mInitializWidget(new InitializeWidget(this))
|
, mInitializWidget(new InitializeWidget(this))
|
||||||
|
, mShutdownWidget(new ShutdownWidget(nullptr))
|
||||||
, mAdminTabIndex(-1)
|
, mAdminTabIndex(-1)
|
||||||
, mThread(nullptr)
|
, mThread(nullptr)
|
||||||
, mIsDebugMode(false)
|
, mIsDebugMode(false)
|
||||||
@@ -50,6 +52,8 @@ MainWindow::MainWindow(QWidget* aParent)
|
|||||||
connect(EventCenter::Default(), &EventCenter::RequestScreenSaver, this, &MainWindow::requestScreenSaver);
|
connect(EventCenter::Default(), &EventCenter::RequestScreenSaver, this, &MainWindow::requestScreenSaver);
|
||||||
connect(DeviceManager::Default(), &DeviceManager::initializeFinished, this, &MainWindow::requestLogin);
|
connect(DeviceManager::Default(), &DeviceManager::initializeFinished, this, &MainWindow::requestLogin);
|
||||||
connect(DeviceManager::Default(), &DeviceManager::initializeProgress, mInitializWidget, &InitializeWidget::setMessage);
|
connect(DeviceManager::Default(), &DeviceManager::initializeProgress, mInitializWidget, &InitializeWidget::setMessage);
|
||||||
|
connect(DeviceManager::Default(), &DeviceManager::shutdownDmsSended, this, &MainWindow::showShutdownWidget);
|
||||||
|
connect(DeviceManager::Default(), &DeviceManager::shutdownDmsFailed, this, &MainWindow::processShutdownDmsFailed);
|
||||||
connect(DialogManager::Default(), &DialogManager::loginDialogShown, this, [this]()
|
connect(DialogManager::Default(), &DialogManager::loginDialogShown, this, [this]()
|
||||||
{
|
{
|
||||||
mInitializWidget->setVisible(false);
|
mInitializWidget->setVisible(false);
|
||||||
@@ -64,6 +68,7 @@ MainWindow::~MainWindow()
|
|||||||
mThread->terminate();
|
mThread->terminate();
|
||||||
mThread->deleteLater();
|
mThread->deleteLater();
|
||||||
delete mUI;
|
delete mUI;
|
||||||
|
delete mShutdownWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------Layout-----------------------------------------------------------------
|
//------Layout-----------------------------------------------------------------
|
||||||
@@ -91,6 +96,7 @@ void MainWindow::initializeLayout()
|
|||||||
layout->addWidget(mInitializWidget);
|
layout->addWidget(mInitializWidget);
|
||||||
|
|
||||||
mTabWidget->setVisible(false);
|
mTabWidget->setVisible(false);
|
||||||
|
mShutdownWidget->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initializeTabWidget()
|
void MainWindow::initializeTabWidget()
|
||||||
@@ -114,6 +120,17 @@ void MainWindow::reloadLanguage() {
|
|||||||
mTabWidget->setTabText(3, tr("Settings"));
|
mTabWidget->setTabText(3, tr("Settings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::showShutdownWidget()
|
||||||
|
{
|
||||||
|
mShutdownWidget->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::processShutdownDmsFailed()
|
||||||
|
{
|
||||||
|
mShutdownWidget->setVisible(false);
|
||||||
|
triggerError(tr("Shut down failed, please push emergency button to shutdown."));
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::switchToScanTab() { mTabWidget->setCurrentIndex(1); }
|
void MainWindow::switchToScanTab() { mTabWidget->setCurrentIndex(1); }
|
||||||
|
|
||||||
void MainWindow::centerWidgetHide()
|
void MainWindow::centerWidgetHide()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class QSwipeGesture;
|
|||||||
class QPanGesture;
|
class QPanGesture;
|
||||||
class QDockWidget;
|
class QDockWidget;
|
||||||
class InitializeWidget;
|
class InitializeWidget;
|
||||||
|
class ShutdownWidget;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
@@ -53,6 +54,8 @@ private:
|
|||||||
void swipeTriggered(QSwipeGesture* aSwipeGesture);
|
void swipeTriggered(QSwipeGesture* aSwipeGesture);
|
||||||
void panTriggered(QPanGesture* aPanGesture);
|
void panTriggered(QPanGesture* aPanGesture);
|
||||||
void loadStyleSheet(const QString& aSheetName);
|
void loadStyleSheet(const QString& aSheetName);
|
||||||
|
void showShutdownWidget();
|
||||||
|
void processShutdownDmsFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* mUI;
|
Ui::MainWindow* mUI;
|
||||||
@@ -60,6 +63,8 @@ private:
|
|||||||
QTextEdit* mDebugMessageConsole;
|
QTextEdit* mDebugMessageConsole;
|
||||||
QTabWidget* mTabWidget;
|
QTabWidget* mTabWidget;
|
||||||
InitializeWidget* mInitializWidget;
|
InitializeWidget* mInitializWidget;
|
||||||
|
ShutdownWidget* mShutdownWidget;
|
||||||
|
|
||||||
int mAdminTabIndex;
|
int mAdminTabIndex;
|
||||||
QThread* mThread;
|
QThread* mThread;
|
||||||
bool mIsDebugMode;
|
bool mIsDebugMode;
|
||||||
|
|||||||
31
src/windows/ShutdownWidget.cpp
Normal file
31
src/windows/ShutdownWidget.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "ShutdownWidget.h"
|
||||||
|
|
||||||
|
#include "components/LoadingWidget.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QSpacerItem>
|
||||||
|
|
||||||
|
|
||||||
|
ShutdownWidget::ShutdownWidget(QWidget* aParent)
|
||||||
|
: QWidget(aParent)
|
||||||
|
, mLoadingWidget(new LoadingWidget(this))
|
||||||
|
, mMessage(new QLabel(this))
|
||||||
|
{
|
||||||
|
setGeometry(QApplication::desktop()->screenGeometry());
|
||||||
|
mLoadingWidget->setMaximumHeight(150);
|
||||||
|
mLoadingWidget->setMaxDiameter(16);
|
||||||
|
setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool | Qt::BypassWindowManagerHint);
|
||||||
|
mMessage->setText(tr("shut down"));
|
||||||
|
mMessage->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||||
|
mMessage->setObjectName("Shutdown");
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
layout->addItem(new QSpacerItem(20, 300, QSizePolicy::Minimum, QSizePolicy::Preferred));
|
||||||
|
layout->addWidget(mLoadingWidget);
|
||||||
|
layout->addWidget(mMessage);
|
||||||
|
layout->setSpacing(50);
|
||||||
|
}
|
||||||
|
|
||||||
20
src/windows/ShutdownWidget.h
Normal file
20
src/windows/ShutdownWidget.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef SHUTDOWNWIDGET_H
|
||||||
|
#define SHUTDOWNWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class LoadingWidget;
|
||||||
|
|
||||||
|
class ShutdownWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ShutdownWidget(QWidget* aParent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
LoadingWidget* mLoadingWidget;
|
||||||
|
QLabel* mMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SHUTDOWNWIDGET_H
|
||||||
Reference in New Issue
Block a user