diff --git a/CHANGELOG.md b/CHANGELOG.md index 82e931c7..942485b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ - Dev: Refactored `Button` and friends. (#6102, #6255, #6266, #6302, #6268, #6334, #6371, #6372) - 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 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) - Dev: Refactored `OnceFlag`. (#6237, #6316) diff --git a/resources/buttons/pinDisabled-darkMode.svg b/resources/buttons/pinDisabled-darkMode.svg new file mode 100644 index 00000000..a9b18bc8 --- /dev/null +++ b/resources/buttons/pinDisabled-darkMode.svg @@ -0,0 +1,23 @@ + + + + diff --git a/resources/buttons/pinDisabled-lightMode.svg b/resources/buttons/pinDisabled-lightMode.svg new file mode 100644 index 00000000..5f6549df --- /dev/null +++ b/resources/buttons/pinDisabled-lightMode.svg @@ -0,0 +1,23 @@ + + + + diff --git a/resources/buttons/pinDisabledDark.png b/resources/buttons/pinDisabledDark.png deleted file mode 100644 index 87e912c5..00000000 Binary files a/resources/buttons/pinDisabledDark.png and /dev/null differ diff --git a/resources/buttons/pinDisabledLight.png b/resources/buttons/pinDisabledLight.png deleted file mode 100644 index 5eeac17b..00000000 Binary files a/resources/buttons/pinDisabledLight.png and /dev/null differ diff --git a/resources/buttons/pinEnabled.png b/resources/buttons/pinEnabled.png deleted file mode 100644 index 2fe5944d..00000000 Binary files a/resources/buttons/pinEnabled.png and /dev/null differ diff --git a/resources/buttons/pinEnabled.svg b/resources/buttons/pinEnabled.svg new file mode 100644 index 00000000..d17f5f34 --- /dev/null +++ b/resources/buttons/pinEnabled.svg @@ -0,0 +1,23 @@ + + + + diff --git a/src/singletons/Theme.cpp b/src/singletons/Theme.cpp index 87eb07bb..6bf0d25d 100644 --- a/src/singletons/Theme.cpp +++ b/src/singletons/Theme.cpp @@ -549,12 +549,10 @@ void Theme::parseFrom(const QJsonObject &root, bool isCustomTheme) if (this->isLightTheme()) { this->buttons.copy = getResources().buttons.copyDark; - this->buttons.pin = getResources().buttons.pinDisabledDark; } else { this->buttons.copy = getResources().buttons.copyLight; - this->buttons.pin = getResources().buttons.pinDisabledLight; } // This assumes that we never update the application palette diff --git a/src/singletons/Theme.hpp b/src/singletons/Theme.hpp index 1ae50797..63e8cf08 100644 --- a/src/singletons/Theme.hpp +++ b/src/singletons/Theme.hpp @@ -153,7 +153,6 @@ public: struct { QPixmap copy; - QPixmap pin; } buttons; QPalette palette; diff --git a/src/widgets/DraggablePopup.cpp b/src/widgets/DraggablePopup.cpp index 5dd85651..240dac76 100644 --- a/src/widgets/DraggablePopup.cpp +++ b/src/widgets/DraggablePopup.cpp @@ -1,8 +1,6 @@ #include "widgets/DraggablePopup.hpp" -#include "singletons/Resources.hpp" -#include "singletons/Theme.hpp" -#include "widgets/buttons/PixmapButton.hpp" +#include "buttons/SvgButton.hpp" #include @@ -109,18 +107,17 @@ void DraggablePopup::togglePinned() if (isPinned_) { this->windowDeactivateAction = WindowDeactivateAction::Nothing; - this->pinButton_->setPixmap(getResources().buttons.pinEnabled); + this->pinButton_->setSource(this->pinEnabledSource_); } else { this->windowDeactivateAction = WindowDeactivateAction::Delete; - this->pinButton_->setPixmap(getTheme()->buttons.pin); + this->pinButton_->setSource(this->pinDisabledSource_); } } Button *DraggablePopup::createPinButton() { - this->pinButton_ = new PixmapButton(this); - this->pinButton_->setPixmap(getTheme()->buttons.pin); + this->pinButton_ = new SvgButton(pinDisabledSource_, this, {3, 3}); this->pinButton_->setScaleIndependentSize(18, 18); this->pinButton_->setToolTip("Pin Window"); diff --git a/src/widgets/DraggablePopup.hpp b/src/widgets/DraggablePopup.hpp index 4e6e1cd4..01b296cb 100644 --- a/src/widgets/DraggablePopup.hpp +++ b/src/widgets/DraggablePopup.hpp @@ -1,5 +1,6 @@ #pragma once +#include "buttons/SvgButton.hpp" #include "widgets/BaseWindow.hpp" #include @@ -9,8 +10,6 @@ namespace chatterino { -class PixmapButton; - class DraggablePopup : public BaseWindow { Q_OBJECT @@ -62,7 +61,15 @@ private: // dragTimer_ is called ~60 times per second once the user has initiated dragging QTimer dragTimer_; - PixmapButton *pinButton_ = nullptr; + SvgButton *pinButton_{}; + SvgButton::Src pinDisabledSource_{ + .dark = ":/buttons/pinDisabled-darkMode.svg", + .light = ":/buttons/pinDisabled-lightMode.svg", + }; + SvgButton::Src pinEnabledSource_{ + .dark = ":/buttons/pinEnabled.svg", + .light = ":/buttons/pinEnabled.svg", + }; bool isPinned_ = false; }; diff --git a/src/widgets/PluginRepl.cpp b/src/widgets/PluginRepl.cpp index a31c14f7..9bd09b0c 100644 --- a/src/widgets/PluginRepl.cpp +++ b/src/widgets/PluginRepl.cpp @@ -11,7 +11,6 @@ # include "singletons/Resources.hpp" # include "singletons/Settings.hpp" # include "singletons/Theme.hpp" -# include "widgets/buttons/PixmapButton.hpp" # include "widgets/buttons/SvgButton.hpp" # include @@ -445,7 +444,7 @@ PluginRepl::PluginRepl(QString id, QWidget *parent) } }); - this->ui.pin = new PixmapButton; + this->ui.pin = new SvgButton(this->ui.pinDisabledSource_, this, {0, 0}); this->ui.pin->setScaleIndependentSize({18, 18}); this->ui.pin->setToolTip(u"Pin Window"_s); QObject::connect(this->ui.pin, &Button::leftClicked, this, [this] { @@ -512,15 +511,6 @@ void PluginRepl::themeChangedEvent() this->blockFormats.error.setBackground(QColor(0x4b2f36)); } - if (this->isPinned) - { - this->ui.pin->setPixmap(getResources().buttons.pinEnabled); - } - else - { - this->ui.pin->setPixmap(getTheme()->buttons.pin); - } - auto pal = this->palette(); pal.setColor(QPalette::Window, getTheme()->tabs.selected.backgrounds.regular); @@ -754,11 +744,11 @@ void PluginRepl::updatePinned() this->setTopMost(this->isPinned); if (this->isPinned) { - this->ui.pin->setPixmap(getResources().buttons.pinEnabled); + this->ui.pin->setSource(this->ui.pinEnabledSource_); } else { - this->ui.pin->setPixmap(getTheme()->buttons.pin); + this->ui.pin->setSource(this->ui.pinDisabledSource_); } } diff --git a/src/widgets/PluginRepl.hpp b/src/widgets/PluginRepl.hpp index 4d45956c..e29eb7f3 100644 --- a/src/widgets/PluginRepl.hpp +++ b/src/widgets/PluginRepl.hpp @@ -1,6 +1,7 @@ #pragma once #ifdef CHATTERINO_HAVE_PLUGINS +# include "buttons/SvgButton.hpp" # include "widgets/BaseWindow.hpp" # include @@ -20,8 +21,6 @@ enum class LogLevel; namespace chatterino { class Plugin; -class SvgButton; -class PixmapButton; class PluginRepl : public BaseWindow { @@ -65,7 +64,15 @@ private: QTextEdit *output = nullptr; SvgButton *clear = nullptr; SvgButton *reload = nullptr; - PixmapButton *pin = nullptr; + SvgButton *pin = nullptr; + SvgButton::Src pinDisabledSource_{ + .dark = ":/buttons/pinDisabled-darkMode.svg", + .light = ":/buttons/pinDisabled-lightMode.svg", + }; + SvgButton::Src pinEnabledSource_{ + .dark = ":/buttons/pinEnabled.svg", + .light = ":/buttons/pinEnabled.svg", + }; } ui; struct {