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 2ebbf44e..00000000 Binary files a/resources/buttons/modModeDisabled.png and /dev/null differ diff --git a/resources/buttons/modModeEnabled.png b/resources/buttons/modModeEnabled.png deleted file mode 100644 index f7bfec4b..00000000 Binary files a/resources/buttons/modModeEnabled.png and /dev/null differ diff --git a/resources/buttons/moderationDisabled-darkMode.svg b/resources/buttons/moderationDisabled-darkMode.svg new file mode 100644 index 00000000..91413787 --- /dev/null +++ b/resources/buttons/moderationDisabled-darkMode.svg @@ -0,0 +1,46 @@ + + + + + + + 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_{};