From 7c31ab635758401bd0e155f82538093577132d32 Mon Sep 17 00:00:00 2001 From: Alexander Kernozhitsky Date: Fri, 5 Aug 2022 13:00:09 +0000 Subject: [PATCH] Consider small icon size from system Before that, the values were hardcoded (i.e. 16 for non-tablet mode and 22 for tablet mode). Now, the value for non-tablet mode is taken from the system, and the value for tablet mode is one step bigger. BUG: 455513 FIXED-IN: 5.25.5 --- kstyle/breezestyle.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index 35216971..d8e018bc 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -529,13 +530,25 @@ int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWi return Metrics::MenuItem_HighlightGap; // small icon size - case PM_SmallIconSize: - if (isTabletMode()) { - return 22; - } else { - return 16; + case PM_SmallIconSize: { + auto iconSize = ParentStyleClass::pixelMetric(metric, option, widget); + if (!isTabletMode()) { + return iconSize; + } + + // in tablet mode, we try to figure out the next size and use it + // see bug 455513 + auto metaEnum = QMetaEnum::fromType(); + for (int i = 0; i + 1 < metaEnum.keyCount(); ++i) { + if (iconSize == metaEnum.value(i)) { + return metaEnum.value(i + 1); + } } + // size is either too large or unknown, just increase it by 50% + return iconSize * 3 / 2; + } + // frame width case PM_DefaultFrameWidth: if (qobject_cast(widget))