cc, dash: load grid edit chrome only in edit mode

port 2.0
This commit is contained in:
bbedward committed 2026-10-29 11:10:38 -04:00
1 parent c13ffb530a
commit 012237a1ad
5 files changed
+74 -53

No files matched your search

@@ -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
@@ -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
@@ -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)
}
}
+19 -15
View File
@@ -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()
}
}
}
}
@@ -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()
}
}
}