mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
feat: quit to system tray
This commit is contained in:
parent
493c87ada1
commit
f904a8c284
1 changed files with 11 additions and 21 deletions
|
@ -87,8 +87,12 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog)
|
|||
m_menu->addAction(m_showWindow);
|
||||
m_menu->addAction(m_quit);
|
||||
m_hideIcon->setContextMenu(m_menu);
|
||||
m_hideIcon->show();
|
||||
connect(m_showWindow, &QAction::triggered, this, &Dialog::slotShow);
|
||||
connect(m_quit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
connect(m_quit, &QAction::triggered, this, [this](){
|
||||
m_hideIcon->hide();
|
||||
qApp->quit();
|
||||
});
|
||||
connect(m_hideIcon, &QSystemTrayIcon::activated,this,&Dialog::slotActivated);
|
||||
}
|
||||
|
||||
|
@ -240,26 +244,12 @@ void Dialog::slotActivated(QSystemTrayIcon::ActivationReason reason)
|
|||
|
||||
void Dialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
int res = QMessageBox::question(this,tr("warning"),tr("Quit or set tray?"),tr("Quit"),tr("Set tray"),tr("Cancel"));
|
||||
|
||||
if(res == 0)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
else if(res == 1)
|
||||
{
|
||||
this->hide();
|
||||
m_hideIcon->show();
|
||||
m_hideIcon->showMessage(tr("Notice"),
|
||||
tr("Hidden here!"),
|
||||
QSystemTrayIcon::Information,
|
||||
3000);
|
||||
event->ignore();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
this->hide();
|
||||
m_hideIcon->showMessage(tr("Notice"),
|
||||
tr("Hidden here!"),
|
||||
QSystemTrayIcon::Information,
|
||||
3000);
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void Dialog::on_updateDevice_clicked()
|
||||
|
|
Loading…
Add table
Reference in a new issue