1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-26 22:42:50 -05:00

Allow removing force-padding on monitor widgets + plugin load fixes

This commit is contained in:
bbedward
2025-10-06 11:32:25 -04:00
parent e24ddb804d
commit 11a1af89f4
10 changed files with 209 additions and 44 deletions

View File

@@ -263,6 +263,9 @@ Item {
if (widgetId === "diskUsage") {
widgetObj.mountPath = "/"
}
if (widgetId === "cpuUsage" || widgetId === "memUsage" || widgetId === "cpuTemp" || widgetId === "gpuTemp") {
widgetObj.minimumWidth = true
}
var widgets = []
if (targetSection === "left") {
@@ -509,6 +512,54 @@ Item {
}
}
function handleMinimumWidthChanged(sectionId, widgetIndex, enabled) {
var widgets = []
if (sectionId === "left")
widgets = SettingsData.dankBarLeftWidgets.slice()
else if (sectionId === "center")
widgets = SettingsData.dankBarCenterWidgets.slice()
else if (sectionId === "right")
widgets = SettingsData.dankBarRightWidgets.slice()
if (widgetIndex >= 0 && widgetIndex < widgets.length) {
var widget = widgets[widgetIndex]
if (typeof widget === "string") {
widgets[widgetIndex] = {
"id": widget,
"enabled": true,
"minimumWidth": enabled
}
} else {
var newWidget = {
"id": widget.id,
"enabled": widget.enabled,
"minimumWidth": enabled
}
if (widget.size !== undefined)
newWidget.size = widget.size
if (widget.selectedGpuIndex !== undefined)
newWidget.selectedGpuIndex = widget.selectedGpuIndex
if (widget.pciId !== undefined)
newWidget.pciId = widget.pciId
if (widget.mountPath !== undefined)
newWidget.mountPath = widget.mountPath
if (widget.id === "controlCenterButton") {
newWidget.showNetworkIcon = widget.showNetworkIcon !== undefined ? widget.showNetworkIcon : true
newWidget.showBluetoothIcon = widget.showBluetoothIcon !== undefined ? widget.showBluetoothIcon : true
newWidget.showAudioIcon = widget.showAudioIcon !== undefined ? widget.showAudioIcon : true
}
widgets[widgetIndex] = newWidget
}
}
if (sectionId === "left")
SettingsData.setDankBarLeftWidgets(widgets)
else if (sectionId === "center")
SettingsData.setDankBarCenterWidgets(widgets)
else if (sectionId === "right")
SettingsData.setDankBarRightWidgets(widgets)
}
function getItemsForSection(sectionId) {
var widgets = []
var widgetData = []
@@ -532,6 +583,7 @@ Item {
var widgetShowNetworkIcon = typeof widget === "string" ? undefined : widget.showNetworkIcon
var widgetShowBluetoothIcon = typeof widget === "string" ? undefined : widget.showBluetoothIcon
var widgetShowAudioIcon = typeof widget === "string" ? undefined : widget.showAudioIcon
var widgetMinimumWidth = typeof widget === "string" ? undefined : widget.minimumWidth
var widgetDef = baseWidgetDefinitions.find(w => {
return w.id === widgetId
})
@@ -552,6 +604,8 @@ Item {
item.showBluetoothIcon = widgetShowBluetoothIcon
if (widgetShowAudioIcon !== undefined)
item.showAudioIcon = widgetShowAudioIcon
if (widgetMinimumWidth !== undefined)
item.minimumWidth = widgetMinimumWidth
widgets.push(item)
}
@@ -1208,6 +1262,10 @@ Item {
dankBarTab.handleDiskMountSelectionChanged(
sectionId, widgetIndex, mountPath)
}
onMinimumWidthChanged: (sectionId, widgetIndex, enabled) => {
dankBarTab.handleMinimumWidthChanged(
sectionId, widgetIndex, enabled)
}
}
}
@@ -1280,6 +1338,10 @@ Item {
dankBarTab.handleDiskMountSelectionChanged(
sectionId, widgetIndex, mountPath)
}
onMinimumWidthChanged: (sectionId, widgetIndex, enabled) => {
dankBarTab.handleMinimumWidthChanged(
sectionId, widgetIndex, enabled)
}
}
}
@@ -1352,6 +1414,10 @@ Item {
dankBarTab.handleDiskMountSelectionChanged(
sectionId, widgetIndex, mountPath)
}
onMinimumWidthChanged: (sectionId, widgetIndex, enabled) => {
dankBarTab.handleMinimumWidthChanged(
sectionId, widgetIndex, enabled)
}
}
}
}

View File

@@ -22,6 +22,7 @@ Column {
signal gpuSelectionChanged(string sectionId, int widgetIndex, int selectedIndex)
signal diskMountSelectionChanged(string sectionId, int widgetIndex, string mountPath)
signal controlCenterSettingChanged(string sectionId, int widgetIndex, string settingName, bool value)
signal minimumWidthChanged(string sectionId, int widgetIndex, bool enabled)
width: parent.width
height: implicitHeight
@@ -283,6 +284,37 @@ Column {
}
}
DankActionButton {
id: minimumWidthButton
buttonSize: 28
visible: modelData.id === "cpuUsage"
|| modelData.id === "memUsage"
|| modelData.id === "cpuTemp"
|| modelData.id === "gpuTemp"
iconName: "straighten"
iconSize: 16
iconColor: (modelData.minimumWidth !== undefined ? modelData.minimumWidth : true) ? Theme.primary : Theme.outline
onClicked: {
var currentEnabled = modelData.minimumWidth !== undefined ? modelData.minimumWidth : true
root.minimumWidthChanged(root.sectionId, index, !currentEnabled)
}
onEntered: {
minimumWidthTooltipLoader.active = true
if (minimumWidthTooltipLoader.item) {
var currentEnabled = modelData.minimumWidth !== undefined ? modelData.minimumWidth : true
const tooltipText = currentEnabled ? "Force Padding" : "Dynamic Width"
const p = minimumWidthButton.mapToItem(null, minimumWidthButton.width / 2, 0)
minimumWidthTooltipLoader.item.show(tooltipText, p.x, p.y - 40, null)
}
}
onExited: {
if (minimumWidthTooltipLoader.item) {
minimumWidthTooltipLoader.item.hide()
}
minimumWidthTooltipLoader.active = false
}
}
Row {
spacing: Theme.spacingXS
visible: modelData.id === "clock"
@@ -892,4 +924,10 @@ Column {
active: false
sourceComponent: DankTooltip {}
}
Loader {
id: minimumWidthTooltipLoader
active: false
sourceComponent: DankTooltip {}
}
}