Show the application from left click on systray
This commit is contained in:
parent
7bca18f6b3
commit
b6284ea1e6
1 changed files with 9 additions and 1 deletions
|
|
@ -1003,9 +1003,17 @@ void App::setSysTrayIcon() {
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
}
|
}
|
||||||
menu->addAction(quitAction);
|
menu->addAction(quitAction);
|
||||||
if (!mSystemTrayIcon)
|
if (!mSystemTrayIcon) {
|
||||||
systemTrayIcon->setContextMenu(menu); // This is a Qt bug. We cannot call setContextMenu more than once. So we
|
systemTrayIcon->setContextMenu(menu); // This is a Qt bug. We cannot call setContextMenu more than once. So we
|
||||||
// have to keep an instance of the menu.
|
// have to keep an instance of the menu.
|
||||||
|
connect(systemTrayIcon, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
|
||||||
|
// Left-Click and Double Left-Click
|
||||||
|
if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::DoubleClick) {
|
||||||
|
auto mainWindow = getMainWindow();
|
||||||
|
if (mainWindow) mainWindow->show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
systemTrayIcon->setIcon(QIcon(Constants::WindowIconPath));
|
systemTrayIcon->setIcon(QIcon(Constants::WindowIconPath));
|
||||||
systemTrayIcon->setToolTip(APPLICATION_NAME);
|
systemTrayIcon->setToolTip(APPLICATION_NAME);
|
||||||
systemTrayIcon->show();
|
systemTrayIcon->show();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue