mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-04 22:48:44 +00:00
feat: quit to system tray
This commit is contained in:
parent
d3539738f5
commit
945117d464
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_showWindow);
|
||||||
m_menu->addAction(m_quit);
|
m_menu->addAction(m_quit);
|
||||||
m_hideIcon->setContextMenu(m_menu);
|
m_hideIcon->setContextMenu(m_menu);
|
||||||
|
m_hideIcon->show();
|
||||||
connect(m_showWindow, &QAction::triggered, this, &Dialog::slotShow);
|
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);
|
connect(m_hideIcon, &QSystemTrayIcon::activated,this,&Dialog::slotActivated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,26 +244,12 @@ void Dialog::slotActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
|
||||||
void Dialog::closeEvent(QCloseEvent *event)
|
void Dialog::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
int res = QMessageBox::question(this,tr("warning"),tr("Quit or set tray?"),tr("Quit"),tr("Set tray"),tr("Cancel"));
|
this->hide();
|
||||||
|
m_hideIcon->showMessage(tr("Notice"),
|
||||||
if(res == 0)
|
tr("Hidden here!"),
|
||||||
{
|
QSystemTrayIcon::Information,
|
||||||
event->accept();
|
3000);
|
||||||
}
|
event->ignore();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::on_updateDevice_clicked()
|
void Dialog::on_updateDevice_clicked()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue