Skip to content

Commit

Permalink
fix: find and resize with containment
Browse files Browse the repository at this point in the history
Fixes expanding and slow resizing of panels in fit content mode

closes: #55
  • Loading branch information
luisbocanegra committed Oct 22, 2024
1 parent ea0c6e1 commit 1074478
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ PlasmoidItem {
return null;
}

property Item containment: {
let candidate = root.parent;
while (candidate) {
if (candidate.toString().indexOf("ContainmentItem_QML") > -1 ) {
return candidate;
}
candidate = candidate.parent;
}
return null
}

Plasmoid.contextualActions: [
PlasmaCore.Action {
text: i18n("Set flexible size")
Expand Down Expand Up @@ -384,8 +395,12 @@ PlasmoidItem {
sizeHints[sizeHints.length - 1] += Math.min(child.Layout.maximumHeight, Math.max(child.Layout.minimumHeight, child.Layout.preferredHeight)) + panelLayout.columnSpacing;
}
}
sizeHints[0] *= 2; sizeHints[sizeHints.length - 1] *= 2
let opt = (horizontal ? panelLayout.width : panelLayout.height) / expandingSpacers - sizeHints[thisSpacerIndex] / 2 - sizeHints[thisSpacerIndex + 1] / 2
sizeHints[0] *= 2;
sizeHints[sizeHints.length - 1] *= 2
let opt = 0
if (containment) {
opt = (root.horizontal ? containment.width : containment.height) / expandingSpacers - sizeHints[thisSpacerIndex] / 2 - sizeHints[thisSpacerIndex + 1] / 2
}
return Math.max(opt, 0)
}

Expand Down

0 comments on commit 1074478

Please sign in to comment.