diff --git a/src/ui/form/opt/pages/ifacepage.cpp b/src/ui/form/opt/pages/ifacepage.cpp index a7f5e18f..77a38c21 100644 --- a/src/ui/form/opt/pages/ifacepage.cpp +++ b/src/ui/form/opt/pages/ifacepage.cpp @@ -60,11 +60,11 @@ void IfacePage::onResetToDefault() m_cbAppAlertAutoShow->setChecked(true); m_cbAppAlertAlwaysOnTop->setChecked(true); m_cbAppAlertAutoActive->setChecked(false); + m_cbAppAlertSound->setChecked(false); m_cbTrayShowIcon->setChecked(true); m_cbTrayShowAlert->setChecked(true); m_cbTrayAnimateAlert->setChecked(true); - m_cbTraySoundAlert->setChecked(false); m_spinTrayMaxGroups->setValue(trayMaxGroups); @@ -137,11 +137,11 @@ void IfacePage::onRetranslateUi() m_cbAppAlertAutoShow->setText(tr("Auto-Show Alert Window for New Programs")); m_cbAppAlertAlwaysOnTop->setText(tr("Alert Window is Always on top")); m_cbAppAlertAutoActive->setText(tr("Alert Window is auto-active")); + m_cbAppAlertSound->setText(tr("Sound Alert")); m_cbTrayShowIcon->setText(tr("Show Icon")); m_cbTrayShowAlert->setText(tr("Show Alert Icon")); m_cbTrayAnimateAlert->setText(tr("Animate Alert Icon")); - m_cbTraySoundAlert->setText(tr("Sound Alert")); m_labelTrayMaxGroups->setText(tr("Maximum count of Groups in menu:")); m_labelTrayEvent->setText(tr("Event:")); m_labelTrayAction->setText(tr("Action:")); @@ -490,9 +490,14 @@ void IfacePage::setupProgBox() ctrl()->setIniUserEdited(); }); + m_cbAppAlertSound = ControlUtil::createCheckBox(iniUser()->progAlertSound(), [&](bool checked) { + iniUser()->setProgAlertSound(checked); + ctrl()->setIniUserEdited(); + }); + // Layout auto layout = ControlUtil::createVLayoutByWidgets({ m_cbAppNotifyMessage, m_cbAppAlertAutoShow, - m_cbAppAlertAlwaysOnTop, m_cbAppAlertAutoActive }); + m_cbAppAlertAlwaysOnTop, m_cbAppAlertAutoActive, m_cbAppAlertSound }); m_gbProg = new QGroupBox(); m_gbProg->setLayout(layout); @@ -516,12 +521,6 @@ void IfacePage::setupTrayBox() ctrl()->setIniUserEdited(); }); - m_cbTraySoundAlert = - ControlUtil::createCheckBox(iniUser()->traySoundAlert(), [&](bool checked) { - iniUser()->setTraySoundAlert(checked); - ctrl()->setIniUserEdited(); - }); - // Tray Max. Groups Row auto maxGroupsLayout = setupTrayMaxGroupsLayout(); @@ -533,7 +532,6 @@ void IfacePage::setupTrayBox() layout->addWidget(m_cbTrayShowIcon); layout->addWidget(m_cbTrayShowAlert); layout->addWidget(m_cbTrayAnimateAlert); - layout->addWidget(m_cbTraySoundAlert); layout->addLayout(maxGroupsLayout); layout->addWidget(ControlUtil::createSeparator()); layout->addLayout(eventLayout); diff --git a/src/ui/form/opt/pages/ifacepage.h b/src/ui/form/opt/pages/ifacepage.h index bc53f56a..4dce3972 100644 --- a/src/ui/form/opt/pages/ifacepage.h +++ b/src/ui/form/opt/pages/ifacepage.h @@ -93,11 +93,11 @@ private: QCheckBox *m_cbAppAlertAutoShow = nullptr; QCheckBox *m_cbAppAlertAlwaysOnTop = nullptr; QCheckBox *m_cbAppAlertAutoActive = nullptr; + QCheckBox *m_cbAppAlertSound = nullptr; QCheckBox *m_cbTrayShowIcon = nullptr; QCheckBox *m_cbTrayShowAlert = nullptr; QCheckBox *m_cbTrayAnimateAlert = nullptr; - QCheckBox *m_cbTraySoundAlert = 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 658376cd..db9c3b80 100644 --- a/src/ui/form/tray/trayicon.cpp +++ b/src/ui/form/tray/trayicon.cpp @@ -260,10 +260,6 @@ void TrayIcon::updateTrayIcon(bool alerted) return; if (alerted) { - if (iniUser()->traySoundAlert()) { - OsUtil::playSound(); - } - if (!iniUser()->trayShowAlert()) return; } @@ -627,6 +623,10 @@ void TrayIcon::sendAlertMessage() tr("New program detected!"), WindowManager::TrayMessageAlert); } + if (iniUser()->progAlertSound()) { + OsUtil::playSound(); + } + if (iniUser()->progAlertWindowAutoShow()) { windowManager()->showProgramAlertWindow(/*activate=*/false); } diff --git a/src/ui/user/iniuser.h b/src/ui/user/iniuser.h index 87c75fa3..6c485a1a 100644 --- a/src/ui/user/iniuser.h +++ b/src/ui/user/iniuser.h @@ -75,6 +75,9 @@ public: bool progNotifyMessage() const { return valueBool("prog/notifyMessage", true); } void setProgNotifyMessage(bool v) { setValue("prog/notifyMessage", v, true); } + bool progAlertSound() const { return valueBool("prog/soundAlert"); } + void setProgAlertSound(bool v) { setValue("prog/soundAlert", v); } + bool trayShowIcon() const { return valueBool("tray/showIcon", true); } void setTrayShowIcon(bool v) { setValue("tray/showIcon", v, true); } @@ -84,9 +87,6 @@ public: bool trayAnimateAlert() const { return valueBool("tray/animateAlert", true); } void setTrayAnimateAlert(bool v) { setValue("tray/animateAlert", v, true); } - bool traySoundAlert() const { return valueBool("tray/soundAlert"); } - void setTraySoundAlert(bool v) { setValue("tray/soundAlert", v); } - int trayMaxGroups(int v = 0) const { return valueInt("tray/maxGroups", v); } void setTrayMaxGroups(int v) { setValue("tray/maxGroups", v); }