feat(SvgButton): Allow custom color (#6268)

This commit is contained in:
pajlada
2025-06-29 13:27:37 +02:00
committed by GitHub
parent 89483e4c05
commit 03845bfbc6
3 changed files with 34 additions and 2 deletions
+11
View File
@@ -2,8 +2,11 @@
#include "widgets/buttons/Button.hpp"
#include <QColor>
#include <QString>
#include <optional>
class QSvgRenderer;
namespace chatterino {
@@ -41,6 +44,13 @@ public:
/// Setter for #source()
void setSource(Src source);
/// Sets a custom color to render over the SVG.
/// This allows you to change the color of a button to a solid color
/// of your choice without using multiple SVG resources.
///
/// Set to std::nullopt to not override the color.
void setColor(std::optional<QColor> color);
/// @brief Returns the padding inside the button.
///
/// `width` is the padding applied horizontally (left and right).
@@ -65,6 +75,7 @@ private:
Src source_;
QSvgRenderer *svg_;
QSize padding_;
std::optional<QColor> color_;
};
} // namespace chatterino