Commit b382f61c authored by Martin Seher's avatar Martin Seher Committed by Nate Graham
Browse files

applets/panelspacer: Fix optimal size calculation

Get rid of the delayed optimal size calculation caused by Qt.callLater
and calculate optimal size immediately when an applet's size changes.
This removes the unnecessary jumping of applets that are centered between 2
spacers.

BUG: 431668
FIXED-IN: 5.24.2


(cherry picked from commit 5824e636)
parent 4fa725ef
Pipeline #140624 passed with stage
in 10 minutes and 54 seconds
......@@ -55,12 +55,9 @@ Item {
plasmoid.removeAction("configure");
}
property real leftItemsSizeHint: 0
property real rightItemsSizeHint: 0
property real middleItemsSizeHint: {
// Every time this binding gets reevaluated we want to queue a recomputation of the size hints
Qt.callLater(root.updateHints)
if (!twinSpacer || !panelLayout || !leftTwin || !rightTwin) {
optimalSize = horizontal ? plasmoid.nativeInterface.containment.width : plasmoid.nativeInterface.containment.height;
return 0;
}
......@@ -105,8 +102,13 @@ Item {
}
}
rightItemsSizeHint = rightItemsHint;
leftItemsSizeHint = leftItemsHint;
var halfContainment = root.horizontal ?plasmoid.nativeInterface.containment.width/2 : plasmoid.nativeInterface.containment.height/2;
if (leftTwin == plasmoid) {
optimalSize = Math.max(PlasmaCore.Units.smallSpacing, halfContainment - middleItemsHint/2 - leftItemsHint)
} else {
optimalSize = Math.max(PlasmaCore.Units.smallSpacing, halfContainment - middleItemsHint/2 - rightItemsHint)
}
return middleItemsHint;
}
......@@ -134,22 +136,6 @@ Item {
}
}
function updateHints() {
if (!twinSpacer || !panelLayout || !leftTwin || !rightTwin) {
root.optimalSize = root.horizontal ? plasmoid.nativeInterface.containment.width : plasmoid.nativeInterface.containment.height;
return;
}
var halfContainment = root.horizontal ?plasmoid.nativeInterface.containment.width/2 : plasmoid.nativeInterface.containment.height/2;
if (leftTwin == plasmoid) {
root.optimalSize = Math.max(PlasmaCore.Units.smallSpacing, halfContainment - middleItemsSizeHint/2 - leftItemsSizeHint)
} else {
root.optimalSize = Math.max(PlasmaCore.Units.smallSpacing, halfContainment - middleItemsSizeHint/2 - rightItemsSizeHint)
}
}
Rectangle {
anchors.fill: parent
color: PlasmaCore.Theme.highlightColor
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment