From 1ee42506b690300577e515cb4b7a65b88b15b3fa Mon Sep 17 00:00:00 2001 From: purian23 Date: Tue, 2 Jun 2026 15:48:47 -0400 Subject: [PATCH] refactor(control-center): consolidate detail section height rules --- .../ControlCenter/Components/DetailHost.qml | 19 ------------------- .../ControlCenter/Components/DragDropGrid.qml | 16 ++-------------- .../ControlCenter/utils/detailHeight.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 33 deletions(-) create mode 100644 quickshell/Modules/ControlCenter/utils/detailHeight.js diff --git a/quickshell/Modules/ControlCenter/Components/DetailHost.qml b/quickshell/Modules/ControlCenter/Components/DetailHost.qml index 45b083fb..5013d110 100644 --- a/quickshell/Modules/ControlCenter/Components/DetailHost.qml +++ b/quickshell/Modules/ControlCenter/Components/DetailHost.qml @@ -15,25 +15,6 @@ Item { property var pluginDetailInstance: null property var widgetModel: null property var collapseCallback: null - property real maxAvailableHeight: 9999 - - function getDetailHeight(section) { - switch (true) { - case section === "wifi": - case section === "bluetooth": - case section === "builtin_vpn": - case section === "builtin_tailscale": - return Math.min(350, maxAvailableHeight); - case section.startsWith("brightnessSlider_"): - return Math.min(400, maxAvailableHeight); - case section.startsWith("plugin_"): - if (pluginDetailInstance?.ccDetailHeight) - return Math.min(pluginDetailInstance.ccDetailHeight, maxAvailableHeight); - return Math.min(250, maxAvailableHeight); - default: - return Math.min(250, maxAvailableHeight); - } - } Loader { id: pluginDetailLoader diff --git a/quickshell/Modules/ControlCenter/Components/DragDropGrid.qml b/quickshell/Modules/ControlCenter/Components/DragDropGrid.qml index 7685157f..0e248125 100644 --- a/quickshell/Modules/ControlCenter/Components/DragDropGrid.qml +++ b/quickshell/Modules/ControlCenter/Components/DragDropGrid.qml @@ -3,6 +3,7 @@ import qs.Common import qs.Services import qs.Modules.ControlCenter.Widgets import qs.Modules.ControlCenter.Components +import "../utils/detailHeight.js" as DetailHeightUtils import "../utils/layout.js" as LayoutUtils Column { @@ -38,8 +39,6 @@ Column { property real currentRowWidth: 0 property int expandedRowIndex: -1 property var colorPickerModal: null - // Detail instance of the currently expanded plugin section, so the grid can - // honor its dynamic ccDetailHeight instead of a fixed slot size. property var activePluginDetailInstance: null readonly property real _maxDetailHeight: { @@ -76,17 +75,7 @@ Column { } function detailHeightForSection(section) { - if (!section) - return 0; - if (section === "wifi" || section === "bluetooth" || section === "builtin_vpn") - return Math.min(350, _maxDetailHeight); - if (section.startsWith("brightnessSlider_")) - return Math.min(400, _maxDetailHeight); - if (section.startsWith("plugin_")) { - const h = activePluginDetailInstance ? activePluginDetailInstance.ccDetailHeight : 0; - return Math.min(h > 0 ? h : 250, _maxDetailHeight); - } - return Math.min(250, _maxDetailHeight); + return DetailHeightUtils.detailHeightForSection(section, _maxDetailHeight, activePluginDetailInstance); } function calculateRowsAndWidgets() { @@ -226,7 +215,6 @@ Column { DetailHost { id: detailHost width: parent.width - maxAvailableHeight: root._maxDetailHeight height: active ? (root.detailHeightForSection(root.expandedSection) + Theme.spacingS) : 0 clip: true property string retainedSection: "" diff --git a/quickshell/Modules/ControlCenter/utils/detailHeight.js b/quickshell/Modules/ControlCenter/utils/detailHeight.js new file mode 100644 index 00000000..3a8e52ec --- /dev/null +++ b/quickshell/Modules/ControlCenter/utils/detailHeight.js @@ -0,0 +1,14 @@ +function detailHeightForSection(section, maxHeight, pluginInstance) { + if (!section) + return 0; + if (section === "wifi" || section === "bluetooth" + || section === "builtin_vpn" || section === "builtin_tailscale") + return Math.min(350, maxHeight); + if (section.startsWith("brightnessSlider_")) + return Math.min(400, maxHeight); + if (section.startsWith("plugin_")) { + const h = pluginInstance ? pluginInstance.ccDetailHeight : 0; + return Math.min(h > 0 ? h : 250, maxHeight); + } + return Math.min(250, maxHeight); +}