151 lines
3.4 KiB
QML
151 lines
3.4 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import ZShell
|
|
import ZShell.Components
|
|
import ZShell.Config
|
|
import qs.Components
|
|
import qs.Services
|
|
|
|
CustomRect {
|
|
id: root
|
|
|
|
required property color accent
|
|
required property string icon
|
|
required property string label
|
|
required property string subLabel
|
|
required property real temperature
|
|
required property real usage
|
|
|
|
color: Colors.tPalette.m3surfaceContainer
|
|
implicitHeight: ZUtils.snap(Math.max(tempProg.implicitHeight + detailsRow.implicitHeight + Tokens.spacing.largeIncreased, usageColumn.implicitHeight + usageLabel.implicitHeight) + Tokens.padding.large * 2, root)
|
|
implicitWidth: ZUtils.snapCeil(450, root)
|
|
radius: Tokens.rounding.largeIncreased
|
|
|
|
ClipRect {
|
|
anchors.fill: parent
|
|
radius: parent.radius
|
|
|
|
CustomRect {
|
|
anchors.bottom: parent.bottom
|
|
anchors.left: parent.left
|
|
anchors.top: parent.top
|
|
color: Qt.alpha(root.accent, 0.05)
|
|
implicitWidth: parent.width * root.usage
|
|
|
|
Behavior on implicitWidth {
|
|
Anim {}
|
|
}
|
|
}
|
|
}
|
|
|
|
CircularProgress {
|
|
id: tempProg
|
|
|
|
anchors.left: parent.left
|
|
anchors.margins: Tokens.padding.large
|
|
anchors.top: parent.top
|
|
fgColor: root.accent
|
|
implicitSize: ZUtils.snap(Math.max(icon.implicitWidth, icon.implicitHeight) + Tokens.padding.small * 2, root)
|
|
spacing: Tokens.spacing.extraSmall
|
|
strokeWidth: Tokens.padding.extraSmall
|
|
value: root.usage
|
|
|
|
Behavior on clampedVal {
|
|
Anim {}
|
|
}
|
|
|
|
MaterialIcon {
|
|
id: icon
|
|
|
|
anchors.centerIn: parent
|
|
color: root.accent
|
|
fontStyle: Tokens.font.icon.large
|
|
text: root.icon
|
|
}
|
|
}
|
|
|
|
SnapLayout {
|
|
anchors.left: tempProg.right
|
|
anchors.margins: Tokens.spacing.largeIncreased
|
|
anchors.right: usageColumn.left
|
|
anchors.verticalCenter: tempProg.verticalCenter
|
|
|
|
spacing: Tokens.spacing.extraSmall
|
|
orientation: Qt.Vertical
|
|
|
|
CustomText {
|
|
color: root.accent
|
|
text: root.label
|
|
}
|
|
|
|
CustomText {
|
|
Layout.fillWidth: true
|
|
color: Colors.palette.m3onSurfaceVariant
|
|
elide: Text.ElideRight
|
|
text: root.subLabel
|
|
}
|
|
}
|
|
|
|
SnapLayout {
|
|
id: detailsRow
|
|
|
|
anchors.bottom: parent.bottom
|
|
anchors.left: parent.left
|
|
anchors.margins: Tokens.padding.largeIncreased
|
|
|
|
spacing: Tokens.spacing.extraSmall
|
|
orientation: Qt.Vertical
|
|
|
|
SnapLayout {
|
|
Layout.leftMargin: -Tokens.padding.extraSmall
|
|
spacing: Tokens.spacing.extraSmall
|
|
|
|
MaterialIcon {
|
|
Layout.topMargin: Math.round(fontInfo.pointSize * 0.08)
|
|
color: root.temperature > 90 ? Colors.palette.m3error : root.accent
|
|
fill: 1
|
|
text: root.temperature > 90 ? "thermometer_alert" : "thermometer"
|
|
}
|
|
|
|
CustomText {
|
|
text: `${Math.ceil(root.temperature)}°${"C"}`
|
|
}
|
|
}
|
|
|
|
CustomProgressBar {
|
|
fgColor: root.accent
|
|
implicitHeight: Tokens.padding.small
|
|
indeterminate: isNaN(root.usage) || isNaN(root.temperature)
|
|
value: root.temperature / 100
|
|
}
|
|
}
|
|
|
|
SnapLayout {
|
|
id: usageColumn
|
|
|
|
anchors.margins: Tokens.padding.large
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: Tokens.padding.extraLarge
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
spacing: 0
|
|
orientation: Qt.Vertical
|
|
|
|
CustomText {
|
|
id: usageLabel
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
color: Colors.palette.m3onSurfaceVariant
|
|
font: Tokens.font.body.medium
|
|
text: qsTr("Usage")
|
|
}
|
|
|
|
CustomText {
|
|
Layout.alignment: Qt.AlignRight
|
|
color: root.accent
|
|
font: Tokens.font.headline.builders.small.width(50).build()
|
|
text: isNaN(root.usage) ? "...%" : Math.round(root.usage * 100) + "%"
|
|
}
|
|
}
|
|
}
|