extract InfoRow component from applet key-value rows
This commit is contained in:
parent
d38c4b5161
commit
e50dd155fa
5 changed files with 57 additions and 172 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
33
shell/applets/InfoRow.qml
Normal file
33
shell/applets/InfoRow.qml
Normal file
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue