diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index c7a7fc567..4f3d5d63f 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -34,6 +34,7 @@ #include "fadingnode_p.h" #include "svgtexturenode.h" +#include "units.h" IconItem::IconItem(QQuickItem *parent) : QQuickItem(parent), @@ -238,7 +239,7 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update animatingNode->setProgress(m_animValue); if (m_sizeChanged) { - const int iconSize = adjustedSize(qMin(boundingRect().size().width(), boundingRect().size().height())); + const int iconSize = Units::roundToIconSize(qMin(boundingRect().size().width(), boundingRect().size().height())); const QRect destRect(QPointF(boundingRect().center() - QPointF(iconSize/2, iconSize/2)).toPoint(), QSize(iconSize, iconSize)); @@ -259,7 +260,7 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update } if (m_sizeChanged) { - const int iconSize = adjustedSize(qMin(boundingRect().size().width(), boundingRect().size().height())); + const int iconSize = Units::roundToIconSize(qMin(boundingRect().size().width(), boundingRect().size().height())); const QRect destRect(QPointF(boundingRect().center() - QPointF(iconSize/2, iconSize/2)).toPoint(), QSize(iconSize, iconSize)); @@ -283,38 +284,9 @@ void IconItem::animationFinished() update(); } -int IconItem::adjustedSize(int size) -{ - if (m_svgIcon) { - m_svgIcon->resize(); - } - - if (m_svgIcon && - size > KIconLoader::SizeSmallMedium && - size < KIconLoader::SizeMedium && - m_svgIcon->elementSize(m_source.toString()).width() > KIconLoader::SizeSmallMedium && - m_svgIcon->elementSize(m_source.toString()).width() < KIconLoader::SizeMedium) { - return m_svgIcon->elementSize(m_source.toString()).width(); - } else if (size < KIconLoader::SizeSmall) { - //do nothing - return size; - } else if (size < KIconLoader::SizeSmallMedium) { - return KIconLoader::SizeSmall; - } else if (size < KIconLoader::SizeMedium) { - return KIconLoader::SizeSmallMedium; - } else if (size < KIconLoader::SizeLarge) { - return KIconLoader::SizeMedium; - } else if (size < KIconLoader::SizeHuge) { - return KIconLoader::SizeLarge; - //if size is more than 64, leave as is - } - - return size; -} - void IconItem::loadPixmap() { - const int size = adjustedSize(qMin(width(), height())); + const int size = Units::roundToIconSize(qMin(width(), height())); //final pixmap to paint QPixmap result; diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 77c55306d..8aecd1737 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -82,7 +82,6 @@ private Q_SLOTS: void valueChanged(const QVariant &value); private: - int adjustedSize(int size); //all the ways we can set an source. Only one of them will be valid QIcon m_icon; Plasma::Svg *m_svgIcon; diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index bd2a503b8..dfc817af2 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -104,18 +104,24 @@ QQmlPropertyMap *Units::iconSizes() const return m_iconSizes; } -int Units::roundToIconSize(int size) const +int Units::roundToIconSize(int size) { - if (size < devicePixelIconSize(KIconLoader::SizeSmall)) { - return devicePixelIconSize(KIconLoader::SizeSmall/2); - } else if (size < devicePixelIconSize(KIconLoader::SizeSmallMedium)) { - return devicePixelIconSize(KIconLoader::SizeSmall); - } else if (size < devicePixelIconSize(KIconLoader::SizeMedium)) { - return devicePixelIconSize(KIconLoader::SizeSmallMedium); - } else if (size < devicePixelIconSize(KIconLoader::SizeLarge)) { - return devicePixelIconSize(KIconLoader::SizeMedium); - } else if (size < devicePixelIconSize(KIconLoader::SizeEnormous)) { - return devicePixelIconSize(KIconLoader::SizeHuge); + /*Do *not* use devicePixelIconSize here, we want to use the sizes of the pixmaps of the smallest icons on the disk. And those are unaffected by dpi*/ + if (size < KIconLoader::SizeSmall) { + return KIconLoader::SizeSmall/2; + + } else if (size < KIconLoader::SizeSmallMedium) { + return KIconLoader::SizeSmall; + + } else if (size < KIconLoader::SizeMedium) { + return KIconLoader::SizeSmallMedium; + + } else if (size < KIconLoader::SizeLarge) { + return KIconLoader::SizeMedium; + + } else if (size < KIconLoader::SizeHuge) { + return KIconLoader::SizeLarge; + } else { return size; } diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h index f73e54107..e1d9bde78 100644 --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -128,7 +128,7 @@ public: * @param int size the size we want to be rounded down * @see iconSizes */ - Q_INVOKABLE int roundToIconSize(int size) const; + Q_INVOKABLE static int roundToIconSize(int size); /** * @return Pixel value for large spacing between elements.