Add shutdown widget.
This commit is contained in:
@@ -36,6 +36,7 @@ namespace
|
||||
{
|
||||
const int PREVIEW_IMAGE_WH = 140;
|
||||
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 RECON_TRANSFER_PATH = "/home/krad/TestStore";
|
||||
|
||||
@@ -101,7 +102,7 @@ void DeviceManager::initDevice()
|
||||
// preview
|
||||
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan,this, &DeviceManager::startPreview);
|
||||
//shutdown
|
||||
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdown);
|
||||
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdownDms);
|
||||
//Drainage
|
||||
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);
|
||||
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);
|
||||
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(mShutDownAction, &DmsAsyncAction::timeout, this, &DeviceManager::shutdownDmsFailed);
|
||||
|
||||
|
||||
//dmsInfoReceiverThread
|
||||
@@ -600,6 +604,10 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
|
||||
case ACT_CTL_PUMP:
|
||||
emit responsePumpControl(aContents);
|
||||
break;
|
||||
case ACT_CTL_PWRDOWN:
|
||||
emit responseShutDown(aContents);
|
||||
processShutDownDms(aContents);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -731,14 +739,42 @@ void DeviceManager::getScanProcess()
|
||||
mGetScanProgressAction->execute();
|
||||
}
|
||||
|
||||
void DeviceManager::shutdown()
|
||||
void DeviceManager::shutdownDms()
|
||||
{
|
||||
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);
|
||||
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()
|
||||
|
||||
@@ -91,7 +91,8 @@ private:
|
||||
*/
|
||||
void startScan(const QString& json, bool empty = false);
|
||||
void startPreview();
|
||||
void shutdown();
|
||||
void shutdownDms();
|
||||
void shutdownOperationSystem();
|
||||
|
||||
//-----------------new
|
||||
DeviceStatus getDeviceStatus();
|
||||
@@ -115,6 +116,7 @@ private:
|
||||
void processGetSoftwareVersion(const QString& aSoftwareVersion);
|
||||
void processDeviceTemperature(const QString& aResponseTemperature);
|
||||
void processTransferProgress(const QString& aProgress);
|
||||
void processShutDownDms(const QString& aResponse);
|
||||
|
||||
void insertEmptyScanRecord();
|
||||
void insertScanRecord();
|
||||
@@ -150,6 +152,7 @@ signals:
|
||||
void responseSetSimulatorMode(const QString& aResponse);
|
||||
void responseSetHeartBeat(const QString& aResponese);
|
||||
void responseStopTransfer(const QString& aResponse);
|
||||
void responseShutDown(const QString& aResponse);
|
||||
//Recon
|
||||
void createEmptyScanToRecon(const QString& aScanID, 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 startPreviewScanResult(bool aIsSucessful);
|
||||
void startPumpControlResult(bool aIsSucessful);
|
||||
void shutdownDmsSended();
|
||||
void shutdownDmsFailed();
|
||||
|
||||
|
||||
private:
|
||||
@@ -202,6 +207,7 @@ private:
|
||||
DmsAsyncAction* mGetScanProgressAction = nullptr;
|
||||
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
|
||||
DmsAsyncAction* mStopTransferAction = nullptr;
|
||||
DmsAsyncAction* mShutDownAction = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
|
||||
, mSendData()
|
||||
{
|
||||
mTimer->setSingleShot(true);
|
||||
mTimer->setInterval(TIMEOUT_MSEC);
|
||||
connect(mTimer, &QTimer::timeout, this, &DmsAsyncAction::sendTimeoutSignal);
|
||||
connect(mObject, ("2" + mResponseSignal).toStdString().c_str(), mTimer, SLOT(stop()));
|
||||
}
|
||||
@@ -36,7 +37,7 @@ bool DmsAsyncAction::execute()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
mTimer->start(TIMEOUT_MSEC);
|
||||
mTimer->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,3 +45,8 @@ void DmsAsyncAction::sendTimeoutSignal()
|
||||
{
|
||||
emit timeout();
|
||||
}
|
||||
|
||||
void DmsAsyncAction::setTimeoutInterval(int aMsec)
|
||||
{
|
||||
mTimer->setInterval(aMsec);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
|
||||
bool execute();
|
||||
void setSendData(const QString& aData);
|
||||
void setTimeoutInterval(int aMsec);
|
||||
|
||||
signals:
|
||||
void timeout();
|
||||
|
||||
@@ -352,6 +352,11 @@ void DialogManager::raiseDeviceError(QObject *parent, QObject *msg) {
|
||||
clearMessageDialog();
|
||||
auto dialog = new GUIMessageDialog(mTopWidget);
|
||||
|
||||
if(mFunctionDialog->isRunning())
|
||||
{
|
||||
dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint | Qt::BypassWindowManagerHint );
|
||||
}
|
||||
|
||||
if (nullptr != mTopWidget && mTopWidget->inherits("GUIMessageDialog"))
|
||||
{
|
||||
GUIMessageDialog* parent = qobject_cast<GUIMessageDialog*>(mTopWidget);
|
||||
|
||||
@@ -72,6 +72,12 @@ QLabel {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
QLabel#Shutdown {
|
||||
color: #fcfcfc;
|
||||
font-weight: bold;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
min-height: 36px;
|
||||
max-height: 36px;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "InitializeWidget.h"
|
||||
#include "ShutdownWidget.h"
|
||||
#include "event/EventCenter.h"
|
||||
#include "forms/TabFormWidget.h"
|
||||
#include "forms/recon/ReconFormWidget.h"
|
||||
@@ -31,6 +32,7 @@ MainWindow::MainWindow(QWidget* aParent)
|
||||
, mDebugMessageConsole(nullptr)
|
||||
, mTabWidget(new QTabWidget(this))
|
||||
, mInitializWidget(new InitializeWidget(this))
|
||||
, mShutdownWidget(new ShutdownWidget(nullptr))
|
||||
, mAdminTabIndex(-1)
|
||||
, mThread(nullptr)
|
||||
, mIsDebugMode(false)
|
||||
@@ -50,6 +52,8 @@ MainWindow::MainWindow(QWidget* aParent)
|
||||
connect(EventCenter::Default(), &EventCenter::RequestScreenSaver, this, &MainWindow::requestScreenSaver);
|
||||
connect(DeviceManager::Default(), &DeviceManager::initializeFinished, this, &MainWindow::requestLogin);
|
||||
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]()
|
||||
{
|
||||
mInitializWidget->setVisible(false);
|
||||
@@ -64,6 +68,7 @@ MainWindow::~MainWindow()
|
||||
mThread->terminate();
|
||||
mThread->deleteLater();
|
||||
delete mUI;
|
||||
delete mShutdownWidget;
|
||||
}
|
||||
|
||||
//------Layout-----------------------------------------------------------------
|
||||
@@ -91,6 +96,7 @@ void MainWindow::initializeLayout()
|
||||
layout->addWidget(mInitializWidget);
|
||||
|
||||
mTabWidget->setVisible(false);
|
||||
mShutdownWidget->setVisible(false);
|
||||
}
|
||||
|
||||
void MainWindow::initializeTabWidget()
|
||||
@@ -114,6 +120,17 @@ void MainWindow::reloadLanguage() {
|
||||
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::centerWidgetHide()
|
||||
|
||||
@@ -19,6 +19,7 @@ class QSwipeGesture;
|
||||
class QPanGesture;
|
||||
class QDockWidget;
|
||||
class InitializeWidget;
|
||||
class ShutdownWidget;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
@@ -53,6 +54,8 @@ private:
|
||||
void swipeTriggered(QSwipeGesture* aSwipeGesture);
|
||||
void panTriggered(QPanGesture* aPanGesture);
|
||||
void loadStyleSheet(const QString& aSheetName);
|
||||
void showShutdownWidget();
|
||||
void processShutdownDmsFailed();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* mUI;
|
||||
@@ -60,6 +63,8 @@ private:
|
||||
QTextEdit* mDebugMessageConsole;
|
||||
QTabWidget* mTabWidget;
|
||||
InitializeWidget* mInitializWidget;
|
||||
ShutdownWidget* mShutdownWidget;
|
||||
|
||||
int mAdminTabIndex;
|
||||
QThread* mThread;
|
||||
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