diff --git a/ZoomPipeline_FuncSvr/zpmainframe.cpp b/ZoomPipeline_FuncSvr/zpmainframe.cpp index 0dfeab0cda9e11d67638b2835c2a48bb2ada336a..422e7af63b9ae4c163dd288a69b254111c9bbbf0 100644 --- a/ZoomPipeline_FuncSvr/zpmainframe.cpp +++ b/ZoomPipeline_FuncSvr/zpmainframe.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "smartlink/st_clientnode_basetrans.h" #include "dialogaddressinput.h" using namespace ZPNetwork; @@ -26,6 +27,7 @@ ZPMainFrame::ZPMainFrame(QWidget *parent) :QMainWindow(parent) ,ui(new Ui::ZPMainFrame) ,m_pLogger(0) + ,m_IconTray(0) { m_currentConfigFile = QCoreApplication::applicationFilePath()+".ini"; ui->setupUi(this); @@ -59,6 +61,13 @@ ZPMainFrame::ZPMainFrame(QWidget *parent) m_nTimerCheck = startTimer(10000); initUI(); LoadSettings(m_currentConfigFile); + m_pTrayMenu = new QMenu (this); + m_pTrayMenu->addAction(ui->actionShow_Window); + m_pTrayMenu->addAction(ui->actionExit); + + m_IconTray = new QSystemTrayIcon(QIcon(":/icons/Resources/Backup drive.png"),this); + m_IconTray->setContextMenu(m_pTrayMenu); + m_IconTray->show(); } ZPMainFrame::~ZPMainFrame() @@ -107,6 +116,14 @@ void ZPMainFrame::changeEvent(QEvent *e) case QEvent::LanguageChange: ui->retranslateUi(this); break; + case QEvent::WindowStateChange: + if (this->isMinimized()==true) + { + this->hide(); + this->m_IconTray->showMessage(tr("Server still running"), + tr("If you want to terminate server, just using exit Toolbar button.")); + } + break; default: break; } @@ -925,3 +942,31 @@ void ZPMainFrame::LoadSettingsAndForkServer(const QString & configfile) } } + +void ZPMainFrame::on_actionShow_Window_triggered() +{ + this->showNormal(); +} +void ZPMainFrame::closeEvent(QCloseEvent * e) +{ + if (this->isVisible()==true) + { + this->hide(); + this->m_IconTray->showMessage(tr("Server still running"), + tr("If you want to terminate server, just using exit Toolbar button.")); + e->ignore(); + } + else + { + e->accept(); + this->m_IconTray->showMessage(tr("Server is going to closed"), + tr("Waiting for all unfinished progress...")); + } +} + +void ZPMainFrame::on_actionExit_triggered() +{ + this->hide(); + this->m_IconTray->setContextMenu(0); + this->close(); +} diff --git a/ZoomPipeline_FuncSvr/zpmainframe.h b/ZoomPipeline_FuncSvr/zpmainframe.h index 579be10fb609c9365fd742d245504eadfe88d918..94d874b20548e28352f31a52d9733aee2f281fbe 100644 --- a/ZoomPipeline_FuncSvr/zpmainframe.h +++ b/ZoomPipeline_FuncSvr/zpmainframe.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "network/zp_net_threadpool.h" #include "pipeline/zp_pipeline.h" #include "smartlink/st_client_table.h" @@ -29,6 +31,7 @@ public: void setLogger(STMsgLogger::st_logger * plogger); protected: void changeEvent(QEvent *e); + void closeEvent(QCloseEvent * e); QStandardItemModel * m_pMsgModelNetwork; QStandardItemModel * m_pMsgModelCluster; QStandardItemModel * m_pMsgModelDatabase; @@ -53,6 +56,8 @@ protected: private: Ui::ZPMainFrame *ui; + QSystemTrayIcon * m_IconTray ; + QMenu * m_pTrayMenu; QLabel * m_pStatusLabel; ZPNetwork::zp_net_Engine * m_netEngine; ZPTaskEngine::zp_pipeline * m_taskEngine; @@ -80,6 +85,8 @@ public slots: void on_action_Start_Stop_triggered(bool); void on_action_About_triggered(); void on_actionReload_config_file_triggered(); + void on_actionShow_Window_triggered(); + void on_actionExit_triggered(); void on_pushButton_addListener_clicked(); void on_pushButton_delListener_clicked(); void on_pushButton_listerner_apply_clicked(); diff --git a/ZoomPipeline_FuncSvr/zpmainframe.ui b/ZoomPipeline_FuncSvr/zpmainframe.ui index c0b3a9b349366929f6410cb0970f4d897f0f0733..8265d4d2f4f94638eac1dd28d039c55ef28b9f84 100644 --- a/ZoomPipeline_FuncSvr/zpmainframe.ui +++ b/ZoomPipeline_FuncSvr/zpmainframe.ui @@ -1121,28 +1121,24 @@ Reload Config file + + + + :/icons/Resources/Color, Bondi.png:/icons/Resources/Color, Bondi.png + + + Show&Window + + + Show main window + + - - dial_plain_trans_threads - valueChanged(int) - progressBar_plain_threads - setValue(int) - - - 266 - 145 - - - 421 - 144 - - - dial_ssl_trans_threads valueChanged(int) @@ -1175,22 +1171,6 @@ - - actionExit - triggered() - ZPMainFrame - close() - - - -1 - -1 - - - 277 - 206 - - - horizontalSlider_heartbeating valueChanged(int)