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
This commit is contained in:
pajlada
2025-06-14 22:28:17 +02:00
committed by GitHub
parent 20b92ea0ca
commit 6398570bcc
8 changed files with 89 additions and 50 deletions
+16 -7
View File
@@ -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<NotebookButton>();
auto *settingsBtn = this->addCustomButton<SvgButton>(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<NotebookButton>();
auto *userBtn = this->addCustomButton<SvgButton>(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()));
});
-42
View File
@@ -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:;
}
}
+4 -1
View File
@@ -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);