mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:46:03 +00:00
UI: Tray: Fix confirmation checking
This commit is contained in:
parent
9b6dcb8a9e
commit
9399a309d3
@ -329,24 +329,25 @@ void TrayIcon::setupTrayMenu()
|
||||
m_menu->addSeparator();
|
||||
|
||||
m_filterEnabledAction =
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(saveTrayFlags()), true);
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true);
|
||||
addHotKey(m_filterEnabledAction, iniUser()->hotKeyFilter());
|
||||
|
||||
m_stopTrafficAction = addAction(m_menu, QIcon(), QString(), this, SLOT(saveTrayFlags()), true);
|
||||
m_stopTrafficAction =
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true);
|
||||
addHotKey(m_stopTrafficAction, iniUser()->hotKeyStopTraffic());
|
||||
|
||||
m_stopInetTrafficAction =
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(saveTrayFlags()), true);
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true);
|
||||
addHotKey(m_stopInetTrafficAction, iniUser()->hotKeyStopInetTraffic());
|
||||
|
||||
m_autoAllowProgsAction =
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(saveTrayFlags()), true);
|
||||
addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true);
|
||||
addHotKey(m_autoAllowProgsAction, iniUser()->hotKeyAllowAllNew());
|
||||
|
||||
m_menu->addSeparator();
|
||||
|
||||
for (int i = 0; i < MAX_APP_GROUP_COUNT; ++i) {
|
||||
QAction *a = addAction(m_menu, QIcon(), QString(), this, SLOT(saveTrayFlags()), true);
|
||||
QAction *a = addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true);
|
||||
|
||||
if (i < 12) {
|
||||
const QString shortcutText =
|
||||
@ -412,15 +413,6 @@ void TrayIcon::updateAppGroupActions()
|
||||
|
||||
void TrayIcon::saveTrayFlags()
|
||||
{
|
||||
if (iniUser()->confirmTrayFlags()) {
|
||||
const auto action = qobject_cast<QAction *>(sender());
|
||||
Q_ASSERT(action);
|
||||
|
||||
if (!windowManager()->showQuestionBox(
|
||||
tr("Are you sure to switch \"%1\"?").arg(action->text())))
|
||||
return;
|
||||
}
|
||||
|
||||
conf()->setFilterEnabled(m_filterEnabledAction->isChecked());
|
||||
conf()->setStopTraffic(m_stopTrafficAction->isChecked());
|
||||
conf()->setStopInetTraffic(m_stopInetTrafficAction->isChecked());
|
||||
@ -435,6 +427,22 @@ void TrayIcon::saveTrayFlags()
|
||||
confManager()->saveFlags();
|
||||
}
|
||||
|
||||
void TrayIcon::switchTrayFlag(bool checked)
|
||||
{
|
||||
if (iniUser()->confirmTrayFlags()) {
|
||||
const auto action = qobject_cast<QAction *>(sender());
|
||||
Q_ASSERT(action);
|
||||
|
||||
if (!windowManager()->showQuestionBox(
|
||||
tr("Are you sure to switch \"%1\"?").arg(action->text()))) {
|
||||
action->setChecked(!checked);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
saveTrayFlags();
|
||||
}
|
||||
|
||||
void TrayIcon::quitProgram()
|
||||
{
|
||||
if (iniUser()->confirmQuit()) {
|
||||
|
@ -58,6 +58,8 @@ protected slots:
|
||||
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
|
||||
void saveTrayFlags();
|
||||
|
||||
void switchTrayFlag(bool checked);
|
||||
void quitProgram();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user