From 1b9ed11a67e0ed53d0627b85195494265a2b3c53 Mon Sep 17 00:00:00 2001 From: pajlada Date: Mon, 18 Aug 2025 00:02:35 +0200 Subject: [PATCH] fix: svgify moderation button (#6398) --- CHANGELOG.md | 1 + resources/buttons/modModeDisabled.png | Bin 512 -> 0 bytes resources/buttons/modModeEnabled.png | Bin 589 -> 0 bytes .../buttons/moderationDisabled-darkMode.svg | 46 +++++++++ .../buttons/moderationDisabled-lightMode.svg | 46 +++++++++ .../buttons/moderationEnabled-darkMode.svg | 46 +++++++++ .../buttons/moderationEnabled-lightMode.svg | 46 +++++++++ src/widgets/buttons/SvgButton.cpp | 1 + src/widgets/splits/SplitHeader.cpp | 94 ++++++++++-------- src/widgets/splits/SplitHeader.hpp | 3 +- 10 files changed, 240 insertions(+), 43 deletions(-) delete mode 100644 resources/buttons/modModeDisabled.png delete mode 100644 resources/buttons/modModeEnabled.png create mode 100644 resources/buttons/moderationDisabled-darkMode.svg create mode 100644 resources/buttons/moderationDisabled-lightMode.svg create mode 100644 resources/buttons/moderationEnabled-darkMode.svg create mode 100644 resources/buttons/moderationEnabled-lightMode.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b9ea8b7..c85dba7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,7 @@ - Dev: Made "add split" button (part of the split header) a natively rendered button. (#6349) - Dev: Made Settings & Account button on Linux/macOS SVGs. (#6267) - Dev: Made "Chatters" button an SVG. (#6397) +- Dev: Made "Moderation" button an SVG. (#6398) - Dev: Made user card "pin" button SVGs. (#6399) - Dev: Some more setting widget refactors. (#6317) - Dev: Emoji style / set is now stored lowercase (and matched case-insensitively). Changing emoji style from this point on and then running an old version might mean you will use the Twitter emoji style by default. (#6300) diff --git a/resources/buttons/modModeDisabled.png b/resources/buttons/modModeDisabled.png deleted file mode 100644 index 2ebbf44e600a999bcaf33d2a3cbd37eeb0d3193c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 512 zcmV+b0{{JqP)^^%McAK}l>}@K`4lj3cld^Z-n>~pO7?OLf2zG` zCwAgcIVB)Tm*RMV_V$5N)9Km(Ot0B8qJ3Fh#;g>CBEXls@FfkmflS%e%hugmKAzirb zIFPK{jwcBl6c}BL^Chjt=}4rsNc4+gdh_PZ{rmvsokQJ)4UMq?0000uN_2MXYXU* zWt?BZ)yUYY(X@(-MJPC)`NppnvG}%w*B^8r*sjFp<$bx%zRR=i?A(WM%1pyu=UCo+ z|7PdyAHKye)7qDH&W?-tB5yA5=xd~)XVvi2*|Oi-rFL7UX=KC~@oRyB;>Qdx%4=Mj z@j^sRDd?ZCl9c;@RsZPl zc0S#hi9GQaGv6O95w8=E_;OQgU)~y4PVZO~IfgwyuJtSJZQpveqqXIRW<87W;pZOj z_6hZN-Q9kFEt3@chqn)e_txGu&8`o7oSl8VYklT9k@(3`-1{tKH;C4pT=4$YH0gbA z2hK=Z*2D@G9AEc)#njp7?{=}=n6xW*v&r7_u!Vo?wSZjSMqEqX6 z?zsf#KjBCS{F1bB1ZU|BD~rJN{&jgHP-V z`Hm+n)t*;h@!j*jc00g-!7YL7TNhjv_}L%zlxu0&Ez_-&LO(~pT($CQq_Umo + + + + + + diff --git a/resources/buttons/moderationDisabled-lightMode.svg b/resources/buttons/moderationDisabled-lightMode.svg new file mode 100644 index 00000000..a4c896ac --- /dev/null +++ b/resources/buttons/moderationDisabled-lightMode.svg @@ -0,0 +1,46 @@ + + + + + + + diff --git a/resources/buttons/moderationEnabled-darkMode.svg b/resources/buttons/moderationEnabled-darkMode.svg new file mode 100644 index 00000000..9f9b24eb --- /dev/null +++ b/resources/buttons/moderationEnabled-darkMode.svg @@ -0,0 +1,46 @@ + + + + + + + diff --git a/resources/buttons/moderationEnabled-lightMode.svg b/resources/buttons/moderationEnabled-lightMode.svg new file mode 100644 index 00000000..9f9b24eb --- /dev/null +++ b/resources/buttons/moderationEnabled-lightMode.svg @@ -0,0 +1,46 @@ + + + + + + + diff --git a/src/widgets/buttons/SvgButton.cpp b/src/widgets/buttons/SvgButton.cpp index 4de2dcc6..b4dd9bad 100644 --- a/src/widgets/buttons/SvgButton.cpp +++ b/src/widgets/buttons/SvgButton.cpp @@ -18,6 +18,7 @@ SvgButton::SvgButton(Src source, BaseWidget *parent, QSize padding) void SvgButton::setSource(Src source) { + // TODO: compare sources before trying to load / invalidate? this->source_ = std::move(source); this->loadSource(); this->invalidateContent(); diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index afbe8de1..26740e6a 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -13,7 +13,6 @@ #include "providers/twitch/TwitchAccount.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchIrcServer.hpp" -#include "singletons/Resources.hpp" #include "singletons/Settings.hpp" #include "singletons/StreamerMode.hpp" #include "singletons/Theme.hpp" @@ -22,7 +21,6 @@ #include "util/LayoutHelper.hpp" #include "widgets/buttons/DrawnButton.hpp" #include "widgets/buttons/LabelButton.hpp" -#include "widgets/buttons/PixmapButton.hpp" #include "widgets/buttons/SvgButton.hpp" #include "widgets/dialogs/SettingsDialog.hpp" #include "widgets/helper/CommonTexts.hpp" @@ -290,6 +288,13 @@ void SplitHeader::initializeLayout() { assert(this->layout() == nullptr); + this->moderationButton_ = new SvgButton( + { + .dark = ":/buttons/moderationDisabled-darkMode.svg", + .light = ":/buttons/moderationDisabled-lightMode.svg", + }, + this, {5, 5}); + this->chattersButton_ = new SvgButton( { .dark = ":/buttons/chatters-darkMode.svg", @@ -336,42 +341,7 @@ void SplitHeader::initializeLayout() w->setMenu(this->createChatModeMenu()); }), // moderator - this->moderationButton_ = makeWidget([&](auto w) { - QObject::connect( - w, &Button::clicked, this, - [this, w](Qt::MouseButton button) mutable { - switch (button) - { - case Qt::LeftButton: - if (getSettings()->moderationActions.empty()) - { - getApp()->getWindows()->showSettingsDialog( - this, SettingsDialogPreference:: - ModerationActions); - this->split_->setModerationMode(true); - } - else - { - auto moderationMode = - this->split_->getModerationMode(); - - this->split_->setModerationMode( - !moderationMode); - w->setDim(moderationMode - ? DimButton::Dim::Some - : DimButton::Dim::None); - } - break; - - case Qt::RightButton: - case Qt::MiddleButton: - getApp()->getWindows()->showSettingsDialog( - this, - SettingsDialogPreference::ModerationActions); - break; - } - }); - }), + this->moderationButton_, // chatter list this->chattersButton_, // dropdown @@ -380,6 +350,37 @@ void SplitHeader::initializeLayout() this->addButton_, }); + QObject::connect( + this->moderationButton_, &Button::clicked, this, + [this](Qt::MouseButton button) mutable { + auto *w = this->moderationButton_; + switch (button) + { + case Qt::LeftButton: + if (getSettings()->moderationActions.empty()) + { + getApp()->getWindows()->showSettingsDialog( + this, SettingsDialogPreference::ModerationActions); + this->split_->setModerationMode(true); + } + else + { + auto moderationMode = this->split_->getModerationMode(); + + this->split_->setModerationMode(!moderationMode); + // w->setDim(moderationMode ? DimButton::Dim::Some + // : DimButton::Dim::None); + } + break; + + case Qt::RightButton: + case Qt::MiddleButton: + getApp()->getWindows()->showSettingsDialog( + this, SettingsDialogPreference::ModerationActions); + break; + } + }); + QObject::connect(this->chattersButton_, &Button::leftClicked, this, [this]() { this->split_->openChatterList(); @@ -923,9 +924,20 @@ void SplitHeader::updateIcons() auto moderationMode = this->split_->getModerationMode() && !getSettings()->moderationActions.empty(); - this->moderationButton_->setPixmap( - moderationMode ? getResources().buttons.modModeEnabled - : getResources().buttons.modModeDisabled); + if (moderationMode) + { + this->moderationButton_->setSource({ + .dark = ":/buttons/moderationEnabled-darkMode.svg", + .light = ":/buttons/moderationEnabled-lightMode.svg", + }); + } + else + { + this->moderationButton_->setSource({ + .dark = ":/buttons/moderationDisabled-darkMode.svg", + .light = ":/buttons/moderationDisabled-lightMode.svg", + }); + } if (twitchChannel->hasModRights() || moderationMode) { diff --git a/src/widgets/splits/SplitHeader.hpp b/src/widgets/splits/SplitHeader.hpp index f1c1f92d..b119fea2 100644 --- a/src/widgets/splits/SplitHeader.hpp +++ b/src/widgets/splits/SplitHeader.hpp @@ -18,7 +18,6 @@ namespace chatterino { class SvgButton; class DrawnButton; -class PixmapButton; class LabelButton; class Label; class Split; @@ -87,7 +86,7 @@ private: QAction *modeActionSetR9k{}; QAction *modeActionSetFollowers{}; - PixmapButton *moderationButton_{}; + SvgButton *moderationButton_{}; SvgButton *chattersButton_{}; DrawnButton *addButton_{};