Allow associating a paint device with the renderer for device-pixel-ratio

This commit is contained in:
Martchus 2024-02-22 00:43:22 +01:00
parent ce8e535d0e
commit 44776c210e
2 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include <QHash>
#include <QIcon>
#include <QPainter>
#include <QPaintDevice>
/// \brief Contains classes provided by the QtForkAwesome library.
namespace QtForkAwesome {
@ -58,11 +59,13 @@ struct Renderer::InternalData {
int id;
QStringList fontFamilies;
QHash<QChar, IconOverride> 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).
*/

View File

@ -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();