Verified Commit 142ee970 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/taskmanager: set width/height to 0 when there is no task

The panel code should allow zero size in `Layout.preferredWidth` and
`Layout.preferredHeight`, so the task manager can shrink its size to
zero.

BUG: 453102
FIXED-IN: 5.26
parent 1e522274
Pipeline #207267 passed with stage
in 2 minutes and 35 seconds
......@@ -25,6 +25,7 @@ MouseArea {
hoverEnabled: true
readonly property real devicePixelRatio: Screen.devicePixelRatio
readonly property bool shouldShirnkToZero: !LayoutManager.logicalTaskCount()
property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
property bool iconsOnly: plasmoid.pluginName === "org.kde.plasma.icontasks"
......@@ -48,12 +49,38 @@ MouseArea {
Layout.fillWidth: tasks.vertical ? true : plasmoid.configuration.fill
Layout.fillHeight: !tasks.vertical ? true : plasmoid.configuration.fill
Layout.minimumWidth: tasks.vertical ? 0 : LayoutManager.preferredMinWidth()
Layout.minimumHeight: !tasks.vertical ? 0 : LayoutManager.preferredMinHeight()
Layout.minimumWidth: {
if (shouldShirnkToZero) {
return PlasmaCore.Units.gridUnit; // For edit mode
}
return tasks.vertical ? 0 : LayoutManager.preferredMinWidth();
}
Layout.minimumHeight: {
if (shouldShirnkToZero) {
return PlasmaCore.Units.gridUnit; // For edit mode
}
return !tasks.vertical ? 0 : LayoutManager.preferredMinHeight();
}
//BEGIN TODO: this is not precise enough: launchers are smaller than full tasks
Layout.preferredWidth: tasks.vertical ? PlasmaCore.Units.gridUnit * 10 : ((LayoutManager.logicalTaskCount() * LayoutManager.preferredMaxWidth()) / LayoutManager.calculateStripes())
Layout.preferredHeight: tasks.vertical ? ((LayoutManager.logicalTaskCount() * LayoutManager.preferredMaxHeight()) / LayoutManager.calculateStripes()) : PlasmaCore.Units.gridUnit * 2
Layout.preferredWidth: {
if (shouldShirnkToZero) {
return 0.01;
}
if (tasks.vertical) {
return PlasmaCore.Units.gridUnit * 10;
}
return (LayoutManager.logicalTaskCount() * LayoutManager.preferredMaxWidth()) / LayoutManager.calculateStripes();
}
Layout.preferredHeight: {
if (shouldShirnkToZero) {
return 0.01;
}
if (tasks.vertical) {
return (LayoutManager.logicalTaskCount() * LayoutManager.preferredMaxHeight()) / LayoutManager.calculateStripes();
}
return PlasmaCore.Units.gridUnit * 2;
}
//END TODO
property Item dragSource: null
......@@ -406,8 +433,8 @@ MouseArea {
left: parent.left
top: parent.top
}
width: LayoutManager.layoutWidth()
height: LayoutManager.layoutHeight()
width: tasks.shouldShirnkToZero ? 0 : LayoutManager.layoutWidth()
height: tasks.shouldShirnkToZero ? 0 : LayoutManager.layoutHeight()
flow: {
if (tasks.vertical) {
......
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