Implement tray icon click

This commit is contained in:
BlackMark 2020-07-08 23:06:38 +02:00
parent 4bb32f0bd0
commit 1e3596a230
2 changed files with 10 additions and 0 deletions

View File

@ -62,6 +62,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
m_trayIcon->setContextMenu(m_trayIconMenu);
m_trayIcon->show();
m_trayIcon->setToolTip(tr("AdaptiveBrightness"));
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconClicked);
qDebug(ltr("Tray icon initialized"));
}
@ -201,3 +202,10 @@ void MainWindow::updateState()
m_trayIcon->setToolTip(tr("AdaptiveBrightness - %1%").arg(m_brightness * 100, 0, 'f', 0));
}
}
void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::ActivationReason::Trigger) {
m_showHideAction->trigger();
}
}

View File

@ -31,6 +31,8 @@ class MainWindow : public QMainWindow {
void updateState();
void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
Ui::AdaptiveBrightnessClass m_ui;
std::array<std::unique_ptr<QIcon>, 9> m_noSensorStateIcons;