diff --git a/shell/applets/BatteryApplet.qml b/shell/applets/BatteryApplet.qml index be30b8f..da0fe2a 100644 --- a/shell/applets/BatteryApplet.qml +++ b/shell/applets/BatteryApplet.qml @@ -210,62 +210,26 @@ Column { } // Rate row - Item { - width: parent.width - height: 20 + InfoRow { visible: S.BatteryService.changeRate !== 0 - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: S.BatteryService.charging ? "Charging" : "Discharging" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: { - const r = Math.abs(S.BatteryService.changeRate); - return r > 0 ? r.toFixed(1) + " W" : ""; - } - color: root._stateColor - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily + height: 20 + label: S.BatteryService.charging ? "Charging" : "Discharging" + value: { + const r = Math.abs(S.BatteryService.changeRate); + return r > 0 ? r.toFixed(1) + " W" : ""; } + valueColor: root._stateColor } // Health row - Item { - width: parent.width - height: 20 + InfoRow { visible: S.BatteryService.healthSupported - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: "Health" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: Math.round(S.BatteryService.healthPercent) + "%" - color: { - const h = S.BatteryService.healthPercent; - return h < 50 ? S.Theme.base08 : h < 75 ? S.Theme.base0A : S.Theme.base0B; - } - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily + height: 20 + label: "Health" + value: Math.round(S.BatteryService.healthPercent) + "%" + valueColor: { + const h = S.BatteryService.healthPercent; + return h < 50 ? S.Theme.base08 : h < 75 ? S.Theme.base0A : S.Theme.base0B; } } diff --git a/shell/applets/GpuApplet.qml b/shell/applets/GpuApplet.qml index 3a313fb..29fb82e 100644 --- a/shell/applets/GpuApplet.qml +++ b/shell/applets/GpuApplet.qml @@ -182,30 +182,12 @@ Column { } // Temperature row - Item { - width: parent.width - height: 22 + InfoRow { visible: S.SystemStats.gpuTempC > 0 - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: "Temp" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: S.SystemStats.gpuTempC + "\u00B0C" - color: S.SystemStats.gpuTempC > 85 ? S.Theme.base08 : S.SystemStats.gpuTempC > 70 ? S.Theme.base0A : S.Theme.base05 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } + height: 22 + label: "Temp" + value: S.SystemStats.gpuTempC + "\u00B0C" + valueColor: S.SystemStats.gpuTempC > 85 ? S.Theme.base08 : S.SystemStats.gpuTempC > 70 ? S.Theme.base0A : S.Theme.base05 } Item { diff --git a/shell/applets/InfoRow.qml b/shell/applets/InfoRow.qml new file mode 100644 index 0000000..68047ca --- /dev/null +++ b/shell/applets/InfoRow.qml @@ -0,0 +1,33 @@ +import QtQuick +import "../services" as S + +Item { + id: root + + required property string label + required property string value + property color valueColor: S.Theme.base05 + + width: parent?.width ?? 0 + height: 18 + + Text { + anchors.left: parent.left + anchors.leftMargin: 12 + anchors.verticalCenter: parent.verticalCenter + text: root.label + color: S.Theme.base04 + font.pixelSize: S.Theme.fontSize - 2 + font.family: S.Theme.fontFamily + } + + Text { + anchors.right: parent.right + anchors.rightMargin: 12 + anchors.verticalCenter: parent.verticalCenter + text: root.value + color: root.valueColor + font.pixelSize: S.Theme.fontSize - 2 + font.family: S.Theme.fontFamily + } +} diff --git a/shell/applets/MemoryApplet.qml b/shell/applets/MemoryApplet.qml index 4244332..d62add2 100644 --- a/shell/applets/MemoryApplet.qml +++ b/shell/applets/MemoryApplet.qml @@ -110,105 +110,10 @@ Column { } // Breakdown rows - Item { - width: root.width - height: 18 - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: "Used" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: root._fmt(root.usedGb) - color: S.Theme.base05 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - } - - Item { - width: root.width - height: 18 - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: "Cached" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: root._fmt(root.cachedGb) - color: S.Theme.base05 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - } - - Item { - width: root.width - height: 18 - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: "Available" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: root._fmt(root.availGb) - color: S.Theme.base05 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - } - - Item { - width: root.width - height: 18 - - Text { - anchors.left: parent.left - anchors.leftMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: "Total" - color: S.Theme.base04 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - - Text { - anchors.right: parent.right - anchors.rightMargin: 12 - anchors.verticalCenter: parent.verticalCenter - text: root._fmt(root.totalGb) - color: S.Theme.base05 - font.pixelSize: S.Theme.fontSize - 2 - font.family: S.Theme.fontFamily - } - } + InfoRow { label: "Used"; value: root._fmt(root.usedGb) } + InfoRow { label: "Cached"; value: root._fmt(root.cachedGb) } + InfoRow { label: "Available"; value: root._fmt(root.availGb) } + InfoRow { label: "Total"; value: root._fmt(root.totalGb) } // Process list separator Rectangle { diff --git a/shell/applets/qmldir b/shell/applets/qmldir index bf26e90..17b1759 100644 --- a/shell/applets/qmldir +++ b/shell/applets/qmldir @@ -7,6 +7,7 @@ CpuApplet 1.0 CpuApplet.qml DiskApplet 1.0 DiskApplet.qml GpuApplet 1.0 GpuApplet.qml HexWaveBackground 1.0 HexWaveBackground.qml +InfoRow 1.0 InfoRow.qml MemoryApplet 1.0 MemoryApplet.qml MprisApplet 1.0 MprisApplet.qml NetworkApplet 1.0 NetworkApplet.qml