1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -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

@@ -827,6 +827,7 @@ Item {
return processListPopoutLoader.item
}
parentScreen: barWindow.screen
widgetData: parent.widgetData
toggleProcessList: () => {
processListPopoutLoader.active = true
return processListPopoutLoader.item?.toggle()
@@ -846,6 +847,7 @@ Item {
return processListPopoutLoader.item
}
parentScreen: barWindow.screen
widgetData: parent.widgetData
toggleProcessList: () => {
processListPopoutLoader.active = true
return processListPopoutLoader.item?.toggle()
@@ -875,6 +877,7 @@ Item {
return processListPopoutLoader.item
}
parentScreen: barWindow.screen
widgetData: parent.widgetData
toggleProcessList: () => {
processListPopoutLoader.active = true
return processListPopoutLoader.item?.toggle()

View File

@@ -65,6 +65,14 @@ Loader {
restoreMode: Binding.RestoreNone
}
Binding {
target: root.item
when: root.item && "widgetData" in root.item
property: "widgetData"
value: root.widgetData
restoreMode: Binding.RestoreNone
}
onLoaded: {
if (item) {
contentItemReady(item)

View File

@@ -17,6 +17,8 @@ Rectangle {
property var parentScreen: null
property real barThickness: 48
property real widgetThickness: 30
property var widgetData: null
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
readonly property real horizontalPadding: SettingsData.dankBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30))
width: isVertical ? widgetThickness : (cpuContent.implicitWidth + horizontalPadding * 2)
@@ -141,7 +143,7 @@ Rectangle {
text: "100%"
}
width: Math.max(cpuBaseline.width, paintedWidth)
width: root.minimumWidth ? Math.max(cpuBaseline.width, paintedWidth) : paintedWidth
Behavior on width {
NumberAnimation {

View File

@@ -17,6 +17,8 @@ Rectangle {
property var parentScreen: null
property real barThickness: 48
property real widgetThickness: 30
property var widgetData: null
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
readonly property real horizontalPadding: SettingsData.dankBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30))
width: isVertical ? widgetThickness : (cpuTempContent.implicitWidth + horizontalPadding * 2)
@@ -141,7 +143,7 @@ Rectangle {
text: "100°"
}
width: Math.max(tempBaseline.width, paintedWidth)
width: root.minimumWidth ? Math.max(tempBaseline.width, paintedWidth) : paintedWidth
Behavior on width {
NumberAnimation {

View File

@@ -19,6 +19,7 @@ Rectangle {
property real barThickness: 48
property real widgetThickness: 30
property int selectedGpuIndex: (widgetData && widgetData.selectedGpuIndex !== undefined) ? widgetData.selectedGpuIndex : 0
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
readonly property real horizontalPadding: SettingsData.dankBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30))
property real displayTemp: {
if (!DgopService.availableGpus || DgopService.availableGpus.length === 0) {
@@ -209,7 +210,7 @@ Rectangle {
text: "100°"
}
width: Math.max(gpuTempBaseline.width, paintedWidth)
width: root.minimumWidth ? Math.max(gpuTempBaseline.width, paintedWidth) : paintedWidth
Behavior on width {
NumberAnimation {

View File

@@ -17,6 +17,8 @@ Rectangle {
property var parentScreen: null
property real barThickness: 48
property real widgetThickness: 30
property var widgetData: null
property bool minimumWidth: (widgetData && widgetData.minimumWidth !== undefined) ? widgetData.minimumWidth : true
readonly property real horizontalPadding: SettingsData.dankBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30))
width: isVertical ? widgetThickness : (ramContent.implicitWidth + horizontalPadding * 2)
@@ -30,6 +32,7 @@ Rectangle {
const baseColor = ramArea.containsMouse ? Theme.widgetBaseHoverColor : Theme.widgetBaseBackgroundColor;
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, baseColor.a * Theme.widgetTransparency);
}
Component.onCompleted: {
DgopService.addRef(["memory"]);
}
@@ -141,7 +144,7 @@ Rectangle {
text: "100%"
}
width: Math.max(ramBaseline.width, paintedWidth)
width: root.minimumWidth ? Math.max(ramBaseline.width, paintedWidth) : paintedWidth
Behavior on width {
NumberAnimation {

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 {}
}
}