123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #ifndef DIALOG_H
- #define DIALOG_H
- #include "mythread.h"
- #include <QDialog>
- #include "serialport/serailport.h"
- #include "hkcamera/hkcamera.h"
- #include<QMessageBox>
- #include <QCloseEvent>
- #include <QSystemTrayIcon>
- #include <QMenu>
- #include <QAction>
- #include <QVBoxLayout>
- #include <QPushButton>
- #include <QApplication>
- namespace Ui {
- class Dialog;
- }
- class Dialog : public QDialog
- {
- Q_OBJECT
- public:
- explicit Dialog(QWidget *parent = nullptr);
- ~Dialog();
-
- void closeEvent(QCloseEvent* e);
- private:
- QSystemTrayIcon *trayIcon;
- public:
- void startInBackground() {
-
-
- hide();
-
- trayIcon = new QSystemTrayIcon(this);
- trayIcon->setIcon(QIcon("D:/irdet/cfg/ir.jpg"));
- trayIcon->setToolTip("红外缺陷检测");
-
- QMenu *menu = new QMenu(this);
- QAction *showAction = menu->addAction("Show Dialog");
- QAction *quitAction = menu->addAction("Quit");
-
- connect(showAction, &QAction::triggered, this, &Dialog::show);
- connect(quitAction, &QAction::triggered, qApp, &QApplication::quit);
- connect(trayIcon, &QSystemTrayIcon::activated, this, &Dialog::onTrayIconActivated);
-
- trayIcon->setContextMenu(menu);
-
- trayIcon->show();
-
- if (!trayIcon->isSystemTrayAvailable()) {
-
- QMessageBox::warning(this, "Tray Icon", "System tray is not available.");
- show();
- }
- }
-
- void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason) {
- if (reason == QSystemTrayIcon::Trigger) {
-
- show();
- activateWindow();
- raise();
- }
- }
- private: void irdetnetproc();
- private:
- QTcpSocket* ptcpSocket = nullptr;
- QTcpSocket* ptcpSocket1 = nullptr;
- private slots:
- void on_OpenPortButton_clicked();
- void on_OpenButton_clicked();
- void on_SavePicButton_clicked();
- void on_CloseButton_clicked();
- void on_minimizeButton_clicked() {
- hide();
- }
-
- void on_SendCmdButton_clicked();
- void grabPicandRes();
-
- virtual void timerEvent(QTimerEvent *);
- public:
- Ui::Dialog *ui;
- int hstopheattimerid;
- int hkilltimerid;
- int htimersampleid;
- QString strnewidr = "";
- QString strposition = "";
- qint64 qiheatms = 0;
- public:
- SerailPort* serailPort;
- hkcamera* phkcamera = nullptr;
- };
- #endif
|