Add event listener on tray.

This commit is contained in:
Black Hat 2018-09-06 19:34:14 +08:00
parent bd5c119f53
commit 96874cba06
1 changed files with 5 additions and 0 deletions

View File

@ -13,6 +13,11 @@
Controller::Controller(QObject* parent) : QObject(parent) { Controller::Controller(QObject* parent) : QObject(parent) {
tray->setIcon(QIcon(":/asset/img/icon.png")); tray->setIcon(QIcon(":/asset/img/icon.png"));
tray->setToolTip("Matrique"); tray->setToolTip("Matrique");
connect(tray, &QSystemTrayIcon::activated,
[this](QSystemTrayIcon::ActivationReason r) {
if (r != QSystemTrayIcon::Context) emit toggleWindow();
});
connect(tray, &QSystemTrayIcon::messageClicked, [=] { emit toggleWindow(); });
trayMenu->addAction("Toggle Window", [=] { emit toggleWindow(); }); trayMenu->addAction("Toggle Window", [=] { emit toggleWindow(); });
trayMenu->addAction("Quit", [=] { QApplication::quit(); }); trayMenu->addAction("Quit", [=] { QApplication::quit(); });
tray->setContextMenu(trayMenu); tray->setContextMenu(trayMenu);