From 565c63d0df2f14b220a81ae32ca0fdad42ae2a1a Mon Sep 17 00:00:00 2001 From: James Upjohn Date: Mon, 18 Aug 2025 00:18:23 +1200 Subject: [PATCH] fix: svgify user card pin button (#6399) --- CHANGELOG.md | 1 + resources/buttons/pinDisabled-darkMode.svg | 23 ++++++++++++++++++++ resources/buttons/pinDisabled-lightMode.svg | 23 ++++++++++++++++++++ resources/buttons/pinDisabledDark.png | Bin 278 -> 0 bytes resources/buttons/pinDisabledLight.png | Bin 300 -> 0 bytes resources/buttons/pinEnabled.png | Bin 340 -> 0 bytes resources/buttons/pinEnabled.svg | 23 ++++++++++++++++++++ src/singletons/Theme.cpp | 2 -- src/singletons/Theme.hpp | 1 - src/widgets/DraggablePopup.cpp | 11 ++++------ src/widgets/DraggablePopup.hpp | 13 ++++++++--- src/widgets/PluginRepl.cpp | 16 +++----------- src/widgets/PluginRepl.hpp | 13 ++++++++--- 13 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 resources/buttons/pinDisabled-darkMode.svg create mode 100644 resources/buttons/pinDisabled-lightMode.svg delete mode 100644 resources/buttons/pinDisabledDark.png delete mode 100644 resources/buttons/pinDisabledLight.png delete mode 100644 resources/buttons/pinEnabled.png create mode 100644 resources/buttons/pinEnabled.svg 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 87e912c5d6f483fde750a33a5a19100961e3f23b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 278 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I0wfs{c7_7UyPhtNAr-gYUfamo;vmA7m_7GV z&ap*%POBMw5G$Me;7`0(4YSe?-P;@I-nZVC@X58QW|G2ul@sZlpRTv`m@7W^Jy9WS zbPpR-=^powjSTD5_x}@pWB2MWum6$VUF9Kr7C({|eZQi@{iwCpy}*xss6t%xybl@g zsdsPYJoD`QK^C>ohdIwYJuW=sbiewBuKV?WG$K#mSKlygzkh;m{rm%)|ClyDuV_Ed tzK4_dy+_6OPx}8qEry!kUSlftk9qyy+5465)vO2k*VEO{Wt~$(69B&uez*Vt diff --git a/resources/buttons/pinDisabledLight.png b/resources/buttons/pinDisabledLight.png deleted file mode 100644 index 5eeac17b28bb6301879dc2b8a20f622b7a09f81c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I0wfs{c7_7U&z>%hAr-gYUfamqVj#d8$hAOa z`{uP5&xmeyH#^AMt@@s~(O&4KG^g^<7m@RRo~-`<+vcBbg(Bm;i3%T7GHf`d{F{zV zUhokI)5C^S=)B6j(1<^FAKuPaSf3-+{^97K2^CB#^HK?F1}b2hzt|(=@lM&JAx>+a z6&opveZI_j@qoYTk)(OHHhmY5#`D*odhzsi3o^cV@;c}A1Ctd#=(zK>rq90r=b8HS eg$M^e_z>TAV&ikwPM=m#D0sU1xvXQnA>MxzRS+sef|4|5cluti&+ZVPcU{cH9!dt zMh6!LCk6pQ0Tu=q78XVZK}J^w2N4F=1y&cuQS~YR~XA)i5kpe zVNhh~U~u4IP-19eXqdpj(xAeyf*WKAL*s-4oJy?UBS_Za6Rs)XHjgD(r4LU4YU+6G&G5nRipw_U5FF=qfq4K70 b-Csrq&!CRtHJjD|{mbC#>gTe~DWM4ff1q_* 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 {