fix: emote button is now rendered smoothlier (#6080)
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user