1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

dankbar: fix monitoring widgets with no background option

fixes #806
This commit is contained in:
bbedward
2025-11-24 12:26:29 -05:00
parent 5a52edcad8
commit 29f84aeab5
4 changed files with 235 additions and 263 deletions

View File

@@ -25,8 +25,8 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuContentRoot.implicitWidth implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuContent.implicitWidth
implicitHeight: root.isVerticalOrientation ? cpuColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2) implicitHeight: root.isVerticalOrientation ? cpuColumn.implicitHeight : cpuContent.implicitHeight
Column { Column {
id: cpuColumn id: cpuColumn
@@ -65,79 +65,72 @@ BasePill {
} }
} }
Item { Row {
id: cpuContentRoot id: cpuContent
visible: !root.isVerticalOrientation visible: !root.isVerticalOrientation
anchors.centerIn: parent
spacing: Theme.spacingXS
implicitWidth: cpuRow.implicitWidth DankIcon {
implicitHeight: cpuRow.implicitHeight id: cpuIcon
name: "memory"
Row { size: Theme.barIconSize(root.barThickness)
id: cpuRow color: {
anchors.centerIn: parent if (DgopService.cpuUsage > 80) {
spacing: Theme.spacingXS return Theme.tempDanger;
DankIcon {
id: cpuIcon
name: "memory"
size: Theme.barIconSize(root.barThickness)
color: {
if (DgopService.cpuUsage > 80) {
return Theme.tempDanger;
}
if (DgopService.cpuUsage > 60) {
return Theme.tempWarning;
}
return Theme.widgetIconColor;
} }
implicitWidth: size if (DgopService.cpuUsage > 60) {
implicitHeight: size return Theme.tempWarning;
width: size }
height: size
return Theme.widgetIconColor;
} }
Item { implicitWidth: size
id: textBox implicitHeight: size
width: size
height: size
}
implicitWidth: root.minimumWidth ? Math.max(cpuBaseline.width, cpuText.paintedWidth) : cpuText.paintedWidth Item {
implicitHeight: cpuText.implicitHeight id: textBox
width: implicitWidth implicitWidth: root.minimumWidth ? Math.max(cpuBaseline.width, cpuText.paintedWidth) : cpuText.paintedWidth
height: implicitHeight implicitHeight: cpuText.implicitHeight
Behavior on width { width: implicitWidth
NumberAnimation { height: implicitHeight
duration: Theme.shortDuration
easing.type: Easing.OutCubic Behavior on width {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Easing.OutCubic
}
}
StyledTextMetrics {
id: cpuBaseline
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
text: "88%"
}
StyledText {
id: cpuText
text: {
const v = DgopService.cpuUsage;
if (v === undefined || v === null || v === 0) {
return "--%";
} }
return v.toFixed(0) + "%";
} }
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
StyledTextMetrics { anchors.fill: parent
id: cpuBaseline horizontalAlignment: Text.AlignHCenter
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) verticalAlignment: Text.AlignVCenter
text: "88%" elide: Text.ElideNone
}
StyledText {
id: cpuText
text: {
const v = DgopService.cpuUsage;
if (v === undefined || v === null || v === 0) {
return "--%";
}
return v.toFixed(0) + "%";
}
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
}
} }
} }
} }

View File

