UI: Options: Add "My Fort: Auto-Show Menu" flag

This commit is contained in:
Nodir Temirkhodjaev 2023-06-02 14:53:10 +03:00
parent e0d69be6cb
commit e7e6ac5c4f
5 changed files with 40 additions and 6 deletions

View File

@ -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();

View File

@ -34,9 +34,11 @@ public:
void restoreWindowState() override;
public slots:
void showMenu();
void selectAboutTab();
private slots:
void onActivated();
private:
void setupController();
void setupStateWatcher();

View File

@ -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) {

View File

@ -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;

View File

@ -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); }