From 95f86bed8f4d68d734c83b67aaa4fb49e1da44d9 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 3 Feb 2021 19:31:19 +0200 Subject: [PATCH] accept only odd numbers for iconSize and zoom --- .../contents/ui/abilities/ParabolicEffect.qml | 3 ++- .../ui/abilities/privates/MetricsPrivate.qml | 12 ++++++++++-- .../configuration/pages/AppearanceConfig.qml | 9 +++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/containment/package/contents/ui/abilities/ParabolicEffect.qml b/containment/package/contents/ui/abilities/ParabolicEffect.qml index a83997eb7..49865d911 100644 --- a/containment/package/contents/ui/abilities/ParabolicEffect.qml +++ b/containment/package/contents/ui/abilities/ParabolicEffect.qml @@ -31,7 +31,8 @@ Ability.ParabolicEffectPrivate { factor.zoom: { var storedZoom = LatteCore.WindowSystem.compositingActive && animations.active ? ( 1 + (plasmoid.configuration.zoomLevel / 20) ) : 1; var maxSize = storedZoom * metrics.iconSize; - maxSize = Math.round(maxSize); + //! round to nearest odd number + maxSize = 2 * Math.round(Math.round(maxSize) / 2); //! this way we make sure that the iconSize at the maximum of its parabolic effect is an integer return (maxSize/metrics.iconSize); diff --git a/containment/package/contents/ui/abilities/privates/MetricsPrivate.qml b/containment/package/contents/ui/abilities/privates/MetricsPrivate.qml index 407c8d9f3..926bbaba9 100644 --- a/containment/package/contents/ui/abilities/privates/MetricsPrivate.qml +++ b/containment/package/contents/ui/abilities/privates/MetricsPrivate.qml @@ -35,14 +35,22 @@ AbilityHost.Metrics { //! private properties to avoid too many not needed animation calculations readonly property int _iconSize: autosizeEnabled && autosize.iconSize > 0 ? Math.min(autosize.iconSize, maxIconSize) : maxIconSize - readonly property int _maxIconSize: portionIconSize!==-1 ? portionIconSize : plasmoid.configuration.iconSize + readonly property int _maxIconSize: { + //! round to nearest odd number + var storedIconSize = 2 * Math.round(plasmoid.configuration.iconSize / 2) + + return portionIconSize!==-1 ? portionIconSize : storedIconSize; + } //! Private Properties readonly property int portionIconSize: { //icon size based on screen height if ((plasmoid.configuration.proportionIconSize===-1) || !latteView) return -1; - return Math.max(16,Math.round(latteView.screenGeometry.height * plasmoid.configuration.proportionIconSize/100)); + var basedOnScreenHeight = Math.max(16,Math.round(latteView.screenGeometry.height * plasmoid.configuration.proportionIconSize/100)) + + //! round to nearest odd number + return 2 * Math.round(basedOnScreenHeight/2); } readonly property bool autosizeEnabled: autosize !== undefined && autosize.isActive diff --git a/shell/package/contents/configuration/pages/AppearanceConfig.qml b/shell/package/contents/configuration/pages/AppearanceConfig.qml index c199fcb56..82402be9d 100644 --- a/shell/package/contents/configuration/pages/AppearanceConfig.qml +++ b/shell/package/contents/configuration/pages/AppearanceConfig.qml @@ -84,16 +84,17 @@ PlasmaComponents.Page { LatteComponents.Slider { id: appletsSizeSlider Layout.fillWidth: true - value: plasmoid.configuration.iconSize + //!round to nearest odd number + value: 2 * Math.round(plasmoid.configuration.iconSize / 2) from: 16 to: 512 - stepSize: dialog.advancedLevel || (plasmoid.configuration.iconSize % 8 !== 0) || dialog.viewIsPanel ? 1 : 8 + stepSize: dialog.advancedLevel || (plasmoid.configuration.iconSize % 8 !== 0) || dialog.viewIsPanel ? 2 : 8 wheelEnabled: false function updateIconSize() { if (!pressed) { - plasmoid.configuration.iconSize = value - syncGeometry.restart() + plasmoid.configuration.iconSize = value; + syncGeometry.restart(); } }