Gui: add overloaded method pixmapFromSvg() to pass the device pixel ratio of a widget

This commit is contained in:
wmayer
2024-03-27 10:29:48 +01:00
committed by wwmayer
parent 7f2bb822d8
commit 7256e1c827
2 changed files with 24 additions and 4 deletions

View File

@@ -285,7 +285,7 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const
}
QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size,
const std::map<unsigned long, unsigned long>& colorMapping) const
const ColorMap& colorMapping) const
{
// If an absolute path is given
QPixmap icon;
@@ -321,8 +321,18 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size,
return icon;
}
QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size, qreal dpr,
const ColorMap& colorMapping) const
{
qreal width = size.width() * dpr;
qreal height = size.height() * dpr;
QPixmap px(pixmapFromSvg(name, QSizeF(width, height), colorMapping));
px.setDevicePixelRatio(dpr);
return px;
}
QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, const QSizeF& size,
const std::map<unsigned long, unsigned long>& colorMapping) const
const ColorMap& colorMapping) const
{
QString stringContents = QString::fromUtf8(originalContents);
for ( const auto &colorToColor : colorMapping ) {