diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -227,7 +227,7 @@ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; - + void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & data) override; protected: void classBegin() Q_DECL_OVERRIDE; diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -612,15 +612,16 @@ void FrameSvgItem::updateDevicePixelRatio() { + m_frameSvg->setScaleFactor(qMax(1.0, floor(Units::instance().devicePixelRatio()))); + //devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned) - if (window()) { - m_frameSvg->setDevicePixelRatio(qMax(1.0, floor(window()->devicePixelRatio()))); - } else { - m_frameSvg->setDevicePixelRatio(qMax(1.0, floor(qApp->devicePixelRatio()))); + const auto newDevicePixelRation = qMax(1.0, floor(window() ? window()->devicePixelRatio() : qApp->devicePixelRatio())); + + if (newDevicePixelRation != m_frameSvg->devicePixelRatio()) { + m_frameSvg->setDevicePixelRatio(qMax(1.0, newDevicePixelRation)); + m_textureChanged = true; } - m_frameSvg->setScaleFactor(qMax(1.0, floor(Units::instance().devicePixelRatio()))); - m_textureChanged = true; } void FrameSvgItem::applyPrefixes() @@ -657,5 +658,14 @@ } } +void FrameSvgItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & value) +{ + if (change == ItemSceneChange && value.window) { + updateDevicePixelRatio(); + } + + QQuickItem::itemChange(change, value); +} + } // Plasma namespace diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -563,6 +563,7 @@ update(); return; } else if (m_svgIcon) { + m_svgIcon->setDevicePixelRatio(window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()); m_svgIcon->resize(size, size); if (!m_svgIconName.isEmpty() && m_svgIcon->hasElement(m_svgIconName)) { result = m_svgIcon->pixmap(m_svgIconName);