From 8d2f12bf9202027adb8cc3f90dbd6aaaa1f8a626 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Thu, 4 Apr 2024 17:43:14 +0300 Subject: [PATCH] UI: IniUser: Refactor HotKey::filterModes --- src/ui/form/tray/trayicon.cpp | 2 +- src/ui/user/iniuser.cpp | 12 ++++++++++++ src/ui/user/iniuser.h | 14 +++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/ui/form/tray/trayicon.cpp b/src/ui/form/tray/trayicon.cpp index e22e9b26..42cb849a 100644 --- a/src/ui/form/tray/trayicon.cpp +++ b/src/ui/form/tray/trayicon.cpp @@ -479,7 +479,7 @@ void TrayIcon::setupTrayMenuFilterMode() const QStringList iconPaths = FirewallConf::filterModeIconPaths(); for (const QString &name : FirewallConf::filterModeNames()) { const QString iconPath = iconPaths.at(index); - const QString hotKey = HotKey::filterModeHotKeys[index]; + const QString hotKey = HotKey::filterModes[index]; QAction *a = addAction(m_filterModeMenu, iconPath, /*receiver=*/nullptr, /*member=*/nullptr, ActionNone, /*checkable=*/true); diff --git a/src/ui/user/iniuser.cpp b/src/ui/user/iniuser.cpp index eb8c75c9..721cc535 100644 --- a/src/ui/user/iniuser.cpp +++ b/src/ui/user/iniuser.cpp @@ -1,5 +1,17 @@ #include "iniuser.h" +namespace HotKey { + +const char *const filterModes[] = { + filterModeAutoLearn, + filterModeAskToConnect, + filterModeBlock, + filterModeAllow, + filterModeIgnore, +}; + +} + IniUser::IniUser(Settings *settings) : MapSettings(settings) { } void IniUser::saveDefaultIni() diff --git a/src/ui/user/iniuser.h b/src/ui/user/iniuser.h index 1b71fe37..53a294ad 100644 --- a/src/ui/user/iniuser.h +++ b/src/ui/user/iniuser.h @@ -18,13 +18,13 @@ const char *const blockInetTraffic = "blockInetTraffic"; const char *const appGroupModifier = "appGroupModifier"; const char *const quit = "quit"; -const char *const filterModeHotKeys[] = { - "filterModeAutoLearn", - "filterModeAskToConnect", - "filterModeBlock", - "filterModeAllow", - "filterModeIgnore", -}; +const char *const filterModeAutoLearn = "filterModeAutoLearn"; +const char *const filterModeAskToConnect = "filterModeAskToConnect"; +const char *const filterModeBlock = "filterModeBlock"; +const char *const filterModeAllow = "filterModeAllow"; +const char *const filterModeIgnore = "filterModeIgnore"; + +extern const char *const filterModes[]; namespace Default { const char *const filter = "Ctrl+Alt+Shift+F";