From 44776c210e5980e4e768925321d35ec74dc2d7ce Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 22 Feb 2024 00:43:22 +0100 Subject: [PATCH] Allow associating a paint device with the renderer for device-pixel-ratio --- qtforkawesome/renderer.cpp | 12 ++++++++++++ qtforkawesome/renderer.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/qtforkawesome/renderer.cpp b/qtforkawesome/renderer.cpp index a8a83ab..2cf5aa6 100644 --- a/qtforkawesome/renderer.cpp +++ b/qtforkawesome/renderer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include /// \brief Contains classes provided by the QtForkAwesome library. namespace QtForkAwesome { @@ -58,11 +59,13 @@ struct Renderer::InternalData { int id; QStringList fontFamilies; QHash overrides; + QPaintDevice *paintDevice; }; Renderer::InternalData::InternalData(int id) : id(id) , fontFamilies(id != invalidId ? QFontDatabase::applicationFontFamilies(id) : QStringList()) + , paintDevice(nullptr) { } @@ -197,6 +200,15 @@ void Renderer::clearOverrides() m_d->overrides.clear(); } +/*! + * \brief Sets the associated \a paintDevice. + * \remarks The device-pixel-ratio of the specified device will be used when rendering pixmaps. + */ +void Renderer::setAssociatedPaintDevice(QPaintDevice *paintDevice) +{ + m_d->paintDevice = paintDevice; +} + /*! * \brief Returns the global instance (which is so far only used by the icon engine plugin). */ diff --git a/qtforkawesome/renderer.h b/qtforkawesome/renderer.h index 1928dfc..64529be 100644 --- a/qtforkawesome/renderer.h +++ b/qtforkawesome/renderer.h @@ -13,6 +13,7 @@ QT_FORWARD_DECLARE_CLASS(QColor) QT_FORWARD_DECLARE_CLASS(QPainter) QT_FORWARD_DECLARE_CLASS(QRect) QT_FORWARD_DECLARE_CLASS(QSize) +QT_FORWARD_DECLARE_CLASS(QPaintDevice) QT_FORWARD_DECLARE_CLASS(QPixmap) QT_FORWARD_DECLARE_CLASS(QIcon) @@ -37,6 +38,7 @@ public: void addThemeOverride(Icon icon, const QString &iconNameInTheme); void addOverride(QChar character, const QIcon &override); void addOverride(Icon icon, const QIcon &override); + void setAssociatedPaintDevice(QPaintDevice *paintDevice); void clearOverrides(); static Renderer &global();