diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 5fc797805..a9ca54324 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -155,26 +155,26 @@ void SettingsDialog::addTabs() // clang-format off this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg"); this->ui_.tabContainer->addSpacing(16); - this->addTab([]{return new AccountsPage;}, "Accounts", ":/settings/accounts.svg"); + this->addTab([]{return new AccountsPage;}, "Accounts", ":/settings/accounts.svg", SettingsTabId::Accounts); this->ui_.tabContainer->addSpacing(16); this->addTab([]{return new CommandPage;}, "Commands", ":/settings/commands.svg"); this->addTab([]{return new HighlightingPage;}, "Highlights", ":/settings/notifications.svg"); this->addTab([]{return new IgnoresPage;}, "Ignores", ":/settings/ignore.svg"); this->ui_.tabContainer->addSpacing(16); this->addTab([]{return new KeyboardSettingsPage;}, "Keybindings", ":/settings/keybinds.svg"); - this->addTab([]{return new ModerationPage;}, "Moderation", ":/settings/moderation.svg"); + this->addTab([]{return new ModerationPage;}, "Moderation", ":/settings/moderation.svg", SettingsTabId::Moderation); this->addTab([]{return new NotificationPage;}, "Notifications", ":/settings/notification2.svg"); this->addTab([]{return new ExternalToolsPage;}, "External tools", ":/settings/externaltools.svg"); this->ui_.tabContainer->addStretch(1); - this->addTab([]{return new AboutPage;}, "About", ":/settings/about.svg", Qt::AlignBottom); + this->addTab([]{return new AboutPage;}, "About", ":/settings/about.svg", SettingsTabId(), Qt::AlignBottom); // clang-format on } void SettingsDialog::addTab(std::function page, const QString &name, const QString &iconPath, - Qt::Alignment alignment) + SettingsTabId id, Qt::Alignment alignment) { - auto tab = new SettingsDialogTab(this, std::move(page), name, iconPath); + auto tab = new SettingsDialogTab(this, std::move(page), name, iconPath, id); this->ui_.tabContainer->addWidget(tab, 0, alignment); this->tabs_.push_back(tab); @@ -216,7 +216,12 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab, bool byUser) void SettingsDialog::selectTab(SettingsTabId id) { - this->selectTab(this->tab(id)); + auto t = this->tab(id); + assert(t); + if (!t) + return; + + this->selectTab(t); } SettingsDialogTab *SettingsDialog::tab(SettingsTabId id) diff --git a/src/widgets/dialogs/SettingsDialog.hpp b/src/widgets/dialogs/SettingsDialog.hpp index 84cdb98de..5dbef8b60 100644 --- a/src/widgets/dialogs/SettingsDialog.hpp +++ b/src/widgets/dialogs/SettingsDialog.hpp @@ -51,7 +51,7 @@ private: void initUi(); void addTabs(); void addTab(std::function page, const QString &name, - const QString &iconPath, + const QString &iconPath, SettingsTabId id = {}, Qt::Alignment alignment = Qt::AlignTop); void selectTab(SettingsDialogTab *tab, const bool byUser = true); void selectTab(SettingsTabId id); diff --git a/src/widgets/helper/SettingsDialogTab.hpp b/src/widgets/helper/SettingsDialogTab.hpp index 49dc9ff23..97c17f93b 100644 --- a/src/widgets/helper/SettingsDialogTab.hpp +++ b/src/widgets/helper/SettingsDialogTab.hpp @@ -26,7 +26,7 @@ public: SettingsDialogTab(SettingsDialog *dialog_, std::function page_, const QString &name, QString imageFileName, - SettingsTabId id = {}); + SettingsTabId id); void setSelected(bool selected_); SettingsPage *page(); diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 086b7a6ad..d891d0859 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -328,7 +328,8 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addCheckbox("Smooth scrolling on new messages", s.enableSmoothScrollingNewMessages); layout.addDropdown( - "Pause on hover", {"Disabled", "0.5s", "1s", "2s", "5s", "Indefinite"}, + "Pause after hover", + {"Disabled", "0.5s", "1s", "2s", "5s", "Indefinite"}, s.pauseOnHoverDuration, [](auto val) { if (val < -0.5f)