From 012237a1ad3df39131ed0d836d1fe06f4238acec Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 29 Oct 2026 11:10:18 -0400 Subject: [PATCH] cc, dash: load grid edit chrome only in edit mode port 2.0 --- .../Modules/ControlCenter/CcMetrics.qml | 3 + .../ControlCenter/Components/CcEditChrome.qml | 2 +- .../ControlCenter/Components/CcTileSlot.qml | 56 +++++++++++-------- quickshell/Modules/DDash/DashWidgetGrid.qml | 34 ++++++----- .../Modules/DDash/Overview/DashCardSlot.qml | 32 ++++++----- 5 files changed, 74 insertions(+), 53 deletions(-) diff --git a/quickshell/Modules/ControlCenter/CcMetrics.qml b/quickshell/Modules/ControlCenter/CcMetrics.qml index a565cf5a5..3c36f1e86 100644 --- a/quickshell/Modules/ControlCenter/CcMetrics.qml +++ b/quickshell/Modules/ControlCenter/CcMetrics.qml @@ -89,6 +89,9 @@ Singleton { // The resize corner counts a small tile as this many rows and snaps to the nearer of this and a full row. readonly property real smallRowFraction: 0.5 readonly property real shapeButtonSize: Theme.iconSize + readonly property real editChromeButtonSize: Theme.iconSize + // Mirrors DGridEditChrome.contentInset so the options menu anchor keeps the chrome's bounds while the chrome is unloaded. + readonly property real editChromeInset: Math.max(Theme.minimumTouchTargetSize, editChromeButtonSize) / 2 readonly property real detailDialogPadding: Theme.spacingS readonly property real detailHeaderHeight: Theme.iconButtonSize diff --git a/quickshell/Modules/ControlCenter/Components/CcEditChrome.qml b/quickshell/Modules/ControlCenter/Components/CcEditChrome.qml index 148994196..8f363f4c5 100644 --- a/quickshell/Modules/ControlCenter/Components/CcEditChrome.qml +++ b/quickshell/Modules/ControlCenter/Components/CcEditChrome.qml @@ -14,7 +14,7 @@ DGridEditChrome { hasOptions: WidgetUtils.hasOptions(widgetData.id) removable: WidgetUtils.isRemovable(widgetData) removeIcon: "remove" - buttonSize: Theme.iconSize + buttonSize: CcMetrics.editChromeButtonSize hitOverflow: CcMetrics.gridGap / 2 iconSize: PopoutMetrics.chromeIconSize diff --git a/quickshell/Modules/ControlCenter/Components/CcTileSlot.qml b/quickshell/Modules/ControlCenter/Components/CcTileSlot.qml index f3652c5a1..0659dc0bf 100644 --- a/quickshell/Modules/ControlCenter/Components/CcTileSlot.qml +++ b/quickshell/Modules/ControlCenter/Components/CcTileSlot.qml @@ -73,9 +73,9 @@ DEditableGridSlot { } onPressAndHold: { - if (!editChrome.hasOptions) + if (!WidgetUtils.hasOptions(widgetData.id)) return; - root.grid.configRequested(root.grid.savedIndex(root.index), root.widgetData, editChrome); + root.grid.configRequested(root.grid.savedIndex(root.index), root.widgetData, chromeBounds); } onResizeRequested: (requestedWidth, requestedHeight) => { @@ -117,30 +117,40 @@ DEditableGridSlot { small: root.small } - CcEditChrome { - id: editChrome + Item { + id: chromeBounds anchors.fill: parent - anchors.margins: -contentInset - anchors.topMargin: -contentInset + root.bodyInset - anchors.bottomMargin: -contentInset + root.bodyInset + anchors.margins: -CcMetrics.editChromeInset + anchors.topMargin: -CcMetrics.editChromeInset + root.bodyInset + anchors.bottomMargin: -CcMetrics.editChromeInset + root.bodyInset + } + + Loader { + id: editChromeLoader + + anchors.fill: chromeBounds z: 2 - visible: root.grid.editMode - enabled: root.interactionEnabled - widgetData: root.widgetData - passthrough: root.passthrough - dragging: root.dragging - resizing: root.resizing - cornerRadius: root.small ? CcMetrics.pillRadius(root.width, root.height - root.bodyInset * 2) : (root.tileItem?.bodyRadius ?? CcMetrics.pillRadius(root.width, root.height)) - sizeText: root.cols + "×" + (root.small ? CcMetrics.smallRowFraction : root.rows) - onResizeStarted: (px, py) => { - root.biasH = root.small ? CcMetrics.smallRowFraction * root.grid.cellWidth - CcMetrics.gridGap - root.height : 0; - root.beginResize(px, py); + active: root.grid.editMode || root.resizing + + sourceComponent: CcEditChrome { + visible: root.grid.editMode + enabled: root.interactionEnabled + widgetData: root.widgetData + passthrough: root.passthrough + dragging: root.dragging + resizing: root.resizing + cornerRadius: root.small ? CcMetrics.pillRadius(root.width, root.height - root.bodyInset * 2) : (root.tileItem?.bodyRadius ?? CcMetrics.pillRadius(root.width, root.height)) + sizeText: root.cols + "×" + (root.small ? CcMetrics.smallRowFraction : root.rows) + onResizeStarted: (px, py) => { + root.biasH = root.small ? CcMetrics.smallRowFraction * root.grid.cellWidth - CcMetrics.gridGap - root.height : 0; + root.beginResize(px, py); + } + onResizeMoved: (px, py) => root.resizeTo(px, py) + onResizeEnded: root.finishResize() + onResizeCanceled: root.cancelResize() + onRemoveRequested: root.grid.removeWidget(root.grid.savedIndex(root.index)) + onConfigRequested: anchor => root.grid.configRequested(root.grid.savedIndex(root.index), root.widgetData, anchor) } - onResizeMoved: (px, py) => root.resizeTo(px, py) - onResizeEnded: root.finishResize() - onResizeCanceled: root.cancelResize() - onRemoveRequested: root.grid.removeWidget(root.grid.savedIndex(root.index)) - onConfigRequested: anchor => root.grid.configRequested(root.grid.savedIndex(root.index), root.widgetData, anchor) } } diff --git a/quickshell/Modules/DDash/DashWidgetGrid.qml b/quickshell/Modules/DDash/DashWidgetGrid.qml index 93d3bd4fa..d280c2162 100644 --- a/quickshell/Modules/DDash/DashWidgetGrid.qml +++ b/quickshell/Modules/DDash/DashWidgetGrid.qml @@ -173,23 +173,27 @@ Item { } } - DashEditChrome { + Loader { anchors.fill: parent - anchors.margins: -contentInset + anchors.margins: -PopoutMetrics.editOverflow z: 2 - visible: root.editMode - enabled: slot.interactionEnabled - cornerRadius: root.cardRadius - dragging: slot.dragging - resizing: slot.resizing - hasOptions: WidgetUtils.optionSpecs(slot.spec).length > 0 - sizeText: (grid.sizePreview?.index === slot.index ? grid.sizePreview.changes.w : slot.widget.w) + "×" + (grid.sizePreview?.index === slot.index ? grid.sizePreview.changes.h : slot.widget.h) - onRemoveRequested: root.save(root.widgets.filter((w, i) => i !== slot.index)) - onOptionsRequested: optionsSheet.presentFor(slot.widget.id) - onResizeStarted: (px, py) => slot.beginResize(px, py) - onResizeMoved: (px, py) => slot.resizeTo(px, py) - onResizeEnded: slot.finishResize() - onResizeCanceled: slot.cancelResize() + active: root.editMode || slot.resizing + + sourceComponent: DashEditChrome { + visible: root.editMode + enabled: slot.interactionEnabled + cornerRadius: root.cardRadius + dragging: slot.dragging + resizing: slot.resizing + hasOptions: WidgetUtils.optionSpecs(slot.spec).length > 0 + sizeText: (grid.sizePreview?.index === slot.index ? grid.sizePreview.changes.w : slot.widget.w) + "×" + (grid.sizePreview?.index === slot.index ? grid.sizePreview.changes.h : slot.widget.h) + onRemoveRequested: root.save(root.widgets.filter((w, i) => i !== slot.index)) + onOptionsRequested: optionsSheet.presentFor(slot.widget.id) + onResizeStarted: (px, py) => slot.beginResize(px, py) + onResizeMoved: (px, py) => slot.resizeTo(px, py) + onResizeEnded: slot.finishResize() + onResizeCanceled: slot.cancelResize() + } } } } diff --git a/quickshell/Modules/DDash/Overview/DashCardSlot.qml b/quickshell/Modules/DDash/Overview/DashCardSlot.qml index 209d7c8bd..a2bf32d30 100644 --- a/quickshell/Modules/DDash/Overview/DashCardSlot.qml +++ b/quickshell/Modules/DDash/Overview/DashCardSlot.qml @@ -137,21 +137,25 @@ DEditableGridSlot { visible: cardLoader.status === Loader.Loading } - DashEditChrome { + Loader { anchors.fill: parent - anchors.margins: -contentInset + anchors.margins: -PopoutMetrics.editOverflow z: 2 - visible: root.grid.editMode - enabled: root.interactionEnabled - sizeText: root.previewW + "×" + root.previewH - dragging: root.dragging - resizing: root.resizing - hasOptions: DashRegistry.hasOptions(root.cardId) - onOptionsRequested: root.grid.optionsRequested(root.cardId) - onRemoveRequested: CardUtils.removeCard(root.index) - onResizeStarted: (px, py) => root.startResize(px, py) - onResizeCanceled: root.cancelResize() - onResizeMoved: (px, py) => root.resizeTo(px, py) - onResizeEnded: root.finishResize() + active: root.grid.editMode || root.resizing + + sourceComponent: DashEditChrome { + visible: root.grid.editMode + enabled: root.interactionEnabled + sizeText: root.previewW + "×" + root.previewH + dragging: root.dragging + resizing: root.resizing + hasOptions: DashRegistry.hasOptions(root.cardId) + onOptionsRequested: root.grid.optionsRequested(root.cardId) + onRemoveRequested: CardUtils.removeCard(root.index) + onResizeStarted: (px, py) => root.startResize(px, py) + onResizeCanceled: root.cancelResize() + onResizeMoved: (px, py) => root.resizeTo(px, py) + onResizeEnded: root.finishResize() + } } }