diff --git a/src/ui/form/home/homewindow.cpp b/src/ui/form/home/homewindow.cpp index 0bfb2578..9f9ae0c7 100644 --- a/src/ui/form/home/homewindow.cpp +++ b/src/ui/form/home/homewindow.cpp @@ -30,6 +30,8 @@ HomeWindow::HomeWindow(QWidget *parent) : setupUi(); setupController(); setupStateWatcher(); + + connect(this, &HomeWindow::activated, this, &HomeWindow::onActivated); } FortSettings *HomeWindow::settings() const @@ -70,16 +72,18 @@ void HomeWindow::restoreWindowState() emit ctrl()->afterRestoreWindowState(iniUser()); } -void HomeWindow::showMenu() -{ - m_btMenu->showMenu(); -} - void HomeWindow::selectAboutTab() { m_mainPage->setCurrentTab(HomeMainPage::TabAbout); } +void HomeWindow::onActivated() +{ + if (iniUser()->homeAutoShowMenu()) { + m_btMenu->showMenu(); + } +} + void HomeWindow::retranslateUi() { this->unsetLocale(); diff --git a/src/ui/form/home/homewindow.h b/src/ui/form/home/homewindow.h index aed0d9fd..c33db670 100644 --- a/src/ui/form/home/homewindow.h +++ b/src/ui/form/home/homewindow.h @@ -34,9 +34,11 @@ public: void restoreWindowState() override; public slots: - void showMenu(); void selectAboutTab(); +private slots: + void onActivated(); + private: void setupController(); void setupStateWatcher(); diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index 096d79ee..b088b108 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -151,6 +151,7 @@ void OptionsPage::onRetranslateUi() 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")); @@ -189,6 +190,8 @@ void OptionsPage::onRetranslateUi() m_cbHotKeysEnabled->setText(tr("Enabled")); m_cbHotKeysGlobal->setText(tr("Global")); + m_cbHomeAutoShowMenu->setText(tr("Auto-Show Menu")); + m_cbTrayShowIcon->setText(tr("Show Icon")); m_cbTrayAnimateAlert->setText(tr("Animate Alert Icon")); m_labelTrayEvent->setText(tr("Event:")); @@ -575,6 +578,10 @@ QLayout *OptionsPage::setupColumn2() setupHotKeysBox(); layout->addWidget(m_gbHotKeys); + // Home Group Box + setupHomeBox(); + layout->addWidget(m_gbHome); + // Tray Group Box setupTrayBox(); layout->addWidget(m_gbTray); @@ -661,6 +668,21 @@ void OptionsPage::setupHotKeysBox() m_gbHotKeys->setLayout(layout); } +void OptionsPage::setupHomeBox() +{ + m_cbHomeAutoShowMenu = + ControlUtil::createCheckBox(iniUser()->homeAutoShowMenu(), [&](bool checked) { + iniUser()->setHomeAutoShowMenu(checked); + ctrl()->setIniUserEdited(); + }); + + auto layout = new QVBoxLayout(); + layout->addWidget(m_cbHomeAutoShowMenu); + + m_gbHome = new QGroupBox(); + m_gbHome->setLayout(layout); +} + void OptionsPage::setupTrayBox() { m_cbTrayShowIcon = ControlUtil::createCheckBox(iniUser()->trayShowIcon(), [&](bool checked) { diff --git a/src/ui/form/opt/pages/optionspage.h b/src/ui/form/opt/pages/optionspage.h index 16a8c68a..269f9d4d 100644 --- a/src/ui/form/opt/pages/optionspage.h +++ b/src/ui/form/opt/pages/optionspage.h @@ -53,6 +53,7 @@ private: QLayout *setupLangLayout(); void setupComboLanguage(); void setupHotKeysBox(); + void setupHomeBox(); void setupTrayBox(); void refreshComboTrayAction(); QLayout *setupTrayEventLayout(); @@ -72,6 +73,7 @@ private: 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; @@ -99,6 +101,7 @@ private: QComboBox *m_comboLanguage = nullptr; QCheckBox *m_cbHotKeysEnabled = nullptr; QCheckBox *m_cbHotKeysGlobal = nullptr; + QCheckBox *m_cbHomeAutoShowMenu = nullptr; QCheckBox *m_cbTrayShowIcon = nullptr; QCheckBox *m_cbTrayAnimateAlert = nullptr; QLabel *m_labelTrayEvent = nullptr; diff --git a/src/ui/user/iniuser.h b/src/ui/user/iniuser.h index a45aa201..4c5c37d9 100644 --- a/src/ui/user/iniuser.h +++ b/src/ui/user/iniuser.h @@ -44,6 +44,9 @@ public: "filterModeAllow", "filterModeIgnore" }; } + bool homeAutoShowMenu() const { return valueBool("home/autoShowMenu"); } + void setHomeAutoShowMenu(bool v) { setValue("home/autoShowMenu", v); } + bool trayShowIcon() const { return valueBool("tray/showIcon", true); } void setTrayShowIcon(bool v) { setValue("tray/showIcon", v, true); }