From 6398570bcc6544a5f9b38a6629f52d312056bbea Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 14 Jun 2025 22:28:17 +0200 Subject: [PATCH] refactor: Make Account & Settings buttons SVGs (#6267) instead of rendering the icons directly in Chatterino, they're now SVGs This has the following consequences: 1. The color does _not_ respect your custom theme. For most users, this will not be a problem/concern. 2. You can no longer drag a split onto those buttons to create a new tab --- CHANGELOG.md | 1 + resources/buttons/account-darkMode.svg | 17 ++++++++++ resources/buttons/account-lightMode.svg | 17 ++++++++++ resources/buttons/settings-darkMode.svg | 17 ++++++++++ resources/buttons/settings-lightMode.svg | 17 ++++++++++ src/widgets/Notebook.cpp | 23 +++++++++---- src/widgets/buttons/NotebookButton.cpp | 42 ------------------------ src/widgets/buttons/NotebookButton.hpp | 5 ++- 8 files changed, 89 insertions(+), 50 deletions(-) create mode 100644 resources/buttons/account-darkMode.svg create mode 100644 resources/buttons/account-lightMode.svg create mode 100644 resources/buttons/settings-darkMode.svg create mode 100644 resources/buttons/settings-lightMode.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b1d827..3eb736da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ - Dev: Fixed incorrect lua generation of static methods for typescript plugins. (#6190, #6223) - Dev: Merged top/bottom and left/right notebook layouts. (#6215) - Dev: Refactored `Button` and friends. (#6102, #6255) +- Dev: Made Settings & Account button on Linux/macOS SVGs. (#6267) - Dev: `OnceFlag`'s internal flag is now atomic. (#6237) - Dev: Bumped clang-format requirement to 19. (#6236) diff --git a/resources/buttons/account-darkMode.svg b/resources/buttons/account-darkMode.svg new file mode 100644 index 00000000..521b98cf --- /dev/null +++ b/resources/buttons/account-darkMode.svg @@ -0,0 +1,17 @@ + + +Qt SVG Document +Generated with Qt + + + + + + + + + diff --git a/resources/buttons/account-lightMode.svg b/resources/buttons/account-lightMode.svg new file mode 100644 index 00000000..e7a19d67 --- /dev/null +++ b/resources/buttons/account-lightMode.svg @@ -0,0 +1,17 @@ + + +Qt SVG Document +Generated with Qt + + + + + + + + + diff --git a/resources/buttons/settings-darkMode.svg b/resources/buttons/settings-darkMode.svg new file mode 100644 index 00000000..190cc4bf --- /dev/null +++ b/resources/buttons/settings-darkMode.svg @@ -0,0 +1,17 @@ + + +Qt SVG Document +Generated with Qt + + + + + + + + + diff --git a/resources/buttons/settings-lightMode.svg b/resources/buttons/settings-lightMode.svg new file mode 100644 index 00000000..6a0ee668 --- /dev/null +++ b/resources/buttons/settings-lightMode.svg @@ -0,0 +1,17 @@ + + +Qt SVG Document +Generated with Qt + + + + + + + + + diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index f6b442c1..ee3c3f27 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -13,6 +13,7 @@ #include "widgets/buttons/InitUpdateButton.hpp" #include "widgets/buttons/NotebookButton.hpp" #include "widgets/buttons/PixmapButton.hpp" +#include "widgets/buttons/SvgButton.hpp" #include "widgets/dialogs/SettingsDialog.hpp" #include "widgets/helper/ChannelView.hpp" #include "widgets/helper/NotebookTab.hpp" @@ -1407,7 +1408,12 @@ void SplitNotebook::showEvent(QShowEvent * /*event*/) void SplitNotebook::addCustomButtons() { // settings - auto *settingsBtn = this->addCustomButton(); + auto *settingsBtn = this->addCustomButton(SvgButton::Src{ + .dark = ":/buttons/settings-darkMode.svg", + .light = ":/buttons/settings-lightMode.svg", + }); + + settingsBtn->setPadding({0, 0}); // This is to ensure you can't lock yourself out of the settings if (getApp()->getArgs().safeMode) @@ -1426,14 +1432,18 @@ void SplitNotebook::addCustomButtons() this->signalHolder_); } - settingsBtn->setIcon(NotebookButton::Settings); - - QObject::connect(settingsBtn, &NotebookButton::leftClicked, [this] { + QObject::connect(settingsBtn, &Button::leftClicked, [this] { getApp()->getWindows()->showSettingsDialog(this); }); // account - auto *userBtn = this->addCustomButton(); + auto *userBtn = this->addCustomButton(SvgButton::Src{ + .dark = ":/buttons/account-darkMode.svg", + .light = ":/buttons/account-lightMode.svg", + }); + + userBtn->setPadding({0, 0}); + userBtn->setVisible(!getSettings()->hideUserButton.getValue()); getSettings()->hideUserButton.connect( [userBtn](bool hide, auto) { @@ -1441,8 +1451,7 @@ void SplitNotebook::addCustomButtons() }, this->signalHolder_); - userBtn->setIcon(NotebookButton::User); - QObject::connect(userBtn, &NotebookButton::leftClicked, [this, userBtn] { + QObject::connect(userBtn, &Button::leftClicked, [this, userBtn] { getApp()->getWindows()->showAccountSelectPopup( this->mapToGlobal(userBtn->rect().bottomRight())); }); diff --git a/src/widgets/buttons/NotebookButton.cpp b/src/widgets/buttons/NotebookButton.cpp index b5304f3a..345aa57a 100644 --- a/src/widgets/buttons/NotebookButton.cpp +++ b/src/widgets/buttons/NotebookButton.cpp @@ -89,48 +89,6 @@ void NotebookButton::paintContent(QPainter &painter) } break; - case User: { - painter.setRenderHint(QPainter::Antialiasing); - - auto a = w / 8; - QPainterPath path; - - path.arcMoveTo(a, 4 * a, 6 * a, 6 * a, 0); - path.arcTo(a, 4 * a, 6 * a, 6 * a, 0, 180); - - QPainterPath remove; - remove.addEllipse(2 * a, 1 * a, 4 * a, 4 * a); - path = path.subtracted(remove); - - path.addEllipse(2.5 * a, 1.5 * a, 3 * a, 3 * a); - - painter.fillPath(path, foreground); - } - break; - - case Settings: { - painter.setRenderHint(QPainter::Antialiasing); - - auto a = w / 8; - QPainterPath path; - - path.arcMoveTo(a, a, 6 * a, 6 * a, 0 - (360 / 32.0)); - - for (int i = 0; i < 8; i++) - { - path.arcTo(a, a, 6 * a, 6 * a, i * (360 / 8.0) - (360 / 32.0), - (360 / 32.0)); - path.arcTo(2 * a, 2 * a, 4 * a, 4 * a, - i * (360 / 8.0) + (360 / 32.0), (360 / 32.0)); - } - - QPainterPath remove; - remove.addEllipse(3 * a, 3 * a, 2 * a, 2 * a); - - painter.fillPath(path.subtracted(remove), foreground); - } - break; - default:; } } diff --git a/src/widgets/buttons/NotebookButton.hpp b/src/widgets/buttons/NotebookButton.hpp index 306fe414..e7642368 100644 --- a/src/widgets/buttons/NotebookButton.hpp +++ b/src/widgets/buttons/NotebookButton.hpp @@ -13,7 +13,10 @@ class NotebookButton : public Button Q_OBJECT public: - enum Icon { None, Plus, User, Settings }; + enum Icon { + None, + Plus, + }; explicit NotebookButton(Notebook *parent);