From 2644e4e4df68d5c6b30063be7165185c7b58357b Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Fri, 16 Aug 2024 15:41:38 +0500 Subject: [PATCH] UI: Options: Tray: Add "Show Alert Icon" flag --- src/ui/form/opt/pages/ifacepage.cpp | 8 ++++++++ src/ui/form/opt/pages/ifacepage.h | 1 + src/ui/form/tray/trayicon.cpp | 3 +++ src/ui/user/iniuser.h | 3 +++ 4 files changed, 15 insertions(+) diff --git a/src/ui/form/opt/pages/ifacepage.cpp b/src/ui/form/opt/pages/ifacepage.cpp index b9c3c9d8..cfcd064a 100644 --- a/src/ui/form/opt/pages/ifacepage.cpp +++ b/src/ui/form/opt/pages/ifacepage.cpp @@ -54,6 +54,7 @@ void IfacePage::onResetToDefault() m_cbHomeAutoShowMenu->setChecked(false); m_cbSplashVisible->setChecked(true); m_cbTrayShowIcon->setChecked(true); + m_cbTrayShowAlert->setChecked(true); m_cbTrayAnimateAlert->setChecked(true); m_spinTrayMaxGroups->setValue(trayMaxGroups); @@ -123,6 +124,7 @@ void IfacePage::onRetranslateUi() m_cbSplashVisible->setText(tr("Show Splash screen on startup")); m_cbTrayShowIcon->setText(tr("Show Icon")); + m_cbTrayShowAlert->setText(tr("Show Alert Icon")); m_cbTrayAnimateAlert->setText(tr("Animate Alert Icon")); m_labelTrayMaxGroups->setText(tr("Maximum count of Groups in menu:")); m_labelTrayEvent->setText(tr("Event:")); @@ -452,6 +454,11 @@ void IfacePage::setupTrayBox() ctrl()->setIniUserEdited(true); }); + m_cbTrayShowAlert = ControlUtil::createCheckBox(iniUser()->trayShowAlert(), [&](bool checked) { + iniUser()->setTrayShowAlert(checked); + ctrl()->setIniUserEdited(); + }); + m_cbTrayAnimateAlert = ControlUtil::createCheckBox(iniUser()->trayAnimateAlert(), [&](bool checked) { iniUser()->setTrayAnimateAlert(checked); @@ -467,6 +474,7 @@ void IfacePage::setupTrayBox() auto layout = new QVBoxLayout(); layout->addWidget(m_cbTrayShowIcon); + layout->addWidget(m_cbTrayShowAlert); layout->addWidget(m_cbTrayAnimateAlert); layout->addLayout(maxGroupsLayout); layout->addWidget(ControlUtil::createSeparator()); diff --git a/src/ui/form/opt/pages/ifacepage.h b/src/ui/form/opt/pages/ifacepage.h index 4b85d6e9..0c569e0f 100644 --- a/src/ui/form/opt/pages/ifacepage.h +++ b/src/ui/form/opt/pages/ifacepage.h @@ -84,6 +84,7 @@ private: QCheckBox *m_cbHomeAutoShowMenu = nullptr; QCheckBox *m_cbSplashVisible = nullptr; QCheckBox *m_cbTrayShowIcon = nullptr; + QCheckBox *m_cbTrayShowAlert = nullptr; QCheckBox *m_cbTrayAnimateAlert = nullptr; QLabel *m_labelTrayMaxGroups = nullptr; QSpinBox *m_spinTrayMaxGroups = nullptr; diff --git a/src/ui/form/tray/trayicon.cpp b/src/ui/form/tray/trayicon.cpp index c57264e1..ce8af3a2 100644 --- a/src/ui/form/tray/trayicon.cpp +++ b/src/ui/form/tray/trayicon.cpp @@ -258,6 +258,9 @@ void TrayIcon::updateTrayIcon(bool alerted) if (m_alerted == alerted) return; + if (alerted && !iniUser()->trayShowAlert()) + return; + m_alerted = alerted; m_animatedAlert = false; diff --git a/src/ui/user/iniuser.h b/src/ui/user/iniuser.h index d57a7fb3..e016ab43 100644 --- a/src/ui/user/iniuser.h +++ b/src/ui/user/iniuser.h @@ -78,6 +78,9 @@ public: bool trayShowIcon() const { return valueBool("tray/showIcon", true); } void setTrayShowIcon(bool v) { setValue("tray/showIcon", v, true); } + bool trayShowAlert() const { return valueBool("tray/showAlert", true); } + void setTrayShowAlert(bool v) { setValue("tray/showAlert", v, true); } + bool trayAnimateAlert() const { return valueBool("tray/animateAlert", true); } void setTrayAnimateAlert(bool v) { setValue("tray/animateAlert", v, true); }