diff --git a/CHANGELOG.md b/CHANGELOG.md index b76b2d621..9d99e2fb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unversioned - Major: Added ability to toggle visibility of Channel Tabs - This can be done by right-clicking the tab area or pressing the keyboard shortcut (default: Ctrl+U). (#2600) +- Minor: Add setting for username style (#2889, #2891) - Minor: Searching for users in the viewer list now searches anywhere in the user's name. (#2861) - Minor: Added moderation buttons to search popup when searching in a split with moderation mode enabled. (#2148, #2803) - Minor: Made "#channel" in `/mentions` tab show in usercards and in the search popup. (#2802) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index f1c05e1af..fb85d778f 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -674,11 +674,7 @@ void TwitchMessageBuilder::appendUsername() // The full string that will be rendered in the chat widget QString usernameText; - pajlada::Settings::Setting usernameDisplayMode( - "/appearance/messages/usernameDisplayMode", - UsernameDisplayMode::UsernameAndLocalizedName); - - switch (usernameDisplayMode.getValue()) + switch (getSettings()->usernameDisplayMode.getValue()) { case UsernameDisplayMode::Username: { usernameText = username; diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index f0b53d98c..918c5bc7e 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -28,12 +28,6 @@ struct TwitchEmoteOccurence { class TwitchMessageBuilder : public SharedMessageBuilder { public: - enum UsernameDisplayMode : int { - Username = 1, // Username - LocalizedName = 2, // Localized name - UsernameAndLocalizedName = 3, // Username (Localized name) - }; - TwitchMessageBuilder() = delete; explicit TwitchMessageBuilder(Channel *_channel, diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 23e032458..ffb6815d9 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -52,6 +52,11 @@ private: ConcurrentSettings &getCSettings(); +enum UsernameDisplayMode : int { + Username = 1, // Username + LocalizedName = 2, // Localized name + UsernameAndLocalizedName = 3, // Username (Localized name) +}; /// Settings which are availlable for reading and writing on the gui thread. // These settings are still accessed concurrently in the code but it is bad practice. class Settings : public ABSettings, public ConcurrentSettings @@ -88,6 +93,9 @@ public: "/appearance/messages/hideDeletionActions", false}; BoolSetting colorizeNicknames = {"/appearance/messages/colorizeNicknames", true}; + EnumSetting usernameDisplayMode = { + "/appearance/messages/usernameDisplayMode", + UsernameDisplayMode::UsernameAndLocalizedName}; IntSetting tabDirection = {"/appearance/tabDirection", NotebookTabDirection::Horizontal}; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index fcb199c67..5d96e9ac5 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -612,6 +612,19 @@ void GeneralPage::initLayout(GeneralPageView &layout) layout.addCheckbox("Color @usernames", s.colorUsernames); layout.addCheckbox("Try to find usernames without @ prefix", s.findAllUsernames); + const QStringList usernameDisplayModes = {"Username", "Localized name", + "Username and localized name"}; + + layout.addDropdown::type>( + "Username style", usernameDisplayModes, s.usernameDisplayMode, + [usernameDisplayModes](auto val) { + return usernameDisplayModes.at(val - 1); + // UsernameDisplayMode enum indexes from 1 + }, + [](auto args) { + return args.index + 1; + }, + false); layout.addDropdown( "Username font weight", {"50", "Default", "75", "100"}, s.boldScale, [](auto val) {