diff --git a/PhaseCompAcq/PhaseCompAcq.pro b/PhaseCompAcq/PhaseCompAcq.pro index f51a158..2bbc10a 100644 --- a/PhaseCompAcq/PhaseCompAcq.pro +++ b/PhaseCompAcq/PhaseCompAcq.pro @@ -26,3 +26,5 @@ DEPENDPATH += $$PWD/include/librdkafka DISTFILES += conf/config.ini + +RESOURCES += res.qrc diff --git a/PhaseCompAcq/PhaseCompAcq.pro b/PhaseCompAcq/PhaseCompAcq.pro index f51a158..2bbc10a 100644 --- a/PhaseCompAcq/PhaseCompAcq.pro +++ b/PhaseCompAcq/PhaseCompAcq.pro @@ -26,3 +26,5 @@ DEPENDPATH += $$PWD/include/librdkafka DISTFILES += conf/config.ini + +RESOURCES += res.qrc diff --git a/PhaseCompAcq/PhaseWindow.cpp b/PhaseCompAcq/PhaseWindow.cpp index 73cd115..59174b3 100644 --- a/PhaseCompAcq/PhaseWindow.cpp +++ b/PhaseCompAcq/PhaseWindow.cpp @@ -1,4 +1,4 @@ -#include "PhaseWindow.h" +#include "PhaseWindow.h" #include "ui_PhaseWindow.h" #include @@ -24,6 +24,8 @@ // 窗口大小为占满一屏 QRect screenRect = QApplication::desktop()->availableGeometry(); resize(screenRect.width(), screenRect.height()); + setWindowIcon(QIcon(":/images/PhaseComp.png")); + setWindowState(Qt::WindowFullScreen); // 将窗口移动到左上角 move(0, 0); @@ -32,6 +34,13 @@ ui->startButt->move(screenRect.width() - 200, 10); ui->line->setGeometry(0, 59, screenRect.width(), 1); + trayIcon = new QSystemTrayIcon(this); + trayIcon->setIcon(QIcon(":/images/PhaseComp.png")); + trayIcon->setToolTip(QString("相位测量数据采集软件(%1)").arg(SettingConfig::getInstance().MASTER == 1 ? "主" : "备")); + trayIcon->show(); + + connect(trayIcon, &QSystemTrayIcon::activated, this, &PhaseWindow::onTrayIconActived); + // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 60, screenRect.width(), screenRect.height() - 60); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -373,16 +382,25 @@ void PhaseWindow::on_minButt_clicked() { - setWindowState(Qt::WindowMinimized | windowState()); + this->hide(); } - +void PhaseWindow::onTrayIconActived(QSystemTrayIcon::ActivationReason reason) +{ + switch (reason) { + case QSystemTrayIcon::Trigger: // left click + case QSystemTrayIcon::Context: // right click + this->show(); + break; + default: + break; + } +} void PhaseWindow::on_startButt_clicked() { int devSelected = ui->devSelect->currentIndex(); PhaseDevice * device = deviceList.at(devSelected); device->startWork(); } - void PhaseWindow::on_endButt_clicked() { int devSelected = ui->devSelect->currentIndex(); diff --git a/PhaseCompAcq/PhaseCompAcq.pro b/PhaseCompAcq/PhaseCompAcq.pro index f51a158..2bbc10a 100644 --- a/PhaseCompAcq/PhaseCompAcq.pro +++ b/PhaseCompAcq/PhaseCompAcq.pro @@ -26,3 +26,5 @@ DEPENDPATH += $$PWD/include/librdkafka DISTFILES += conf/config.ini + +RESOURCES += res.qrc diff --git a/PhaseCompAcq/PhaseWindow.cpp b/PhaseCompAcq/PhaseWindow.cpp index 73cd115..59174b3 100644 --- a/PhaseCompAcq/PhaseWindow.cpp +++ b/PhaseCompAcq/PhaseWindow.cpp @@ -1,4 +1,4 @@ -#include "PhaseWindow.h" +#include "PhaseWindow.h" #include "ui_PhaseWindow.h" #include @@ -24,6 +24,8 @@ // 窗口大小为占满一屏 QRect screenRect = QApplication::desktop()->availableGeometry(); resize(screenRect.width(), screenRect.height()); + setWindowIcon(QIcon(":/images/PhaseComp.png")); + setWindowState(Qt::WindowFullScreen); // 将窗口移动到左上角 move(0, 0); @@ -32,6 +34,13 @@ ui->startButt->move(screenRect.width() - 200, 10); ui->line->setGeometry(0, 59, screenRect.width(), 1); + trayIcon = new QSystemTrayIcon(this); + trayIcon->setIcon(QIcon(":/images/PhaseComp.png")); + trayIcon->setToolTip(QString("相位测量数据采集软件(%1)").arg(SettingConfig::getInstance().MASTER == 1 ? "主" : "备")); + trayIcon->show(); + + connect(trayIcon, &QSystemTrayIcon::activated, this, &PhaseWindow::onTrayIconActived); + // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 60, screenRect.width(), screenRect.height() - 60); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -373,16 +382,25 @@ void PhaseWindow::on_minButt_clicked() { - setWindowState(Qt::WindowMinimized | windowState()); + this->hide(); } - +void PhaseWindow::onTrayIconActived(QSystemTrayIcon::ActivationReason reason) +{ + switch (reason) { + case QSystemTrayIcon::Trigger: // left click + case QSystemTrayIcon::Context: // right click + this->show(); + break; + default: + break; + } +} void PhaseWindow::on_startButt_clicked() { int devSelected = ui->devSelect->currentIndex(); PhaseDevice * device = deviceList.at(devSelected); device->startWork(); } - void PhaseWindow::on_endButt_clicked() { int devSelected = ui->devSelect->currentIndex(); diff --git a/PhaseCompAcq/PhaseWindow.h b/PhaseCompAcq/PhaseWindow.h index bf964fa..c2fd2ec 100644 --- a/PhaseCompAcq/PhaseWindow.h +++ b/PhaseCompAcq/PhaseWindow.h @@ -1,8 +1,9 @@ -#ifndef PHASEWINDOW_H +#ifndef PHASEWINDOW_H #define PHASEWINDOW_H #include #include +#include #include #include @@ -30,10 +31,9 @@ private slots: void on_minButt_clicked(); - void on_startButt_clicked(); - void on_endButt_clicked(); + void onTrayIconActived(QSystemTrayIcon::ActivationReason reason); void on_devSelect_currentIndexChanged(int index); @@ -47,6 +47,8 @@ Ui::PhaseWindow *ui; + QSystemTrayIcon * trayIcon; + QKafkaConsumer * kafkaConsumer; HttpRequestController * httpReq; diff --git a/PhaseCompAcq/PhaseCompAcq.pro b/PhaseCompAcq/PhaseCompAcq.pro index f51a158..2bbc10a 100644 --- a/PhaseCompAcq/PhaseCompAcq.pro +++ b/PhaseCompAcq/PhaseCompAcq.pro @@ -26,3 +26,5 @@ DEPENDPATH += $$PWD/include/librdkafka DISTFILES += conf/config.ini + +RESOURCES += res.qrc diff --git a/PhaseCompAcq/PhaseWindow.cpp b/PhaseCompAcq/PhaseWindow.cpp index 73cd115..59174b3 100644 --- a/PhaseCompAcq/PhaseWindow.cpp +++ b/PhaseCompAcq/PhaseWindow.cpp @@ -1,4 +1,4 @@ -#include "PhaseWindow.h" +#include "PhaseWindow.h" #include "ui_PhaseWindow.h" #include @@ -24,6 +24,8 @@ // 窗口大小为占满一屏 QRect screenRect = QApplication::desktop()->availableGeometry(); resize(screenRect.width(), screenRect.height()); + setWindowIcon(QIcon(":/images/PhaseComp.png")); + setWindowState(Qt::WindowFullScreen); // 将窗口移动到左上角 move(0, 0); @@ -32,6 +34,13 @@ ui->startButt->move(screenRect.width() - 200, 10); ui->line->setGeometry(0, 59, screenRect.width(), 1); + trayIcon = new QSystemTrayIcon(this); + trayIcon->setIcon(QIcon(":/images/PhaseComp.png")); + trayIcon->setToolTip(QString("相位测量数据采集软件(%1)").arg(SettingConfig::getInstance().MASTER == 1 ? "主" : "备")); + trayIcon->show(); + + connect(trayIcon, &QSystemTrayIcon::activated, this, &PhaseWindow::onTrayIconActived); + // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 60, screenRect.width(), screenRect.height() - 60); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -373,16 +382,25 @@ void PhaseWindow::on_minButt_clicked() { - setWindowState(Qt::WindowMinimized | windowState()); + this->hide(); } - +void PhaseWindow::onTrayIconActived(QSystemTrayIcon::ActivationReason reason) +{ + switch (reason) { + case QSystemTrayIcon::Trigger: // left click + case QSystemTrayIcon::Context: // right click + this->show(); + break; + default: + break; + } +} void PhaseWindow::on_startButt_clicked() { int devSelected = ui->devSelect->currentIndex(); PhaseDevice * device = deviceList.at(devSelected); device->startWork(); } - void PhaseWindow::on_endButt_clicked() { int devSelected = ui->devSelect->currentIndex(); diff --git a/PhaseCompAcq/PhaseWindow.h b/PhaseCompAcq/PhaseWindow.h index bf964fa..c2fd2ec 100644 --- a/PhaseCompAcq/PhaseWindow.h +++ b/PhaseCompAcq/PhaseWindow.h @@ -1,8 +1,9 @@ -#ifndef PHASEWINDOW_H +#ifndef PHASEWINDOW_H #define PHASEWINDOW_H #include #include +#include #include #include @@ -30,10 +31,9 @@ private slots: void on_minButt_clicked(); - void on_startButt_clicked(); - void on_endButt_clicked(); + void onTrayIconActived(QSystemTrayIcon::ActivationReason reason); void on_devSelect_currentIndexChanged(int index); @@ -47,6 +47,8 @@ Ui::PhaseWindow *ui; + QSystemTrayIcon * trayIcon; + QKafkaConsumer * kafkaConsumer; HttpRequestController * httpReq; diff --git a/PhaseCompAcq/images/PhaseComp.png b/PhaseCompAcq/images/PhaseComp.png new file mode 100644 index 0000000..1787eb7 --- /dev/null +++ b/PhaseCompAcq/images/PhaseComp.png Binary files differ diff --git a/PhaseCompAcq/PhaseCompAcq.pro b/PhaseCompAcq/PhaseCompAcq.pro index f51a158..2bbc10a 100644 --- a/PhaseCompAcq/PhaseCompAcq.pro +++ b/PhaseCompAcq/PhaseCompAcq.pro @@ -26,3 +26,5 @@ DEPENDPATH += $$PWD/include/librdkafka DISTFILES += conf/config.ini + +RESOURCES += res.qrc diff --git a/PhaseCompAcq/PhaseWindow.cpp b/PhaseCompAcq/PhaseWindow.cpp index 73cd115..59174b3 100644 --- a/PhaseCompAcq/PhaseWindow.cpp +++ b/PhaseCompAcq/PhaseWindow.cpp @@ -1,4 +1,4 @@ -#include "PhaseWindow.h" +#include "PhaseWindow.h" #include "ui_PhaseWindow.h" #include @@ -24,6 +24,8 @@ // 窗口大小为占满一屏 QRect screenRect = QApplication::desktop()->availableGeometry(); resize(screenRect.width(), screenRect.height()); + setWindowIcon(QIcon(":/images/PhaseComp.png")); + setWindowState(Qt::WindowFullScreen); // 将窗口移动到左上角 move(0, 0); @@ -32,6 +34,13 @@ ui->startButt->move(screenRect.width() - 200, 10); ui->line->setGeometry(0, 59, screenRect.width(), 1); + trayIcon = new QSystemTrayIcon(this); + trayIcon->setIcon(QIcon(":/images/PhaseComp.png")); + trayIcon->setToolTip(QString("相位测量数据采集软件(%1)").arg(SettingConfig::getInstance().MASTER == 1 ? "主" : "备")); + trayIcon->show(); + + connect(trayIcon, &QSystemTrayIcon::activated, this, &PhaseWindow::onTrayIconActived); + // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 60, screenRect.width(), screenRect.height() - 60); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -373,16 +382,25 @@ void PhaseWindow::on_minButt_clicked() { - setWindowState(Qt::WindowMinimized | windowState()); + this->hide(); } - +void PhaseWindow::onTrayIconActived(QSystemTrayIcon::ActivationReason reason) +{ + switch (reason) { + case QSystemTrayIcon::Trigger: // left click + case QSystemTrayIcon::Context: // right click + this->show(); + break; + default: + break; + } +} void PhaseWindow::on_startButt_clicked() { int devSelected = ui->devSelect->currentIndex(); PhaseDevice * device = deviceList.at(devSelected); device->startWork(); } - void PhaseWindow::on_endButt_clicked() { int devSelected = ui->devSelect->currentIndex(); diff --git a/PhaseCompAcq/PhaseWindow.h b/PhaseCompAcq/PhaseWindow.h index bf964fa..c2fd2ec 100644 --- a/PhaseCompAcq/PhaseWindow.h +++ b/PhaseCompAcq/PhaseWindow.h @@ -1,8 +1,9 @@ -#ifndef PHASEWINDOW_H +#ifndef PHASEWINDOW_H #define PHASEWINDOW_H #include #include +#include #include #include @@ -30,10 +31,9 @@ private slots: void on_minButt_clicked(); - void on_startButt_clicked(); - void on_endButt_clicked(); + void onTrayIconActived(QSystemTrayIcon::ActivationReason reason); void on_devSelect_currentIndexChanged(int index); @@ -47,6 +47,8 @@ Ui::PhaseWindow *ui; + QSystemTrayIcon * trayIcon; + QKafkaConsumer * kafkaConsumer; HttpRequestController * httpReq; diff --git a/PhaseCompAcq/images/PhaseComp.png b/PhaseCompAcq/images/PhaseComp.png new file mode 100644 index 0000000..1787eb7 --- /dev/null +++ b/PhaseCompAcq/images/PhaseComp.png Binary files differ diff --git a/PhaseCompAcq/res.qrc b/PhaseCompAcq/res.qrc new file mode 100644 index 0000000..7f68ff1 --- /dev/null +++ b/PhaseCompAcq/res.qrc @@ -0,0 +1,5 @@ + + + images/PhaseComp.png + +