From b2fa7b1d9468738ca64b9597cc887d4bd763678c Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sat, 12 Feb 2022 12:27:25 +0000 Subject: [PATCH] Make Tab Layout setting only accept predefined values (#3564) Co-authored-by: pajlada --- CHANGELOG.md | 1 + src/singletons/Settings.hpp | 4 +- src/widgets/settingspages/GeneralPage.cpp | 50 ++++++++++++----------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e1c06e2..f2e1e0ac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ - Minor: Removed timestamp from AutoMod messages. (#3503) - Minor: Added ability to copy message ID with `Shift + Right Click`. (#3481) - Minor: Colorize the entire split header when focused. (#3379) +- Minor: Make Tab Layout setting only accept predefined values (#3564) - Bugfix: Fix Split Input hotkeys not being available when input is hidden (#3362) - Bugfix: Fixed colored usernames sometimes not working. (#3170) - Bugfix: Restored ability to send duplicate `/me` messages. (#3166) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 3aa4e1aa5..15f755405 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -98,8 +98,8 @@ public: "/appearance/messages/usernameDisplayMode", UsernameDisplayMode::UsernameAndLocalizedName}; - IntSetting tabDirection = {"/appearance/tabDirection", - NotebookTabDirection::Horizontal}; + EnumSetting tabDirection = { + "/appearance/tabDirection", NotebookTabDirection::Horizontal}; // BoolSetting collapseLongMessages = // {"/appearance/messages/collapseLongMessages", false}; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 293534bf1..9cd6bc4b1 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -144,30 +144,34 @@ void GeneralPage::initLayout(GeneralPageView &layout) [](auto args) { return fuzzyToFloat(args.value, 1.f); }); - layout.addDropdown( - "Tab layout", {"Horizontal", "Vertical"}, s.tabDirection, - [](auto val) { - switch (val) - { - case NotebookTabDirection::Horizontal: - return "Horizontal"; - case NotebookTabDirection::Vertical: - return "Vertical"; - } + ComboBox *tabDirectionDropdown = + layout.addDropdown::type>( + "Tab layout", {"Horizontal", "Vertical"}, s.tabDirection, + [](auto val) { + switch (val) + { + case NotebookTabDirection::Horizontal: + return "Horizontal"; + case NotebookTabDirection::Vertical: + return "Vertical"; + } - return ""; - }, - [](auto args) { - if (args.value == "Vertical") - { - return NotebookTabDirection::Vertical; - } - else - { - // default to horizontal - return NotebookTabDirection::Horizontal; - } - }); + return ""; + }, + [](auto args) { + if (args.value == "Vertical") + { + return NotebookTabDirection::Vertical; + } + else + { + // default to horizontal + return NotebookTabDirection::Horizontal; + } + }, + false); + tabDirectionDropdown->setMinimumWidth( + tabDirectionDropdown->minimumSizeHint().width()); layout.addCheckbox("Show tab close button", s.showTabCloseButton); layout.addCheckbox("Always on top", s.windowTopMost);