nova-shell/shell/applets/SystemdUnitRow.qml

103 lines
2.7 KiB
QML

import QtQuick
import "../services" as S
import NovaStats as NS
Item {
id: root
required property string unitName
required property string description
required property string subState
required property string scope
required property string hostTarget
required property string machineName
required property color accentColor
width: parent?.width ?? 0
height: 28
HoverHandler {
id: _rowHover
}
Rectangle {
anchors.fill: parent
anchors.leftMargin: 4
anchors.rightMargin: 4
color: _rowHover.hovered ? NS.ThemeService.base02 : "transparent"
radius: NS.ThemeService.radius
z: -1
}
Text {
anchors.left: parent.left
anchors.leftMargin: 12
anchors.right: _subStateTag.left
anchors.rightMargin: 6
anchors.verticalCenter: parent.verticalCenter
text: root.unitName
color: NS.ThemeService.base05
font.pixelSize: NS.ThemeService.fontSize - 1
font.family: NS.ThemeService.fontFamily
elide: Text.ElideRight
}
Rectangle {
id: _subStateTag
anchors.right: _restartBtn.left
anchors.rightMargin: 6
anchors.verticalCenter: parent.verticalCenter
color: NS.ThemeService.base08
opacity: 0.85
radius: 3
width: _subStateLbl.width + 8
height: 14
Text {
id: _subStateLbl
anchors.centerIn: parent
text: root.subState
color: NS.ThemeService.base00
font.pixelSize: NS.ThemeService.fontSize - 3
font.family: NS.ThemeService.fontFamily
}
}
// Restart button only visible while hovering the row. = fa-refresh
Item {
id: _restartBtn
anchors.right: parent.right
anchors.rightMargin: 8
anchors.verticalCenter: parent.verticalCenter
width: 24
height: 24
opacity: _rowHover.hovered ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: 80
}
}
Text {
anchors.centerIn: parent
text: ""
color: _rHover.hovered ? root.accentColor : NS.ThemeService.base04
font.pixelSize: NS.ThemeService.fontSize
font.family: NS.ThemeService.iconFontFamily
Behavior on color {
ColorAnimation {
duration: 80
}
}
}
HoverHandler {
id: _rHover
cursorShape: Qt.PointingHandCursor
}
TapHandler {
enabled: _rowHover.hovered
onTapped: S.SystemdService.restartUnit(root.unitName, root.scope, root.hostTarget, root.machineName)
}
}
}