@@ -25,8 +25,8 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuTempContentRoot.implicitWidth implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : cpuTempRow.implicitWidth
implicitHeight: root.isVerticalOrientation ? cpuTempColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2) implicitHeight: root.isVerticalOrientation ? cpuTempColumn.implicitHeight : cpuTempRow.implicitHeight
Column { Column {
id: cpuTempColumn id: cpuTempColumn
@@ -65,79 +65,72 @@ BasePill {
} }
} }
Item { Row {
id: cpuTempContentRoot id: cpuTempRow
visible: !root.isVerticalOrientation visible: !root.isVerticalOrientation
anchors.centerIn: parent
spacing: Theme.spacingXS
implicitWidth: cpuTempRow.implicitWidth DankIcon {
implicitHeight: cpuTempRow.implicitHeight id: cpuTempIcon
name: "device_thermostat"
Row { size: Theme.barIconSize(root.barThickness)
id: cpuTempRow color: {
anchors.centerIn: parent if (DgopService.cpuTemperature > 85) {
spacing: Theme.spacingXS return Theme.tempDanger;
DankIcon {
id: cpuTempIcon
name: "device_thermostat"
size: Theme.barIconSize(root.barThickness)
color: {
if (DgopService.cpuTemperature > 85) {
return Theme.tempDanger;
}
if (DgopService.cpuTemperature > 69) {
return Theme.tempWarning;
}
return Theme.widgetIconColor;
} }
implicitWidth: size if (DgopService.cpuTemperature > 69) {
implicitHeight: size return Theme.tempWarning;
width: size }
height: size
return Theme.widgetIconColor;
} }
Item { implicitWidth: size
id: textBox implicitHeight: size
width: size
height: size
}
implicitWidth: root.minimumWidth ? Math.max(tempBaseline.width, cpuTempText.paintedWidth) : cpuTempText.paintedWidth Item {
implicitHeight: cpuTempText.implicitHeight id: textBox
width: implicitWidth implicitWidth: root.minimumWidth ? Math.max(tempBaseline.width, cpuTempText.paintedWidth) : cpuTempText.paintedWidth
height: implicitHeight implicitHeight: cpuTempText.implicitHeight
Behavior on width { width: implicitWidth
NumberAnimation { height: implicitHeight
duration: Theme.shortDuration
easing.type: Easing.OutCubic Behavior on width {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Easing.OutCubic
}
}
StyledTextMetrics {
id: tempBaseline
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
text: "88°"
}
StyledText {
id: cpuTempText
text: {
if (DgopService.cpuTemperature === undefined || DgopService.cpuTemperature === null || DgopService.cpuTemperature < 0) {
return "--°";
} }
return Math.round(DgopService.cpuTemperature) + "°";
} }
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
StyledTextMetrics { anchors.fill: parent
id: tempBaseline horizontalAlignment: Text.AlignHCenter
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) verticalAlignment: Text.AlignVCenter
text: "88°" elide: Text.ElideNone
}
StyledText {
id: cpuTempText
text: {
if (DgopService.cpuTemperature === undefined || DgopService.cpuTemperature === null || DgopService.cpuTemperature < 0) {
return "--°";
}
return Math.round(DgopService.cpuTemperature) + "°";
}
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
}
} }
} }
} }

View File

@@ -93,8 +93,8 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : gpuTempContentRoot.implicitWidth implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : gpuTempRow.implicitWidth
implicitHeight: root.isVerticalOrientation ? gpuTempColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2) implicitHeight: root.isVerticalOrientation ? gpuTempColumn.implicitHeight : gpuTempRow.implicitHeight
Column { Column {
id: gpuTempColumn id: gpuTempColumn
@@ -133,79 +133,72 @@ BasePill {
} }
} }
Item { Row {
id: gpuTempContentRoot id: gpuTempRow
visible: !root.isVerticalOrientation visible: !root.isVerticalOrientation
anchors.centerIn: parent
spacing: Theme.spacingXS
implicitWidth: gpuTempRow.implicitWidth DankIcon {
implicitHeight: gpuTempRow.implicitHeight id: gpuTempIcon
name: "auto_awesome_mosaic"
Row { size: Theme.barIconSize(root.barThickness)
id: gpuTempRow color: {
anchors.centerIn: parent if (root.displayTemp > 80) {
spacing: Theme.spacingXS return Theme.tempDanger;
DankIcon {
id: gpuTempIcon
name: "auto_awesome_mosaic"
size: Theme.barIconSize(root.barThickness)
color: {
if (root.displayTemp > 80) {
return Theme.tempDanger;
}
if (root.displayTemp > 65) {
return Theme.tempWarning;
}
return Theme.widgetIconColor;
} }
implicitWidth: size if (root.displayTemp > 65) {
implicitHeight: size return Theme.tempWarning;
width: size }
height: size
return Theme.widgetIconColor;
} }
Item { implicitWidth: size
id: textBox implicitHeight: size
width: size
height: size
}
implicitWidth: root.minimumWidth ? Math.max(gpuTempBaseline.width, gpuTempText.paintedWidth) : gpuTempText.paintedWidth Item {
implicitHeight: gpuTempText.implicitHeight id: textBox
width: implicitWidth implicitWidth: root.minimumWidth ? Math.max(gpuTempBaseline.width, gpuTempText.paintedWidth) : gpuTempText.paintedWidth
height: implicitHeight implicitHeight: gpuTempText.implicitHeight
Behavior on width { width: implicitWidth
NumberAnimation { height: implicitHeight
duration: Theme.shortDuration
easing.type: Easing.OutCubic Behavior on width {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Easing.OutCubic
}
}
StyledTextMetrics {
id: gpuTempBaseline
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
text: "88°"
}
StyledText {
id: gpuTempText
text: {
if (root.displayTemp === undefined || root.displayTemp === null || root.displayTemp === 0) {
return "--°";
} }
return Math.round(root.displayTemp) + "°";
} }
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
StyledTextMetrics { anchors.fill: parent
id: gpuTempBaseline horizontalAlignment: Text.AlignHCenter
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) verticalAlignment: Text.AlignVCenter
text: "88°" elide: Text.ElideNone
}
StyledText {
id: gpuTempText
text: {
if (root.displayTemp === undefined || root.displayTemp === null || root.displayTemp === 0) {
return "--°";
}
return Math.round(root.displayTemp) + "°";
}
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
}
} }
} }
} }

