introduce roundToIconSize(int size)
return a size rounded tothe nearest inferior standard icon size. sizes larger than iconSizes.huge, it will be returned unmodified Reviewed by: Kai Uwe Broulik <kde@privat.broulik.de> Change-Id: I85c575ea1cc7965ae9bede9e5a8b7b4cb342580e
This commit is contained in:
parent
cd8c134578
commit
b98fdd7753
@ -104,6 +104,23 @@ QQmlPropertyMap *Units::iconSizes() const
|
|||||||
return m_iconSizes;
|
return m_iconSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Units::roundToIconSize(int size) const
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Units::devicePixelIconSize(const int size) const
|
int Units::devicePixelIconSize(const int size) const
|
||||||
{
|
{
|
||||||
/* in kiconloader.h
|
/* in kiconloader.h
|
||||||
|
@ -122,6 +122,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
QQmlPropertyMap *iconSizes() const;
|
QQmlPropertyMap *iconSizes() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a size rounded tothe nearest inferior standard icon size.
|
||||||
|
* sizes larger than iconSizes.huge, it will be returned unmodified
|
||||||
|
* @param int size the size we want to be rounded down
|
||||||
|
* @see iconSizes
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE int roundToIconSize(int size) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Pixel value for large spacing between elements.
|
* @return Pixel value for large spacing between elements.
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user