提交 ce10ce13 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add Tray ICON features

上级 38244239
......@@ -10,6 +10,7 @@
#include <QTcpSocket>
#include <QThread>
#include <QSslSocket>
#include <QSystemTrayIcon>
#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();
}
......@@ -6,6 +6,8 @@
#include <QLabel>
#include <QSet>
#include <QMap>
#include <QMenu>
#include <QSystemTrayIcon>
#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();
......
......@@ -1121,28 +1121,24 @@
<string>Reload Config file</string>
</property>
</action>
<action name="actionShow_Window">
<property name="icon">
<iconset resource="resource.qrc">
<normaloff>:/icons/Resources/Color, Bondi.png</normaloff>:/icons/Resources/Color, Bondi.png</iconset>
</property>
<property name="text">
<string>Show&amp;Window</string>
</property>
<property name="toolTip">
<string>Show main window</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="resource.qrc"/>
</resources>
<connections>
<connection>
<sender>dial_plain_trans_threads</sender>
<signal>valueChanged(int)</signal>
<receiver>progressBar_plain_threads</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>266</x>
<y>145</y>
</hint>
<hint type="destinationlabel">
<x>421</x>
<y>144</y>
</hint>
</hints>
</connection>
<connection>
<sender>dial_ssl_trans_threads</sender>
<signal>valueChanged(int)</signal>
......@@ -1175,22 +1171,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionExit</sender>
<signal>triggered()</signal>
<receiver>ZPMainFrame</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>277</x>
<y>206</y>
</hint>
</hints>
</connection>
<connection>
<sender>horizontalSlider_heartbeating</sender>
<signal>valueChanged(int)</signal>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册