View File

@@ -27,8 +27,8 @@ BasePill {
content: Component { content: Component {
Item { Item {
implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : ramContentRoot.implicitWidth implicitWidth: root.isVerticalOrientation ? (root.widgetThickness - root.horizontalPadding * 2) : ramContent.implicitWidth
implicitHeight: root.isVerticalOrientation ? ramColumn.implicitHeight : (root.widgetThickness - root.horizontalPadding * 2) implicitHeight: root.isVerticalOrientation ? ramColumn.implicitHeight : ramContent.implicitHeight
Column { Column {
id: ramColumn id: ramColumn
@@ -75,93 +75,86 @@ BasePill {
} }
} }
Item { Row {
id: ramContentRoot id: ramContent
visible: !root.isVerticalOrientation visible: !root.isVerticalOrientation
anchors.centerIn: parent
spacing: Theme.spacingXS
implicitWidth: ramRow.implicitWidth DankIcon {
implicitHeight: ramRow.implicitHeight id: ramIcon
name: "developer_board"
Row { size: Theme.barIconSize(root.barThickness)
id: ramRow color: {
anchors.centerIn: parent if (DgopService.memoryUsage > 90) {
spacing: Theme.spacingXS return Theme.tempDanger;
DankIcon {
id: ramIcon
name: "developer_board"
size: Theme.barIconSize(root.barThickness)
color: {
if (DgopService.memoryUsage > 90) {
return Theme.tempDanger;
}
if (DgopService.memoryUsage > 75) {
return Theme.tempWarning;
}
return Theme.widgetIconColor;
} }
implicitWidth: size if (DgopService.memoryUsage > 75) {
implicitHeight: size return Theme.tempWarning;
width: size }
height: size
return Theme.widgetIconColor;
} }
Item { implicitWidth: size
id: textBox implicitHeight: size
width: size
height: size
}
implicitWidth: root.minimumWidth ? Math.max(ramBaseline.width, ramText.paintedWidth) : ramText.paintedWidth Item {
implicitHeight: ramText.implicitHeight id: textBox
width: implicitWidth implicitWidth: root.minimumWidth ? Math.max(ramBaseline.width, ramText.paintedWidth) : ramText.paintedWidth
height: implicitHeight implicitHeight: ramText.implicitHeight
Behavior on width { width: implicitWidth
NumberAnimation { height: implicitHeight
duration: Theme.shortDuration
easing.type: Easing.OutCubic Behavior on width {
} NumberAnimation {
duration: Theme.shortDuration
easing.type: Easing.OutCubic
} }
}
StyledTextMetrics { StyledTextMetrics {
id: ramBaseline id: ramBaseline
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
text: { text: {
if (!root.showSwap) { if (!root.showSwap) {
return "88%"; return "88%";
}
if (root.swapUsage < 10) {
return "88% · 0%";
}
return "88% · 88%";
} }
} if (root.swapUsage < 10) {
return "88% · 0%";
StyledText {
id: ramText
text: {
if (DgopService.memoryUsage === undefined || DgopService.memoryUsage === null || DgopService.memoryUsage === 0) {
return "--%";
}
let ramText = DgopService.memoryUsage.toFixed(0) + "%";
if (root.showSwap && DgopService.totalSwapKB > 0) {
return ramText + " · " + root.swapUsage.toFixed(0) + "%";
}
return ramText;
} }
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) return "88% · 88%";
color: Theme.widgetTextColor
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
wrapMode: Text.NoWrap
} }
} }
StyledText {
id: ramText
text: {
if (DgopService.memoryUsage === undefined || DgopService.memoryUsage === null || DgopService.memoryUsage === 0) {
return "--%";
}
let ramText = DgopService.memoryUsage.toFixed(0) + "%";
if (root.showSwap && DgopService.totalSwapKB > 0) {
return ramText + " · " + root.swapUsage.toFixed(0) + "%";
}
return ramText;
}
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideNone
wrapMode: Text.NoWrap
}
} }
} }
} }