From 8789c9c2a847d2e1c83b8de7b915cf9888e68937 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niccol=C3=B2=20Venerandi?= <niccolo@venerandi.com>
Date: Thu, 7 Nov 2024 13:30:27 +0000
Subject: [PATCH] Fill panel width/height in custom/fit content modes when
 flexible spacer is in panel
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The flexible spacer should always make the panel gain its maximum
width/height; this implements that.

BUG:495378


(cherry picked from commit 7d2e16b09d391b7bc979e447d21bc8747399c55d)

Co-authored-by: Niccolò Venerandi <niccolo@venerandi.com>
---
 containments/panel/contents/ui/main.qml |  6 ++++++
 desktoppackage/contents/views/Panel.qml | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/containments/panel/contents/ui/main.qml b/containments/panel/contents/ui/main.qml
index 2570f9f520..e69131d6a6 100644
--- a/containments/panel/contents/ui/main.qml
+++ b/containments/panel/contents/ui/main.qml
@@ -26,6 +26,12 @@ ContainmentItem {
 //BEGIN properties
     Layout.preferredWidth: fixedWidth || currentLayout.implicitWidth + currentLayout.horizontalDisplacement
     Layout.preferredHeight: fixedHeight || currentLayout.implicitHeight + currentLayout.verticalDisplacement
+    Layout.fillWidth: {
+        return currentLayout.children
+            .filter(child => child?.applet?.plasmoid?.pluginName === "org.kde.plasma.panelspacer")
+            .some(child => child.applet.plasmoid.configuration.expanding)
+    }
+    Layout.fillHeight: Layout.fillWidth
 
     property Item toolBox
     property var layoutManager: LayoutManager
diff --git a/desktoppackage/contents/views/Panel.qml b/desktoppackage/contents/views/Panel.qml
index 2083123282..a4fab11699 100644
--- a/desktoppackage/contents/views/Panel.qml
+++ b/desktoppackage/contents/views/Panel.qml
@@ -275,8 +275,22 @@ Item {
                 return;
             }
             if (verticalPanel) {
+                if (containment.Layout.fillHeight) {
+                    if (panel.lengthMode == Panel.Global.Custom) {
+                        return panel.maximumHeight
+                    } else {
+                        return panel.screenGeometry.height
+                    }
+                }
                 return containment.Layout.preferredHeight
             } else {
+                if (containment.Layout.fillWidth) {
+                    if (panel.lengthMode == Panel.Global.Custom) {
+                        return panel.maximumWidth
+                    } else {
+                        return panel.screenGeometry.width
+                    }
+                }
                 return containment.Layout.preferredWidth
             }
         }
-- 
GitLab

