diff --git a/src/ui/FortFirewallUI.pro b/src/ui/FortFirewallUI.pro index 9a4421e6..d0d5c7f6 100644 --- a/src/ui/FortFirewallUI.pro +++ b/src/ui/FortFirewallUI.pro @@ -82,6 +82,7 @@ SOURCES += \ form/opt/pages/applicationspage.cpp \ form/opt/pages/apps/appscolumn.cpp \ form/opt/pages/graphpage.cpp \ + form/opt/pages/ifacepage.cpp \ form/opt/pages/optbasepage.cpp \ form/opt/pages/optionspage.cpp \ form/opt/pages/optmainpage.cpp \ @@ -306,6 +307,7 @@ HEADERS += \ form/opt/pages/applicationspage.h \ form/opt/pages/apps/appscolumn.h \ form/opt/pages/graphpage.h \ + form/opt/pages/ifacepage.h \ form/opt/pages/optbasepage.h \ form/opt/pages/optionspage.h \ form/opt/pages/optmainpage.h \ diff --git a/src/ui/form/opt/pages/ifacepage.cpp b/src/ui/form/opt/pages/ifacepage.cpp new file mode 100644 index 00000000..d61ca823 --- /dev/null +++ b/src/ui/form/opt/pages/ifacepage.cpp @@ -0,0 +1,545 @@ +#include "ifacepage.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include
+#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +constexpr int trayMaxGroups = 16; + +} + +IfacePage::IfacePage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent) +{ + setupUi(); +} + +void IfacePage::onResetToDefault() +{ + m_cbUseSystemLocale->setChecked(true); + m_comboTheme->setCurrentIndex(0); + m_cbHotKeysEnabled->setChecked(false); + m_cbHotKeysGlobal->setChecked(true); + + // Reset Shortcuts + for (int i = 0; i < HotKey::listCount; ++i) { + const auto &key = HotKey::list[i]; + iniUser()->setHotKeyValue(key, HotKey::defaultValue(key)); + } + refreshEditShortcut(); + + m_cbHomeAutoShowMenu->setChecked(false); + m_cbSplashVisible->setChecked(true); + m_cbTrayShowIcon->setChecked(true); + m_cbTrayAnimateAlert->setChecked(true); + + m_spinTrayMaxGroups->setValue(trayMaxGroups); + + // Reset Tray Actions + for (int i = 0; i < TrayIcon::ClickTypeCount; ++i) { + TrayIcon::resetClickEventActionType(iniUser(), TrayIcon::ClickType(i)); + } + refreshComboTrayAction(); + + m_cbConfirmTrayFlags->setChecked(false); + m_cbConfirmQuit->setChecked(true); +} + +void IfacePage::onAboutToSave() +{ + // Explorer + if (explorerEdited()) { + StartupUtil::setExplorerIntegrated(m_cbExplorerMenu->isChecked()); + } +} + +void IfacePage::onEditResetted() +{ + // Explorer + if (explorerEdited()) { + setExplorerEdited(false); + m_cbExplorerMenu->setChecked(StartupUtil::isExplorerIntegrated()); + } + + // Language + if (languageEdited()) { + setLanguageEdited(false); + translationManager()->switchLanguageByName(confManager()->iniUser().language()); + } + + // Theme + if (themeEdited()) { + setThemeEdited(false); + WindowManager::updateTheme(confManager()->iniUser()); + } +} + +void IfacePage::onRetranslateUi() +{ + m_gbGlobal->setTitle(tr("Global")); + m_gbHotKeys->setTitle(tr("Hot Keys")); + m_gbHome->setTitle(tr("My Fort")); + m_gbTray->setTitle(tr("Tray")); + m_gbConfirmations->setTitle(tr("Action Confirmations")); + + m_cbExplorerMenu->setText(tr("Windows Explorer integration")); + m_cbUseSystemLocale->setText(tr("Use System Regional Settings")); + m_labelLanguage->setText(tr("Language:")); + m_labelTheme->setText(tr("Theme:")); + retranslateComboTheme(); + + m_cbHotKeysEnabled->setText(tr("Enabled")); + m_cbHotKeysGlobal->setText(tr("Global")); + m_labelHotKey->setText(tr("Hot Key:")); + m_labelShortcut->setText(tr("Shortcut:")); + retranslateComboHotKey(); + refreshEditShortcut(); + + m_cbHomeAutoShowMenu->setText(tr("Auto-Show Menu")); + m_cbSplashVisible->setText(tr("Show Splash screen on startup")); + + m_cbTrayShowIcon->setText(tr("Show Icon")); + m_cbTrayAnimateAlert->setText(tr("Animate Alert Icon")); + m_labelTrayMaxGroups->setText(tr("Maximum count of Groups in menu:")); + m_labelTrayEvent->setText(tr("Event:")); + m_labelTrayAction->setText(tr("Action:")); + retranslateComboTrayEvent(); + retranslateComboTrayAction(); + refreshComboTrayAction(); + + m_cbConfirmTrayFlags->setText(tr("Tray Menu Flags")); + m_cbConfirmQuit->setText(tr("Quit")); +} + +void IfacePage::retranslateComboTheme() +{ + // Sync with Qt::ColorScheme + const QStringList list = { tr("System"), tr("Light"), tr("Dark") }; + + const int currentIndex = qMax(m_comboTheme->currentIndex(), 0); + + ControlUtil::setComboBoxTexts(m_comboTheme, list, currentIndex); +} + +void IfacePage::retranslateComboHotKey() +{ + // Sync with TrayIcon::retranslateUi() & HotKey::list[] + QStringList list = { TrayIcon::tr("My Fort"), TrayIcon::tr("Programs"), TrayIcon::tr("Options"), + TrayIcon::tr("Rules"), TrayIcon::tr("Zones"), TrayIcon::tr("Statistics"), + TrayIcon::tr("Traffic Graph"), TrayIcon::tr("Filter Enabled") }; + + const auto blockTraffic = tr("Block Traffic:"); + for (const auto &name : FirewallConf::blockTrafficNames()) { + list.append(blockTraffic + ' ' + name); + } + + const auto filterMode = tr("Filter Mode:"); + for (const auto &name : FirewallConf::filterModeNames()) { + list.append(filterMode + ' ' + name); + } + + list.append({ TrayIcon::tr("App Group Modifier"), TrayIcon::tr("Quit") }); + + const int currentIndex = qMax(m_comboHotKey->currentIndex(), 0); + + ControlUtil::setComboBoxTexts(m_comboHotKey, list, currentIndex); +} + +void IfacePage::retranslateComboTrayEvent() +{ + // Sync with TrayIcon::ClickType + const QStringList list = { tr("Single Click"), tr("Ctrl + Single Click"), + tr("Alt + Single Click"), tr("Double Click"), tr("Middle Click"), tr("Right Click") }; + + const int currentIndex = qMax(m_comboTrayEvent->currentIndex(), 0); + + ControlUtil::setComboBoxTexts(m_comboTrayEvent, list, currentIndex); +} + +void IfacePage::retranslateComboTrayAction() +{ + const TrayIcon::ActionType type = TrayIcon::ActionNone; // to find the enum usages + Q_UNUSED(type); + + // Sync with TrayIcon::ActionType + const QStringList list = { tr("Show My Fort"), tr("Show Programs"), + tr("Show Programs Or Alert Window"), tr("Show Options"), tr("Show Statistics"), + tr("Show/Hide Traffic Graph"), tr("Switch Filter Enabled"), tr("Show Block Traffic Menu"), + tr("Show Filter Mode Menu"), tr("Show Tray Menu"), tr("Ignore") }; + + ControlUtil::setComboBoxTexts(m_comboTrayAction, list, /*currentIndex=*/-1); +} + +void IfacePage::setupUi() +{ + // Column #1 + auto colLayout1 = setupColumn1(); + + // Column #2 + auto colLayout2 = setupColumn2(); + + // Main layout + auto layout = new QHBoxLayout(); + layout->addLayout(colLayout1); + layout->addStretch(); + layout->addLayout(colLayout2); + layout->addStretch(); + + this->setLayout(layout); +} + +QLayout *IfacePage::setupColumn1() +{ + // Global Group Box + setupGlobalBox(); + + // Hot Keys Group Box + setupHotKeysBox(); + + auto layout = new QVBoxLayout(); + layout->setSpacing(10); + layout->addWidget(m_gbGlobal); + layout->addWidget(m_gbHotKeys); + layout->addStretch(); + + return layout; +} + +QLayout *IfacePage::setupColumn2() +{ + // Home Group Box + setupHomeBox(); + + // Tray Group Box + setupTrayBox(); + + // Confirmations Group Box + setupConfirmationsBox(); + + auto layout = new QVBoxLayout(); + layout->setSpacing(10); + layout->addWidget(m_gbHome); + layout->addWidget(m_gbTray); + layout->addWidget(m_gbConfirmations); + layout->addStretch(); + + return layout; +} + +void IfacePage::setupGlobalBox() +{ + m_cbExplorerMenu = + ControlUtil::createCheckBox(StartupUtil::isExplorerIntegrated(), [&](bool /*checked*/) { + setExplorerEdited(true); + ctrl()->setIniUserEdited(); + }); + + m_cbUseSystemLocale = + ControlUtil::createCheckBox(iniUser()->useSystemLocale(), [&](bool checked) { + iniUser()->setUseSystemLocale(checked); + ctrl()->setIniUserEdited(true); + }); + + // Language Row + auto langLayout = setupLangLayout(); + + // Theme Row + auto themeLayout = setupThemeLayout(); + + auto layout = new QVBoxLayout(); + layout->addWidget(m_cbExplorerMenu); + layout->addWidget(m_cbUseSystemLocale); + layout->addLayout(langLayout); + layout->addLayout(themeLayout); + + m_gbGlobal = new QGroupBox(); + m_gbGlobal->setLayout(layout); +} + +QLayout *IfacePage::setupLangLayout() +{ + m_labelLanguage = ControlUtil::createLabel(); + + setupComboLanguage(); + + return ControlUtil::createRowLayout(m_labelLanguage, m_comboLanguage); +} + +void IfacePage::setupComboLanguage() +{ + m_comboLanguage = ControlUtil::createComboBox({}, [&](int index) { + if (translationManager()->switchLanguage(index)) { + setLanguageEdited(true); + iniUser()->setLanguage(translationManager()->languageName()); + ctrl()->setIniUserEdited(); + } + }); + m_comboLanguage->setFixedWidth(200); + + const auto refreshComboLanguage = [&] { + ControlUtil::setComboBoxTexts(m_comboLanguage, translationManager()->displayLabels(), + translationManager()->language()); + }; + + refreshComboLanguage(); + + connect(translationManager(), &TranslationManager::languageChanged, this, refreshComboLanguage); +} + +QLayout *IfacePage::setupThemeLayout() +{ + m_labelTheme = ControlUtil::createLabel(); + + m_comboTheme = ControlUtil::createComboBox({}, [&](int index) { + const auto theme = IniUser::colorSchemeName(index); + + if (iniUser()->theme() != theme) { + setThemeEdited(true); + iniUser()->setTheme(theme); + ctrl()->setIniUserEdited(); + + WindowManager::updateTheme(*iniUser()); + } + }); + m_comboTheme->setFixedWidth(200); + + const auto colorScheme = IniUser::colorSchemeByName(iniUser()->theme()); + m_comboTheme->setCurrentIndex(colorScheme); + +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) + m_comboTheme->setEnabled(false); +#endif + + return ControlUtil::createRowLayout(m_labelTheme, m_comboTheme); +} + +void IfacePage::setupHotKeysBox() +{ + m_cbHotKeysEnabled = ControlUtil::createCheckBox(iniUser()->hotKeyEnabled(), [&](bool checked) { + iniUser()->setHotKeyEnabled(checked); + ctrl()->setIniUserEdited(true); + }); + + m_cbHotKeysGlobal = ControlUtil::createCheckBox(iniUser()->hotKeyGlobal(), [&](bool checked) { + iniUser()->setHotKeyGlobal(checked); + ctrl()->setIniUserEdited(true); + }); + + // Hot Keys Combo & Edit Rows + auto comboLayout = setupComboHotKeyLayout(); + auto editLayout = setupEditShortcutLayout(); + + auto layout = new QVBoxLayout(); + layout->addWidget(m_cbHotKeysEnabled); + layout->addWidget(m_cbHotKeysGlobal); + layout->addWidget(ControlUtil::createSeparator()); + layout->addLayout(comboLayout); + layout->addLayout(editLayout); + + m_gbHotKeys = new QGroupBox(); + m_gbHotKeys->setLayout(layout); +} + +void IfacePage::refreshEditShortcut() +{ + const auto &key = HotKey::list[m_comboHotKey->currentIndex()]; + + m_editShortcut->setKeySequence(iniUser()->hotKeyValue(key)); +} + +QLayout *IfacePage::setupComboHotKeyLayout() +{ + m_labelHotKey = ControlUtil::createLabel(); + + m_comboHotKey = ControlUtil::createComboBox( + QStringList(), [&](int /*index*/) { refreshEditShortcut(); }); + m_comboHotKey->setFixedWidth(200); + + return ControlUtil::createRowLayout(m_labelHotKey, m_comboHotKey); +} + +QLayout *IfacePage::setupEditShortcutLayout() +{ + m_labelShortcut = ControlUtil::createLabel(); + + m_editShortcut = new QKeySequenceEdit(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + m_editShortcut->setClearButtonEnabled(true); +#endif + m_editShortcut->setFixedWidth(200); + + const auto onEditShortcut = [&](const QKeySequence &shortcut) { + const auto &key = HotKey::list[m_comboHotKey->currentIndex()]; + const auto value = shortcut.toString(); + + if (value == iniUser()->hotKeyValue(key)) + return; + + iniUser()->setHotKeyValue(key, value); + ctrl()->setIniUserEdited(); + }; + + connect(m_editShortcut, &QKeySequenceEdit::editingFinished, + [=, this] { onEditShortcut(m_editShortcut->keySequence()); }); + + connect(m_editShortcut, &QKeySequenceEdit::keySequenceChanged, + [=, this](const QKeySequence &shortcut) { + if (shortcut.isEmpty()) { + onEditShortcut({}); + } + }); + + return ControlUtil::createRowLayout(m_labelShortcut, m_editShortcut); +} + +void IfacePage::setupHomeBox() +{ + m_cbHomeAutoShowMenu = + ControlUtil::createCheckBox(iniUser()->homeWindowAutoShowMenu(), [&](bool checked) { + iniUser()->setHomeWindowAutoShowMenu(checked); + ctrl()->setIniUserEdited(); + }); + + m_cbSplashVisible = + ControlUtil::createCheckBox(iniUser()->splashWindowVisible(), [&](bool checked) { + iniUser()->setSplashWindowVisible(checked); + ctrl()->setIniUserEdited(); + }); + + auto layout = new QVBoxLayout(); + layout->addWidget(m_cbHomeAutoShowMenu); + layout->addWidget(m_cbSplashVisible); + + m_gbHome = new QGroupBox(); + m_gbHome->setLayout(layout); +} + +void IfacePage::setupTrayBox() +{ + m_cbTrayShowIcon = ControlUtil::createCheckBox(iniUser()->trayShowIcon(), [&](bool checked) { + iniUser()->setTrayShowIcon(checked); + ctrl()->setIniUserEdited(true); + }); + + m_cbTrayAnimateAlert = + ControlUtil::createCheckBox(iniUser()->trayAnimateAlert(), [&](bool checked) { + iniUser()->setTrayAnimateAlert(checked); + ctrl()->setIniUserEdited(); + }); + + // Tray Max. Groups Row + auto maxGroupsLayout = setupTrayMaxGroupsLayout(); + + // Tray Event & Action Rows + auto eventLayout = setupTrayEventLayout(); + auto actionLayout = setupTrayActionLayout(); + + auto layout = new QVBoxLayout(); + layout->addWidget(m_cbTrayShowIcon); + layout->addWidget(m_cbTrayAnimateAlert); + layout->addLayout(maxGroupsLayout); + layout->addWidget(ControlUtil::createSeparator()); + layout->addLayout(eventLayout); + layout->addLayout(actionLayout); + + m_gbTray = new QGroupBox(); + m_gbTray->setLayout(layout); +} + +QLayout *IfacePage::setupTrayMaxGroupsLayout() +{ + m_labelTrayMaxGroups = ControlUtil::createLabel(); + + m_spinTrayMaxGroups = ControlUtil::createSpinBox(); + m_spinTrayMaxGroups->setFixedWidth(50); + + m_spinTrayMaxGroups->setRange(0, trayMaxGroups); + m_spinTrayMaxGroups->setValue(iniUser()->trayMaxGroups(trayMaxGroups)); + + connect(m_spinTrayMaxGroups, QOverload::of(&QSpinBox::valueChanged), [&](int v) { + iniUser()->setTrayMaxGroups(v); + ctrl()->setIniUserEdited(); + }); + + return ControlUtil::createRowLayout(m_labelTrayMaxGroups, m_spinTrayMaxGroups); +} + +void IfacePage::refreshComboTrayAction() +{ + const TrayIcon::ClickType clickType = + static_cast(m_comboTrayEvent->currentIndex()); + + const TrayIcon::ActionType actionType = TrayIcon::clickEventActionType(iniUser(), clickType); + + m_comboTrayAction->setCurrentIndex(actionType); +} + +QLayout *IfacePage::setupTrayEventLayout() +{ + m_labelTrayEvent = ControlUtil::createLabel(); + + m_comboTrayEvent = ControlUtil::createComboBox( + QStringList(), [&](int /*index*/) { refreshComboTrayAction(); }); + m_comboTrayEvent->setFixedWidth(200); + + return ControlUtil::createRowLayout(m_labelTrayEvent, m_comboTrayEvent); +} + +QLayout *IfacePage::setupTrayActionLayout() +{ + m_labelTrayAction = ControlUtil::createLabel(); + + m_comboTrayAction = ControlUtil::createComboBox(QStringList(), [&](int index) { + const TrayIcon::ClickType clickType = + static_cast(m_comboTrayEvent->currentIndex()); + const TrayIcon::ActionType actionType = static_cast(index); + + TrayIcon::setClickEventActionType(iniUser(), clickType, actionType); + ctrl()->setIniUserEdited(true); + }); + m_comboTrayAction->setFixedWidth(200); + + return ControlUtil::createRowLayout(m_labelTrayAction, m_comboTrayAction); +} + +void IfacePage::setupConfirmationsBox() +{ + m_cbConfirmTrayFlags = + ControlUtil::createCheckBox(iniUser()->confirmTrayFlags(), [&](bool checked) { + iniUser()->setConfirmTrayFlags(checked); + ctrl()->setIniUserEdited(); + }); + m_cbConfirmQuit = ControlUtil::createCheckBox(iniUser()->confirmQuit(), [&](bool checked) { + iniUser()->setConfirmQuit(checked); + ctrl()->setIniUserEdited(); + }); + + auto layout = new QVBoxLayout(); + layout->addWidget(m_cbConfirmTrayFlags); + layout->addWidget(m_cbConfirmQuit); + + m_gbConfirmations = new QGroupBox(); + m_gbConfirmations->setLayout(layout); +} diff --git a/src/ui/form/opt/pages/ifacepage.h b/src/ui/form/opt/pages/ifacepage.h new file mode 100644 index 00000000..406b06f6 --- /dev/null +++ b/src/ui/form/opt/pages/ifacepage.h @@ -0,0 +1,98 @@ +#ifndef IFACEPAGE_H +#define IFACEPAGE_H + +#include "optbasepage.h" + +QT_FORWARD_DECLARE_CLASS(QKeySequenceEdit) + +class IfacePage : public OptBasePage +{ + Q_OBJECT + +public: + explicit IfacePage(OptionsController *ctrl = nullptr, QWidget *parent = nullptr); + + bool explorerEdited() const { return m_explorerEdited; } + void setExplorerEdited(bool v) { m_explorerEdited = v; } + + bool languageEdited() const { return m_languageEdited; } + void setLanguageEdited(bool v) { m_languageEdited = v; } + + bool themeEdited() const { return m_themeEdited; } + void setThemeEdited(bool v) { m_themeEdited = v; } + +public slots: + void onResetToDefault() override; + +protected slots: + void onAboutToSave() override; + void onEditResetted() override; + + void onRetranslateUi() override; + +private: + void retranslateComboTheme(); + void retranslateComboHotKey(); + void retranslateComboTrayEvent(); + void retranslateComboTrayAction(); + + void setupUi(); + QLayout *setupColumn1(); + QLayout *setupColumn2(); + + void setupGlobalBox(); + QLayout *setupLangLayout(); + void setupComboLanguage(); + QLayout *setupThemeLayout(); + void setupHotKeysBox(); + void refreshEditShortcut(); + QLayout *setupComboHotKeyLayout(); + QLayout *setupEditShortcutLayout(); + void setupHomeBox(); + void setupTrayBox(); + QLayout *setupTrayMaxGroupsLayout(); + void refreshComboTrayAction(); + QLayout *setupTrayEventLayout(); + QLayout *setupTrayActionLayout(); + void setupConfirmationsBox(); + +private: + bool m_explorerEdited : 1 = false; + bool m_languageEdited : 1 = false; + bool m_themeEdited : 1 = false; + + QGroupBox *m_gbGlobal = nullptr; + QGroupBox *m_gbHotKeys = nullptr; + QGroupBox *m_gbHome = nullptr; + QGroupBox *m_gbTray = nullptr; + QGroupBox *m_gbConfirmations = nullptr; + + QCheckBox *m_cbExplorerMenu = nullptr; + QCheckBox *m_cbUseSystemLocale = nullptr; + QLabel *m_labelLanguage = nullptr; + QComboBox *m_comboLanguage = nullptr; + QLabel *m_labelTheme = nullptr; + QComboBox *m_comboTheme = nullptr; + QCheckBox *m_cbHotKeysEnabled = nullptr; + QCheckBox *m_cbHotKeysGlobal = nullptr; + QLabel *m_labelHotKey = nullptr; + QComboBox *m_comboHotKey = nullptr; + QLabel *m_labelShortcut = nullptr; + QKeySequenceEdit *m_editShortcut = nullptr; + + QCheckBox *m_cbHomeAutoShowMenu = nullptr; + QCheckBox *m_cbSplashVisible = nullptr; + QCheckBox *m_cbTrayShowIcon = nullptr; + QCheckBox *m_cbTrayAnimateAlert = nullptr; + QLabel *m_labelTrayMaxGroups = nullptr; + QSpinBox *m_spinTrayMaxGroups = nullptr; + + QLabel *m_labelTrayEvent = nullptr; + QComboBox *m_comboTrayEvent = nullptr; + QLabel *m_labelTrayAction = nullptr; + QComboBox *m_comboTrayAction = nullptr; + QCheckBox *m_cbConfirmTrayFlags = nullptr; + QCheckBox *m_cbConfirmQuit = nullptr; +}; + +#endif // IFACEPAGE_H diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index 881afa05..d8ec1f87 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -2,13 +2,10 @@ #include #include -#include #include #include -#include #include #include -#include #include #include #include @@ -19,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -27,13 +23,10 @@ #include #include #include -#include #include namespace { -constexpr int trayMaxGroups = 16; - struct Startup { quint8 initialized : 1 = false; @@ -77,34 +70,6 @@ void OptionsPage::onResetToDefault() m_cbAppAlertAlwaysOnTop->setChecked(false); m_cbPurgeOnMounted->setChecked(false); - m_cbUseSystemLocale->setChecked(true); - m_comboTheme->setCurrentIndex(0); - m_cbHotKeysEnabled->setChecked(false); - m_cbHotKeysGlobal->setChecked(true); - - // Reset Shortcuts - for (int i = 0; i < HotKey::listCount; ++i) { - const auto &key = HotKey::list[i]; - iniUser()->setHotKeyValue(key, HotKey::defaultValue(key)); - } - refreshEditShortcut(); - - m_cbHomeAutoShowMenu->setChecked(false); - m_cbSplashVisible->setChecked(true); - m_cbTrayShowIcon->setChecked(true); - m_cbTrayAnimateAlert->setChecked(true); - - m_spinTrayMaxGroups->setValue(trayMaxGroups); - - // Reset Tray Actions - for (int i = 0; i < TrayIcon::ClickTypeCount; ++i) { - TrayIcon::resetClickEventActionType(iniUser(), TrayIcon::ClickType(i)); - } - refreshComboTrayAction(); - - m_cbConfirmTrayFlags->setChecked(false); - m_cbConfirmQuit->setChecked(true); - m_cbLogDebug->setChecked(false); m_cbLogConsole->setChecked(false); } @@ -128,11 +93,6 @@ void OptionsPage::onAboutToSave() } else if (conf()->iniEdited()) { ini()->setHasPassword(settings()->hasPassword()); } - - // Explorer - if (explorerEdited()) { - StartupUtil::setExplorerIntegrated(m_cbExplorerMenu->isChecked()); - } } void OptionsPage::onEditResetted() @@ -140,24 +100,6 @@ void OptionsPage::onEditResetted() // Password setPasswordEdited(false); retranslateEditPassword(); - - // Language - if (languageEdited()) { - setLanguageEdited(false); - translationManager()->switchLanguageByName(confManager()->iniUser().language()); - } - - // Theme - if (themeEdited()) { - setThemeEdited(false); - WindowManager::updateTheme(confManager()->iniUser()); - } - - // Explorer - if (explorerEdited()) { - setExplorerEdited(false); - m_cbExplorerMenu->setChecked(StartupUtil::isExplorerIntegrated()); - } } void OptionsPage::saveAutoRunMode(int mode) @@ -197,11 +139,6 @@ void OptionsPage::onRetranslateUi() m_gbTraffic->setTitle(tr("Traffic")); m_gbProtection->setTitle(tr("Self Protection")); m_gbProg->setTitle(tr("Programs")); - m_gbGlobal->setTitle(tr("Global")); - m_gbHotKeys->setTitle(tr("Hot Keys")); - m_gbHome->setTitle(tr("My Fort")); - m_gbTray->setTitle(tr("Tray")); - m_gbConfirmations->setTitle(tr("Action Confirmations")); m_gbLogs->setTitle(tr("Logs")); m_labelStartMode->setText(tr("Auto-run:")); @@ -237,34 +174,6 @@ void OptionsPage::onRetranslateUi() m_cbAppAlertAlwaysOnTop->setText(tr("Alert Window is Always on top")); m_cbPurgeOnMounted->setText(tr("Purge Obsolete only on mounted drives")); - m_cbExplorerMenu->setText(tr("Windows Explorer integration")); - m_cbUseSystemLocale->setText(tr("Use System Regional Settings")); - m_labelLanguage->setText(tr("Language:")); - m_labelTheme->setText(tr("Theme:")); - retranslateComboTheme(); - - m_cbHotKeysEnabled->setText(tr("Enabled")); - m_cbHotKeysGlobal->setText(tr("Global")); - m_labelHotKey->setText(tr("Hot Key:")); - m_labelShortcut->setText(tr("Shortcut:")); - retranslateComboHotKey(); - refreshEditShortcut(); - - m_cbHomeAutoShowMenu->setText(tr("Auto-Show Menu")); - m_cbSplashVisible->setText(tr("Show Splash screen on startup")); - - m_cbTrayShowIcon->setText(tr("Show Icon")); - m_cbTrayAnimateAlert->setText(tr("Animate Alert Icon")); - m_labelTrayMaxGroups->setText(tr("Maximum count of Groups in menu:")); - m_labelTrayEvent->setText(tr("Event:")); - m_labelTrayAction->setText(tr("Action:")); - retranslateComboTrayEvent(); - retranslateComboTrayAction(); - refreshComboTrayAction(); - - m_cbConfirmTrayFlags->setText(tr("Tray Menu Flags")); - m_cbConfirmQuit->setText(tr("Quit")); - m_cbLogDebug->setText(tr("Log debug messages")); m_cbLogConsole->setText(tr("Show log messages in console")); } @@ -322,65 +231,6 @@ void OptionsPage::retranslateEditPassword() settings()->hasPassword() ? tr("Installed") : tr("Not Installed")); } -void OptionsPage::retranslateComboTheme() -{ - // Sync with Qt::ColorScheme - const QStringList list = { tr("System"), tr("Light"), tr("Dark") }; - - const int currentIndex = qMax(m_comboTheme->currentIndex(), 0); - - ControlUtil::setComboBoxTexts(m_comboTheme, list, currentIndex); -} - -void OptionsPage::retranslateComboHotKey() -{ - // Sync with TrayIcon::retranslateUi() & HotKey::list[] - QStringList list = { TrayIcon::tr("My Fort"), TrayIcon::tr("Programs"), TrayIcon::tr("Options"), - TrayIcon::tr("Rules"), TrayIcon::tr("Zones"), TrayIcon::tr("Statistics"), - TrayIcon::tr("Traffic Graph"), TrayIcon::tr("Filter Enabled") }; - - const auto blockTraffic = tr("Block Traffic:"); - for (const auto &name : FirewallConf::blockTrafficNames()) { - list.append(blockTraffic + ' ' + name); - } - - const auto filterMode = tr("Filter Mode:"); - for (const auto &name : FirewallConf::filterModeNames()) { - list.append(filterMode + ' ' + name); - } - - list.append({ TrayIcon::tr("App Group Modifier"), TrayIcon::tr("Quit") }); - - const int currentIndex = qMax(m_comboHotKey->currentIndex(), 0); - - ControlUtil::setComboBoxTexts(m_comboHotKey, list, currentIndex); -} - -void OptionsPage::retranslateComboTrayEvent() -{ - // Sync with TrayIcon::ClickType - const QStringList list = { tr("Single Click"), tr("Ctrl + Single Click"), - tr("Alt + Single Click"), tr("Double Click"), tr("Middle Click"), tr("Right Click") }; - - const int currentIndex = qMax(m_comboTrayEvent->currentIndex(), 0); - - ControlUtil::setComboBoxTexts(m_comboTrayEvent, list, currentIndex); -} - -void OptionsPage::retranslateComboTrayAction() -{ - const TrayIcon::ActionType type = TrayIcon::ActionNone; // to find the enum usages - Q_UNUSED(type); - - // Sync with TrayIcon::ActionType - const QStringList list = { tr("Show My Fort"), tr("Show Programs"), - tr("Show Programs Or Alert Window"), tr("Show Options"), tr("Show Statistics"), - tr("Show/Hide Traffic Graph"), tr("Switch Filter Enabled"), tr("Show Block Traffic Menu"), - tr("Show Filter Mode Menu"), tr("Show Tray Menu"), tr("Ignore") }; - - ControlUtil::setComboBoxTexts(m_comboTrayAction, list, /*currentIndex=*/-1); -} - void OptionsPage::setupStartup() { m_currentAutoRunMode = StartupUtil::autoRunMode(); @@ -412,25 +262,37 @@ void OptionsPage::setupUi() QLayout *OptionsPage::setupColumn1() { - auto layout = new QVBoxLayout(); - layout->setSpacing(10); - // Startup Group Box setupStartupBox(); - layout->addWidget(m_gbStartup); // Traffic Group Box setupTrafficBox(); - layout->addWidget(m_gbTraffic); // Protection Group Box setupProtectionBox(); - layout->addWidget(m_gbProtection); + auto layout = new QVBoxLayout(); + layout->setSpacing(10); + layout->addWidget(m_gbStartup); + layout->addWidget(m_gbTraffic); + layout->addWidget(m_gbProtection); + layout->addStretch(); + + return layout; +} + +QLayout *OptionsPage::setupColumn2() +{ // Programs Group Box setupProgBox(); - layout->addWidget(m_gbProg); + // Logs Group Box + setupLogsBox(); + + auto layout = new QVBoxLayout(); + layout->setSpacing(10); + layout->addWidget(m_gbProg); + layout->addWidget(m_gbLogs); layout->addStretch(); return layout; @@ -672,336 +534,6 @@ void OptionsPage::setupLogBlocked() m_cbLogBlocked->setFont(GuiUtil::fontBold()); } -QLayout *OptionsPage::setupColumn2() -{ - auto layout = new QVBoxLayout(); - layout->setSpacing(10); - - // Global Group Box - setupGlobalBox(); - layout->addWidget(m_gbGlobal); - - // Hot Keys Group Box - setupHotKeysBox(); - layout->addWidget(m_gbHotKeys); - - // Home Group Box - setupHomeBox(); - layout->addWidget(m_gbHome); - - // Tray Group Box - setupTrayBox(); - layout->addWidget(m_gbTray); - - // Confirmations Group Box - setupConfirmationsBox(); - layout->addWidget(m_gbConfirmations); - - // Logs Group Box - setupLogsBox(); - layout->addWidget(m_gbLogs); - - layout->addStretch(); - - return layout; -} - -void OptionsPage::setupGlobalBox() -{ - m_cbExplorerMenu = - ControlUtil::createCheckBox(StartupUtil::isExplorerIntegrated(), [&](bool /*checked*/) { - setExplorerEdited(true); - ctrl()->setIniUserEdited(); - }); - - m_cbUseSystemLocale = - ControlUtil::createCheckBox(iniUser()->useSystemLocale(), [&](bool checked) { - iniUser()->setUseSystemLocale(checked); - ctrl()->setIniUserEdited(true); - }); - - // Language Row - auto langLayout = setupLangLayout(); - - // Theme Row - auto themeLayout = setupThemeLayout(); - - auto layout = new QVBoxLayout(); - layout->addWidget(m_cbExplorerMenu); - layout->addWidget(m_cbUseSystemLocale); - layout->addLayout(langLayout); - layout->addLayout(themeLayout); - - m_gbGlobal = new QGroupBox(); - m_gbGlobal->setLayout(layout); -} - -QLayout *OptionsPage::setupLangLayout() -{ - m_labelLanguage = ControlUtil::createLabel(); - - setupComboLanguage(); - - return ControlUtil::createRowLayout(m_labelLanguage, m_comboLanguage); -} - -void OptionsPage::setupComboLanguage() -{ - m_comboLanguage = ControlUtil::createComboBox({}, [&](int index) { - if (translationManager()->switchLanguage(index)) { - setLanguageEdited(true); - iniUser()->setLanguage(translationManager()->languageName()); - ctrl()->setIniUserEdited(); - } - }); - m_comboLanguage->setFixedWidth(200); - - const auto refreshComboLanguage = [&] { - ControlUtil::setComboBoxTexts(m_comboLanguage, translationManager()->displayLabels(), - translationManager()->language()); - }; - - refreshComboLanguage(); - - connect(translationManager(), &TranslationManager::languageChanged, this, refreshComboLanguage); -} - -QLayout *OptionsPage::setupThemeLayout() -{ - m_labelTheme = ControlUtil::createLabel(); - - m_comboTheme = ControlUtil::createComboBox({}, [&](int index) { - const auto theme = IniUser::colorSchemeName(index); - - if (iniUser()->theme() != theme) { - setThemeEdited(true); - iniUser()->setTheme(theme); - ctrl()->setIniUserEdited(); - - WindowManager::updateTheme(*iniUser()); - } - }); - m_comboTheme->setFixedWidth(200); - - const auto colorScheme = IniUser::colorSchemeByName(iniUser()->theme()); - m_comboTheme->setCurrentIndex(colorScheme); - -#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) - m_comboTheme->setEnabled(false); -#endif - - return ControlUtil::createRowLayout(m_labelTheme, m_comboTheme); -} - -void OptionsPage::setupHotKeysBox() -{ - m_cbHotKeysEnabled = ControlUtil::createCheckBox(iniUser()->hotKeyEnabled(), [&](bool checked) { - iniUser()->setHotKeyEnabled(checked); - ctrl()->setIniUserEdited(true); - }); - - m_cbHotKeysGlobal = ControlUtil::createCheckBox(iniUser()->hotKeyGlobal(), [&](bool checked) { - iniUser()->setHotKeyGlobal(checked); - ctrl()->setIniUserEdited(true); - }); - - // Hot Keys Combo & Edit Rows - auto comboLayout = setupComboHotKeyLayout(); - auto editLayout = setupEditShortcutLayout(); - - auto layout = new QVBoxLayout(); - layout->addWidget(m_cbHotKeysEnabled); - layout->addWidget(m_cbHotKeysGlobal); - layout->addWidget(ControlUtil::createSeparator()); - layout->addLayout(comboLayout); - layout->addLayout(editLayout); - - m_gbHotKeys = new QGroupBox(); - m_gbHotKeys->setLayout(layout); -} - -void OptionsPage::refreshEditShortcut() -{ - const auto &key = HotKey::list[m_comboHotKey->currentIndex()]; - - m_editShortcut->setKeySequence(iniUser()->hotKeyValue(key)); -} - -QLayout *OptionsPage::setupComboHotKeyLayout() -{ - m_labelHotKey = ControlUtil::createLabel(); - - m_comboHotKey = ControlUtil::createComboBox( - QStringList(), [&](int /*index*/) { refreshEditShortcut(); }); - m_comboHotKey->setFixedWidth(200); - - return ControlUtil::createRowLayout(m_labelHotKey, m_comboHotKey); -} - -QLayout *OptionsPage::setupEditShortcutLayout() -{ - m_labelShortcut = ControlUtil::createLabel(); - - m_editShortcut = new QKeySequenceEdit(); -#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) - m_editShortcut->setClearButtonEnabled(true); -#endif - m_editShortcut->setFixedWidth(200); - - const auto onEditShortcut = [&](const QKeySequence &shortcut) { - const auto &key = HotKey::list[m_comboHotKey->currentIndex()]; - const auto value = shortcut.toString(); - - if (value == iniUser()->hotKeyValue(key)) - return; - - iniUser()->setHotKeyValue(key, value); - ctrl()->setIniUserEdited(); - }; - - connect(m_editShortcut, &QKeySequenceEdit::editingFinished, - [=, this] { onEditShortcut(m_editShortcut->keySequence()); }); - - connect(m_editShortcut, &QKeySequenceEdit::keySequenceChanged, - [=, this](const QKeySequence &shortcut) { - if (shortcut.isEmpty()) { - onEditShortcut({}); - } - }); - - return ControlUtil::createRowLayout(m_labelShortcut, m_editShortcut); -} - -void OptionsPage::setupHomeBox() -{ - m_cbHomeAutoShowMenu = - ControlUtil::createCheckBox(iniUser()->homeWindowAutoShowMenu(), [&](bool checked) { - iniUser()->setHomeWindowAutoShowMenu(checked); - ctrl()->setIniUserEdited(); - }); - - m_cbSplashVisible = - ControlUtil::createCheckBox(iniUser()->splashWindowVisible(), [&](bool checked) { - iniUser()->setSplashWindowVisible(checked); - ctrl()->setIniUserEdited(); - }); - - auto layout = new QVBoxLayout(); - layout->addWidget(m_cbHomeAutoShowMenu); - layout->addWidget(m_cbSplashVisible); - - m_gbHome = new QGroupBox(); - m_gbHome->setLayout(layout); -} - -void OptionsPage::setupTrayBox() -{ - m_cbTrayShowIcon = ControlUtil::createCheckBox(iniUser()->trayShowIcon(), [&](bool checked) { - iniUser()->setTrayShowIcon(checked); - ctrl()->setIniUserEdited(true); - }); - - m_cbTrayAnimateAlert = - ControlUtil::createCheckBox(iniUser()->trayAnimateAlert(), [&](bool checked) { - iniUser()->setTrayAnimateAlert(checked); - ctrl()->setIniUserEdited(); - }); - - // Tray Max. Groups Row - auto maxGroupsLayout = setupTrayMaxGroupsLayout(); - - // Tray Event & Action Rows - auto eventLayout = setupTrayEventLayout(); - auto actionLayout = setupTrayActionLayout(); - - auto layout = new QVBoxLayout(); - layout->addWidget(m_cbTrayShowIcon); - layout->addWidget(m_cbTrayAnimateAlert); - layout->addLayout(maxGroupsLayout); - layout->addWidget(ControlUtil::createSeparator()); - layout->addLayout(eventLayout); - layout->addLayout(actionLayout); - - m_gbTray = new QGroupBox(); - m_gbTray->setLayout(layout); -} - -QLayout *OptionsPage::setupTrayMaxGroupsLayout() -{ - m_labelTrayMaxGroups = ControlUtil::createLabel(); - - m_spinTrayMaxGroups = ControlUtil::createSpinBox(); - m_spinTrayMaxGroups->setFixedWidth(50); - - m_spinTrayMaxGroups->setRange(0, trayMaxGroups); - m_spinTrayMaxGroups->setValue(iniUser()->trayMaxGroups(trayMaxGroups)); - - connect(m_spinTrayMaxGroups, QOverload::of(&QSpinBox::valueChanged), [&](int v) { - iniUser()->setTrayMaxGroups(v); - ctrl()->setIniUserEdited(); - }); - - return ControlUtil::createRowLayout(m_labelTrayMaxGroups, m_spinTrayMaxGroups); -} - -void OptionsPage::refreshComboTrayAction() -{ - const TrayIcon::ClickType clickType = - static_cast(m_comboTrayEvent->currentIndex()); - - const TrayIcon::ActionType actionType = TrayIcon::clickEventActionType(iniUser(), clickType); - - m_comboTrayAction->setCurrentIndex(actionType); -} - -QLayout *OptionsPage::setupTrayEventLayout() -{ - m_labelTrayEvent = ControlUtil::createLabel(); - - m_comboTrayEvent = ControlUtil::createComboBox( - QStringList(), [&](int /*index*/) { refreshComboTrayAction(); }); - m_comboTrayEvent->setFixedWidth(200); - - return ControlUtil::createRowLayout(m_labelTrayEvent, m_comboTrayEvent); -} - -QLayout *OptionsPage::setupTrayActionLayout() -{ - m_labelTrayAction = ControlUtil::createLabel(); - - m_comboTrayAction = ControlUtil::createComboBox(QStringList(), [&](int index) { - const TrayIcon::ClickType clickType = - static_cast(m_comboTrayEvent->currentIndex()); - const TrayIcon::ActionType actionType = static_cast(index); - - TrayIcon::setClickEventActionType(iniUser(), clickType, actionType); - ctrl()->setIniUserEdited(true); - }); - m_comboTrayAction->setFixedWidth(200); - - return ControlUtil::createRowLayout(m_labelTrayAction, m_comboTrayAction); -} - -void OptionsPage::setupConfirmationsBox() -{ - m_cbConfirmTrayFlags = - ControlUtil::createCheckBox(iniUser()->confirmTrayFlags(), [&](bool checked) { - iniUser()->setConfirmTrayFlags(checked); - ctrl()->setIniUserEdited(); - }); - m_cbConfirmQuit = ControlUtil::createCheckBox(iniUser()->confirmQuit(), [&](bool checked) { - iniUser()->setConfirmQuit(checked); - ctrl()->setIniUserEdited(); - }); - - auto layout = new QVBoxLayout(); - layout->addWidget(m_cbConfirmTrayFlags); - layout->addWidget(m_cbConfirmQuit); - - m_gbConfirmations = new QGroupBox(); - m_gbConfirmations->setLayout(layout); -} - void OptionsPage::setupLogsBox() { m_cbLogDebug = ControlUtil::createCheckBox(ini()->logDebug(), [&](bool checked) { diff --git a/src/ui/form/opt/pages/optionspage.h b/src/ui/form/opt/pages/optionspage.h index 9498d2d3..c3f2ee69 100644 --- a/src/ui/form/opt/pages/optionspage.h +++ b/src/ui/form/opt/pages/optionspage.h @@ -3,8 +3,6 @@ #include "optbasepage.h" -QT_FORWARD_DECLARE_CLASS(QKeySequenceEdit) - class OptionsPage : public OptBasePage { Q_OBJECT @@ -15,15 +13,6 @@ public: bool passwordEdited() const { return m_passwordEdited; } void setPasswordEdited(bool v) { m_passwordEdited = v; } - bool languageEdited() const { return m_languageEdited; } - void setLanguageEdited(bool v) { m_languageEdited = v; } - - bool themeEdited() const { return m_themeEdited; } - void setThemeEdited(bool v) { m_themeEdited = v; } - - bool explorerEdited() const { return m_explorerEdited; } - void setExplorerEdited(bool v) { m_explorerEdited = v; } - public slots: void onResetToDefault() override; @@ -41,15 +30,13 @@ private: void retranslateComboBlockTraffic(); void retranslateComboFilterMode(); void retranslateEditPassword(); - void retranslateComboTheme(); - void retranslateComboHotKey(); - void retranslateComboTrayEvent(); - void retranslateComboTrayAction(); void setupStartup(); void setupUi(); QLayout *setupColumn1(); + QLayout *setupColumn2(); + void setupStartupBox(); QLayout *setupStartModeLayout(); void setupTrafficBox(); @@ -61,30 +48,10 @@ private: void setupPasswordLock(); void setupProgBox(); void setupLogBlocked(); - - QLayout *setupColumn2(); - void setupGlobalBox(); - QLayout *setupLangLayout(); - void setupComboLanguage(); - QLayout *setupThemeLayout(); - void setupHotKeysBox(); - void refreshEditShortcut(); - QLayout *setupComboHotKeyLayout(); - QLayout *setupEditShortcutLayout(); - void setupHomeBox(); - void setupTrayBox(); - QLayout *setupTrayMaxGroupsLayout(); - void refreshComboTrayAction(); - QLayout *setupTrayEventLayout(); - QLayout *setupTrayActionLayout(); - void setupConfirmationsBox(); void setupLogsBox(); private: bool m_passwordEdited : 1 = false; - bool m_languageEdited : 1 = false; - bool m_themeEdited : 1 = false; - bool m_explorerEdited : 1 = false; qint8 m_currentAutoRunMode = 0; @@ -92,11 +59,6 @@ private: QGroupBox *m_gbTraffic = nullptr; QGroupBox *m_gbProtection = nullptr; QGroupBox *m_gbProg = nullptr; - QGroupBox *m_gbGlobal = nullptr; - QGroupBox *m_gbHotKeys = nullptr; - QGroupBox *m_gbHome = nullptr; - QGroupBox *m_gbTray = nullptr; - QGroupBox *m_gbConfirmations = nullptr; QGroupBox *m_gbLogs = nullptr; QLabel *m_labelStartMode = nullptr; @@ -114,38 +76,13 @@ private: QCheckBox *m_cbPassword = nullptr; QLineEdit *m_editPassword = nullptr; QToolButton *m_btPasswordLock = nullptr; + QCheckBox *m_cbLogBlocked = nullptr; QCheckBox *m_cbAppNotifyMessage = nullptr; QCheckBox *m_cbAppAlertAutoShow = nullptr; QCheckBox *m_cbAppAlertAlwaysOnTop = nullptr; QCheckBox *m_cbPurgeOnMounted = nullptr; - QCheckBox *m_cbExplorerMenu = nullptr; - QCheckBox *m_cbUseSystemLocale = nullptr; - QLabel *m_labelLanguage = nullptr; - QComboBox *m_comboLanguage = nullptr; - QLabel *m_labelTheme = nullptr; - QComboBox *m_comboTheme = nullptr; - QCheckBox *m_cbHotKeysEnabled = nullptr; - QCheckBox *m_cbHotKeysGlobal = nullptr; - QLabel *m_labelHotKey = nullptr; - QComboBox *m_comboHotKey = nullptr; - QLabel *m_labelShortcut = nullptr; - QKeySequenceEdit *m_editShortcut = nullptr; - - QCheckBox *m_cbHomeAutoShowMenu = nullptr; - QCheckBox *m_cbSplashVisible = nullptr; - QCheckBox *m_cbTrayShowIcon = nullptr; - QCheckBox *m_cbTrayAnimateAlert = nullptr; - QLabel *m_labelTrayMaxGroups = nullptr; - QSpinBox *m_spinTrayMaxGroups = nullptr; - - QLabel *m_labelTrayEvent = nullptr; - QComboBox *m_comboTrayEvent = nullptr; - QLabel *m_labelTrayAction = nullptr; - QComboBox *m_comboTrayAction = nullptr; - QCheckBox *m_cbConfirmTrayFlags = nullptr; - QCheckBox *m_cbConfirmQuit = nullptr; QCheckBox *m_cbLogDebug = nullptr; QCheckBox *m_cbLogConsole = nullptr; }; diff --git a/src/ui/form/opt/pages/optmainpage.cpp b/src/ui/form/opt/pages/optmainpage.cpp index 7af93552..5623ccd6 100644 --- a/src/ui/form/opt/pages/optmainpage.cpp +++ b/src/ui/form/opt/pages/optmainpage.cpp @@ -19,6 +19,7 @@ #include "addressespage.h" #include "applicationspage.h" #include "graphpage.h" +#include "ifacepage.h" #include "optionspage.h" #include "schedulepage.h" #include "statisticspage.h" @@ -36,11 +37,12 @@ void OptMainPage::selectTab(int index) void OptMainPage::onRetranslateUi() { m_tabWidget->setTabText(0, tr("Options")); - m_tabWidget->setTabText(1, tr("IP Addresses")); - m_tabWidget->setTabText(2, tr("Application Groups")); - m_tabWidget->setTabText(3, tr("Statistics")); - m_tabWidget->setTabText(4, tr("Traffic Graph")); - m_tabWidget->setTabText(5, tr("Schedule")); + m_tabWidget->setTabText(1, tr("Interface")); + m_tabWidget->setTabText(2, tr("IP Addresses")); + m_tabWidget->setTabText(3, tr("Application Groups")); + m_tabWidget->setTabText(4, tr("Statistics")); + m_tabWidget->setTabText(5, tr("Traffic Graph")); + m_tabWidget->setTabText(6, tr("Schedule")); m_btBackup->setText(tr("Backup")); m_actExport->setText(tr("Export")); @@ -74,18 +76,21 @@ void OptMainPage::setupUi() void OptMainPage::setupTabBar() { auto optionsPage = new OptionsPage(ctrl()); + auto ifacePage = new IfacePage(ctrl()); auto addressesPage = new AddressesPage(ctrl()); auto applicationsPage = new ApplicationsPage(ctrl()); auto statisticsPage = new StatisticsPage(ctrl()); auto graphPage = new GraphPage(ctrl()); auto schedulePage = new SchedulePage(ctrl()); - m_pages = { optionsPage, addressesPage, applicationsPage, statisticsPage, graphPage, + m_pages = { optionsPage, ifacePage, addressesPage, applicationsPage, statisticsPage, graphPage, schedulePage }; m_tabWidget = new QTabWidget(); m_tabWidget->addTab(ControlUtil::wrapToScrollArea(optionsPage), IconCache::icon(":/icons/cog.png"), QString()); + m_tabWidget->addTab(ControlUtil::wrapToScrollArea(ifacePage), + IconCache::icon(":/icons/interface_preferences.png"), QString()); m_tabWidget->addTab(addressesPage, IconCache::icon(":/icons/ip.png"), QString()); m_tabWidget->addTab( applicationsPage, IconCache::icon(":/icons/application_double.png"), QString()); diff --git a/src/ui/fort_icons.qrc b/src/ui/fort_icons.qrc index f016844f..96f2df73 100644 --- a/src/ui/fort_icons.qrc +++ b/src/ui/fort_icons.qrc @@ -39,6 +39,7 @@ icons/help.png icons/hostname.png icons/information.png + icons/interface_preferences.png icons/ip.png icons/ip_block.png icons/ip_class.png diff --git a/src/ui/icons/interface_preferences.png b/src/ui/icons/interface_preferences.png new file mode 100644 index 00000000..58ce5b76 Binary files /dev/null and b/src/ui/icons/interface_preferences.png differ