fix: emote button is now rendered smoothlier (#6080)

This commit is contained in:
pajlada
2025-03-15 13:46:11 +01:00
committed by GitHub
parent 6cdd28c7d4
commit 95eee28002
5 changed files with 38 additions and 12 deletions
+21 -1
View File
@@ -76,6 +76,20 @@ void Button::setPixmap(const QPixmap &_pixmap)
this->update();
}
void Button::setSvgResource(const QString &resourcePath)
{
if (resourcePath == this->svgResourcePath)
{
// Same resource path as before - nothing changed
return;
}
this->svgRenderer = new QSvgRenderer(resourcePath, this);
this->svgResourcePath = resourcePath;
this->update();
}
const QPixmap &Button::getPixmap() const
{
return this->pixmap_;
@@ -176,7 +190,13 @@ void Button::paintButton(QPainter &painter)
{
painter.setRenderHint(QPainter::SmoothPixmapTransform);
if (!this->pixmap_.isNull())
if (this->svgRenderer != nullptr)
{
painter.setOpacity(this->getCurrentDimAmount());
this->svgRenderer->render(&painter);
}
else if (!this->pixmap_.isNull())
{
painter.setOpacity(this->getCurrentDimAmount());
+4
View File
@@ -6,6 +6,7 @@
#include <QMouseEvent>
#include <QPainter>
#include <QPoint>
#include <QSvgRenderer>
#include <QTimer>
#include <QWidget>
@@ -34,6 +35,7 @@ public:
void setMouseEffectColor(std::optional<QColor> color);
void setPixmap(const QPixmap &pixmap_);
void setSvgResource(const QString &resourcePath);
const QPixmap &getPixmap() const;
void setDim(Dim value);
@@ -88,6 +90,8 @@ private:
QColor borderColor_{};
QPixmap pixmap_{};
QSvgRenderer *svgRenderer{};
QString svgResourcePath;
QPixmap resizedPixmap_{};
Dim dimPixmap_{Dim::Some};
bool enableMargin_{true};