fix: svgify user card pin button (#6399)

This commit is contained in:
James Upjohn
2025-08-18 00:18:23 +12:00
committed by GitHub
parent b85073e673
commit 565c63d0df
13 changed files with 97 additions and 29 deletions
+4 -7
View File
@@ -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 <QMouseEvent>
@@ -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");
+10 -3
View File
@@ -1,5 +1,6 @@
#pragma once
#include "buttons/SvgButton.hpp"
#include "widgets/BaseWindow.hpp"
#include <QPoint>
@@ -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;
};
+3 -13
View File
@@ -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 <QBoxLayout>
@@ -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_);
}
}
+10 -3
View File
@@ -1,6 +1,7 @@
#pragma once
#ifdef CHATTERINO_HAVE_PLUGINS
# include "buttons/SvgButton.hpp"
# include "widgets/BaseWindow.hpp"
# include <boost/signals2/connection.hpp>
@@ -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 {