https://bugs.kde.org/show_bug.cgi?id=454131

--- Comment #5 from Jin Liu <ad.liu....@gmail.com> ---
(In reply to Nate Graham from comment #4)
> Probably something here is incorrect:
> 
> 
> int Units::roundToIconSize(int size)
> {
>     // If not using Qt scaling (e.g. on X11 by default), manually scale all
> sizes
>     // according to the DPR because Qt hasn't done it for us. Otherwise all
>     // returned sizes are too small and icons are only the right size by pure
>     // chance for the larger sizes due to their large differences in size
>     qreal multiplier = 1.0;
>     QScreen *primary = QGuiApplication::primaryScreen();
>     if (primary) {
>         // Note that when using Qt scaling, the multiplier will always be 1
>         // because Qt will scale everything for us. This is good and
> intentional.
>         multiplier =
> bestIconScaleForDevicePixelRatio((qreal)primary->logicalDotsPerInchX() /
> (qreal)96);

Indeed.

This roundToIconSize function is used here:
https://github.com/KDE/plasma-framework/blob/b5f8095d96320bd14f724d6bb1da17e3d1dc8bbf/src/declarativeimports/core/units.cpp#L107
> void Units::iconLoaderSettingsChanged()
> {
>     m_iconSizes->insert(QStringLiteral("desktop"), 
> devicePixelIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop)));
> 
>     m_iconSizes->insert(QStringLiteral("tiny"), 
> devicePixelIconSize(KIconLoader::SizeSmall) / 2);
>     m_iconSizes->insert(QStringLiteral("small"), 
> devicePixelIconSize(KIconLoader::SizeSmall));
>     m_iconSizes->insert(QStringLiteral("smallMedium"), 
> devicePixelIconSize(KIconLoader::SizeSmallMedium));
>     m_iconSizes->insert(QStringLiteral("medium"), 
> devicePixelIconSize(KIconLoader::SizeMedium));
>     m_iconSizes->insert(QStringLiteral("large"), 
> devicePixelIconSize(KIconLoader::SizeLarge));
>     m_iconSizes->insert(QStringLiteral("huge"), 
> devicePixelIconSize(KIconLoader::SizeHuge));
>     m_iconSizes->insert(QStringLiteral("enormous"), 
> devicePixelIconSize(KIconLoader::SizeEnormous));
>     // gridUnit is always the font height here
>     m_iconSizes->insert(QStringLiteral("sizeForLabels"), 
> devicePixelIconSize(roundToIconSize(QFontMetrics(QGuiApplication::font()).height())));
> 
>     m_iconSizeHints->insert(QStringLiteral("panel"), 
> devicePixelIconSize(KIconLoader::global()->currentSize(KIconLoader::Panel)));
>     m_iconSizeHints->insert(QStringLiteral("desktop"), 
> devicePixelIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop)));

Note all these sizes are passed to devicePixelIconSize(), which is:
https://github.com/KDE/plasma-framework/blob/b5f8095d96320bd14f724d6bb1da17e3d1dc8bbf/src/declarativeimports/core/units.cpp#L194
> int Units::devicePixelIconSize(const int size) const
> {
>     /* in kiconloader.h
>     enum StdSizes {
>         SizeSmall=16,
>         SizeSmallMedium=22,
>         SizeMedium=32,
>         SizeLarge=48,
>         SizeHuge=64,
>         SizeEnormous=128
>     };
>     */
>     // Scale the icon sizes up using the devicePixelRatio
>     // This function returns the next stepping icon size
>     // and multiplies the global settings with the dpi ratio.
>     const qreal ratio = devicePixelRatio();
> 
>     return size * bestIconScaleForDevicePixelRatio(ratio);
> }

Note this function already multiplies its parameter by the zoom ratio. So
roundToIconSize(QFontMetrics(QGuiApplication::font()).height()) shouldn't use
the zoom ratio, otherwise the ratio is multiplied by twice.

However, roundToIconSize is called in many other places, e.g.
https://github.com/KDE/plasma-desktop/blob/48a0fc3719de3a87c394af905b16f8cedb9b6c08/applets/window-list/contents/ui/MenuButton.qml#L59
So I've no idea whether
A. Units::roundToIconSize should not multiply by zoom ratio, which affects
sizes all around Plasma.
B. The line
devicePixelIconSize(roundToIconSize(QFontMetrics(QGuiApplication::font()).height()))
should be changed to
roundToIconSize(QFontMetrics(QGuiApplication::font()).height()), which should
only affect sizeForLabels.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to