1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-08 04:09:15 -04:00

feat(control-center): add DiskUsage widget config overlay with showMountPath toggle and standardized tile sizing (#2507)

* feat(control-center): add widget config overlay with showMountPath toggle for DiskUsage

Introduces WidgetConfigOverlay and DiskUsageWidgetConfigMenu components, allowing
users to toggle mount path visibility per DiskUsage widget in edit mode

* refactor(control-center): use Theme.iconSizeLarge and Theme.fontSizeLarge for small tiles

Standardize SmallDiskUsageButton and SmallBatteryButton sizing with Theme.iconSizeLarge
and Theme.fontSizeLarge, and unify font weight to Font.Bold on both tile widgets.

* fix(control-center): adjust SmallDiskUsageButton font size based on showMountPath

* refactor(control-center): simplify DiskUsage config menu i18n strings

Remove the redundant "Disk Usage Widget" title and the toggle description
to reduce translatable strings
This commit is contained in:
Guilherme Pagano
2026-06-01 12:35:14 -03:00
committed by GitHub
parent 12e43d120e
commit 3e4d2b4d46
12 changed files with 173 additions and 6 deletions
@@ -0,0 +1,38 @@
import QtQuick
import qs.Common
import qs.Widgets
Rectangle {
id: root
property var widgetData: null
signal showMountPathChanged(bool show)
width: 260
height: menuColumn.implicitHeight + Theme.spacingS * 2
radius: Theme.cornerRadius
color: Theme.surfaceContainer
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.16)
border.width: 1
MouseArea {
anchors.fill: parent
}
Column {
id: menuColumn
anchors.fill: parent
anchors.margins: Theme.spacingS
spacing: 2
DankToggle {
width: parent.width
text: I18n.tr("Show mount path", "toggle in control center disk usage widget to turn mount path display on or off")
checked: root.widgetData?.showMountPath !== false
onToggled: newChecked => {
root.showMountPathChanged(newChecked);
}
}
}
}
@@ -25,6 +25,7 @@ Column {
signal moveWidget(int fromIndex, int toIndex)
signal toggleWidgetSize(int index)
signal collapseRequested
signal configRequested(int index, var widgetData, var anchor)
function requestCollapse() {
collapseRequested();
@@ -203,6 +204,7 @@ Column {
onWidgetMoved: (fromIndex, toIndex) => root.moveWidget(fromIndex, toIndex)
onRemoveWidget: index => root.removeWidget(index)
onToggleWidgetSize: index => root.toggleWidgetSize(index)
onConfigRequested: (idx, data, anchor) => root.configRequested(idx, data, anchor)
}
}
}
@@ -869,6 +871,7 @@ Column {
mountPath: widgetData.mountPath || "/"
instanceId: widgetData.instanceId || ""
showMountPath: widgetData.showMountPath !== undefined ? widgetData.showMountPath : true
onExpandClicked: {
if (!root.editMode) {
@@ -888,6 +891,7 @@ Column {
mountPath: widgetData.mountPath || "/"
instanceId: widgetData.instanceId || ""
showMountPath: widgetData.showMountPath !== undefined ? widgetData.showMountPath : true
onClicked: {
if (!root.editMode) {
@@ -21,6 +21,7 @@ Item {
signal widgetMoved(int fromIndex, int toIndex)
signal removeWidget(int index)
signal toggleWidgetSize(int index)
signal configRequested(int index, var widgetData, var anchor)
width: {
const widgetWidth = widgetData?.width || 50;
@@ -236,6 +237,7 @@ Item {
}
Rectangle {
id: removeButton
width: 16
height: 16
radius: 8
@@ -278,6 +280,34 @@ Item {
}
}
readonly property bool hasConfigMenu: widgetData?.id === "diskUsage"
Rectangle {
id: configButton
width: 16
height: 16
radius: 8
color: Theme.primary
anchors.top: removeButton.top
anchors.right: removeButton.left
anchors.rightMargin: 4
visible: editMode && root.hasConfigMenu
z: 10
DankIcon {
anchors.centerIn: parent
name: "settings"
size: 12
color: Theme.primaryText
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: root.configRequested(root.widgetIndex, root.widgetData, configButton)
}
}
Rectangle {
id: dragHandle
width: 16
@@ -0,0 +1,77 @@
import QtQuick
import qs.Common
import qs.Services
Item {
id: root
property int widgetIndex: -1
property real anchorX: 0
property real anchorY: 0
property real anchorWidth: 0
property real anchorHeight: 0
readonly property var widgetData: {
if (widgetIndex < 0)
return null;
const widgets = SettingsData.controlCenterWidgets || [];
return widgets[widgetIndex] || null;
}
visible: widgetIndex >= 0
z: 10000
function open(index, data, anchorItem) {
const pos = anchorItem.mapToItem(root, 0, 0);
anchorX = pos.x;
anchorY = pos.y;
anchorWidth = anchorItem.width;
anchorHeight = anchorItem.height;
widgetIndex = index;
}
function close() {
widgetIndex = -1;
}
function persistShowMountPath(show) {
const widgets = (SettingsData.controlCenterWidgets || []).slice();
if (root.widgetIndex < 0 || root.widgetIndex >= widgets.length)
return;
const updated = Object.assign({}, widgets[root.widgetIndex]);
updated.showMountPath = show;
widgets[root.widgetIndex] = updated;
SettingsData.set("controlCenterWidgets", widgets);
}
MouseArea {
anchors.fill: parent
enabled: root.visible
onClicked: root.close()
}
DiskUsageWidgetConfigMenu {
id: diskMenu
visible: root.visible && root.widgetData?.id === "diskUsage"
widgetData: root.widgetData
x: {
let nx = root.anchorX + root.anchorWidth - width;
const maxX = root.width - width - Theme.spacingS;
const minX = Theme.spacingS;
if (nx < minX)
nx = minX;
if (nx > maxX)
nx = maxX;
return nx;
}
y: {
let ny = root.anchorY - height - Theme.spacingS;
if (ny < Theme.spacingS)
ny = root.anchorY + root.anchorHeight + Theme.spacingS;
return ny;
}
onShowMountPathChanged: show => root.persistShowMountPath(show)
}
}