nova-shell/shell/applets/SystemdApplet.qml

169 lines
4.8 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import "../services" as S
import NovaStats as NS
Column {
id: root
required property color accentColor
property bool active: true
// Emitted when content resizes; parent can connect to extend panel-close grace.
signal contentResized
// Section header: state label + unit count
Item {
width: root.width
height: 28
Text {
anchors.left: parent.left
anchors.leftMargin: 12
anchors.verticalCenter: parent.verticalCenter
text: "SYSTEM"
color: NS.ThemeService.base03
font.pixelSize: NS.ThemeService.fontSize - 3
font.family: NS.ThemeService.fontFamily
font.letterSpacing: 1
}
Rectangle {
anchors.right: parent.right
anchors.rightMargin: 12
anchors.verticalCenter: parent.verticalCenter
visible: S.SystemdService.systemState !== "unknown"
color: {
const st = S.SystemdService.systemState;
if (st === "running")
return NS.ThemeService.base0B;
if (st === "degraded")
return NS.ThemeService.base0A;
return NS.ThemeService.base08;
}
opacity: 0.85
radius: 3
width: _sysStateLbl.width + 8
height: 14
Text {
id: _sysStateLbl
anchors.centerIn: parent
text: S.SystemdService.systemState
color: NS.ThemeService.base00
font.pixelSize: NS.ThemeService.fontSize - 3
font.family: NS.ThemeService.fontFamily
}
}
}
Repeater {
model: S.SystemdService.systemUnits
delegate: SystemdUnitRow {
required property var modelData
unitName: modelData.name
description: modelData.description
subState: modelData.subState
isUser: false
machineName: ""
accentColor: root.accentColor
onHeightChanged: root.contentResized()
}
}
Item {
visible: S.SystemdService.systemUnits.length === 0
width: root.width
height: 24
Text {
anchors.centerIn: parent
text: "no failed system units"
color: NS.ThemeService.base0B
font.pixelSize: NS.ThemeService.fontSize - 2
font.family: NS.ThemeService.fontFamily
}
}
Separator {}
// User section
Item {
width: root.width
height: 28
Text {
anchors.left: parent.left
anchors.leftMargin: 12
anchors.verticalCenter: parent.verticalCenter
text: "USER"
color: NS.ThemeService.base03
font.pixelSize: NS.ThemeService.fontSize - 3
font.family: NS.ThemeService.fontFamily
font.letterSpacing: 1
}
Rectangle {
anchors.right: parent.right
anchors.rightMargin: 12
anchors.verticalCenter: parent.verticalCenter
visible: S.SystemdService.userState !== "unknown"
color: {
const st = S.SystemdService.userState;
if (st === "running")
return NS.ThemeService.base0B;
if (st === "degraded")
return NS.ThemeService.base0A;
return NS.ThemeService.base08;
}
opacity: 0.85
radius: 3
width: _userStateLbl.width + 8
height: 14
Text {
id: _userStateLbl
anchors.centerIn: parent
text: S.SystemdService.userState
color: NS.ThemeService.base00
font.pixelSize: NS.ThemeService.fontSize - 3
font.family: NS.ThemeService.fontFamily
}
}
}
Repeater {
model: S.SystemdService.userUnits
delegate: SystemdUnitRow {
required property var modelData
unitName: modelData.name
description: modelData.description
subState: modelData.subState
isUser: true
machineName: ""
accentColor: root.accentColor
onHeightChanged: root.contentResized()
}
}
Item {
visible: S.SystemdService.userUnits.length === 0
width: root.width
height: 24
Text {
anchors.centerIn: parent
text: "no failed user units"
color: NS.ThemeService.base0B
font.pixelSize: NS.ThemeService.fontSize - 2
font.family: NS.ThemeService.fontFamily
}
}
Item {
width: 1
height: 4
}
}