diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -70,15 +70,28 @@ * * large * * huge * * enormous - * - * Not devicePixelRation-adjusted:: - * * desktop + * * desktop (DEPRECATED: use iconSizeHints instead) * */ - //note the iconSizeChanges signal indicates that one (or more) of these icons have changed + //note the iconSizeChanged signal indicates that one (or more) of these icons have changed //but the property map itself remains constant Q_PROPERTY(QQmlPropertyMap *iconSizes READ iconSizes CONSTANT) + /** + * units.iconSizeHints provides access to user-configurable icon size hints, + * to be used where appropriate in the user interface. + * + * Conceptually, an icon size hint is a key that has one of the sizes from + * @iconSizes property as value. + * + * Currently available hints: + * * panel + * * desktop + */ + //note the iconSizeHintsChanged signal indicates that one (or more) of these icons have changed + //but the property map itself remains constant + Q_PROPERTY(QQmlPropertyMap *iconSizeHints READ iconSizeHints CONSTANT) + // layout hints /** @@ -144,6 +157,12 @@ QQmlPropertyMap *iconSizes() const; /** + * @return map with user-configurable icon size hints, indexed by name + * @since 5.33 + */ + QQmlPropertyMap *iconSizeHints() const; + + /** * @return Pixel value for large spacing between elements. * @since 5.0 */ @@ -180,6 +199,7 @@ void devicePixelRatioChanged(); void gridUnitChanged(); void iconSizesChanged(); + void iconSizeHintsChanged(); void spacingChanged(); void durationChanged(); @@ -206,6 +226,7 @@ qreal m_devicePixelRatio; QQmlPropertyMap *m_iconSizes; + QQmlPropertyMap *m_iconSizeHints; static SharedAppFilter *s_sharedAppFilter; int m_smallSpacing; diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -72,6 +72,7 @@ } m_iconSizes = new QQmlPropertyMap(this); + m_iconSizeHints = new QQmlPropertyMap(this); updateDevicePixelRatio(); // also updates icon sizes updateSpacing(); // updates gridUnit and *Spacing properties @@ -135,14 +136,23 @@ m_iconSizes->insert(QStringLiteral("huge"), devicePixelIconSize(KIconLoader::SizeHuge)); m_iconSizes->insert(QStringLiteral("enormous"), devicePixelIconSize(KIconLoader::SizeEnormous)); + m_iconSizeHints->insert(QStringLiteral("panel"), devicePixelIconSize(KIconLoader::global()->currentSize(KIconLoader::Panel))); + m_iconSizeHints->insert(QStringLiteral("desktop"), devicePixelIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop))); + emit iconSizesChanged(); + emit iconSizeHintsChanged(); } QQmlPropertyMap *Units::iconSizes() const { return m_iconSizes; } +QQmlPropertyMap *Units::iconSizeHints() const +{ + return m_iconSizeHints; +} + int Units::roundToIconSize(int size) { /*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*/