81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include <QSystemTrayIcon>
|
|
#include <QFileDialog>
|
|
|
|
#include <daemon.h>
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QssMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
setWindowFlags( Qt::WindowStaysOnTopHint);
|
|
|
|
QSystemTrayIcon* m_tray; //托盘类
|
|
|
|
QMenu* m_menu; //托盘菜单
|
|
|
|
QAction* m_resetAction; //托盘按钮
|
|
|
|
QAction* m_quitAction; //托盘按钮
|
|
m_tray = new QSystemTrayIcon(this);//实例化
|
|
QPixmap m_logo(":/gif.ico");
|
|
|
|
m_tray->setIcon(QIcon(m_logo));//设置图标
|
|
m_tray->show();
|
|
connect(m_tray,&QSystemTrayIcon::activated,this,&MainWindow::TrayIconAction);
|
|
m_menu = new QMenu(this);
|
|
m_resetAction = new QAction(this);
|
|
m_resetAction->setText("show");
|
|
m_quitAction = new QAction(this);
|
|
m_resetAction->setIcon(QIcon(m_logo));
|
|
m_quitAction->setText("quit");
|
|
m_quitAction->setIcon(QIcon(m_logo));
|
|
connect(m_quitAction,&QAction::triggered,qApp,&QApplication::quit);
|
|
connect(m_resetAction,&QAction::triggered,this,&MainWindow::restory);
|
|
|
|
m_tray->setContextMenu(m_menu);//设置托盘菜单
|
|
m_menu->addAction(m_resetAction);
|
|
m_menu->addAction(m_quitAction);
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::GuadDone()
|
|
{
|
|
qDebug()<<"GuadDone";
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_clicked()
|
|
{
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
this,
|
|
tr("open a file."),
|
|
"D:/",
|
|
tr("exe(*.exe);;"));
|
|
if (fileName != "") {
|
|
m_path = fileName;
|
|
ui->lineEdit->setText(m_path);
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::on_pushButton_2_clicked()
|
|
{
|
|
if(mGuard == nullptr){
|
|
mGuard = new ASyncGuard();
|
|
}
|
|
connect(mGuard,&ASyncGuard::Done,
|
|
this,&MainWindow::GuadDone);
|
|
mGuard->Start(this);
|
|
}
|
|
|