165 lines
7.0 KiB
QML
165 lines
7.0 KiB
QML
|
|
import QtQuick
|
|
import QtQuick.Controls as Controls
|
|
import QtQuick.Layouts
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
import org.kde.kcmutils as KCMUtils
|
|
import org.kde.plasma.extras as PlasmaExtras
|
|
import org.kde.plasma.core as PlasmaCore
|
|
import org.kde.plasma.components as PlasmaComponents3
|
|
|
|
import org.kde.plasma.kcm.openrc
|
|
|
|
KCMUtils.ScrollViewKCM {
|
|
id: rootKCM
|
|
ColumnLayout{
|
|
id: root
|
|
anchors.fill: parent
|
|
|
|
PlasmaExtras.Heading {
|
|
level: 1
|
|
Layout.fillWidth: true
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter;
|
|
text: i18n("Configure OpenRC")
|
|
}
|
|
ColumnLayout {
|
|
id: openRCPanel
|
|
Layout.fillHeight: true
|
|
Layout.fillWidth: true
|
|
|
|
PlasmaExtras.Heading {
|
|
level: 2
|
|
Layout.fillWidth: true
|
|
text: i18n("Available Services")
|
|
}
|
|
|
|
Controls.Frame {
|
|
clip: true
|
|
id: serviceViewFrame
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
|
|
Controls.ScrollView {
|
|
id: serviceScrollArea
|
|
anchors.fill: parent
|
|
|
|
TreeView {
|
|
id: treeView
|
|
clip: true
|
|
width: openRCPanel.width
|
|
|
|
selectionModel: ItemSelectionModel {}
|
|
|
|
model: OpenRCServiceModel { }
|
|
|
|
delegate: Item {
|
|
// implicitWidth: openRCPanel.width
|
|
implicitWidth: treeView.width
|
|
// implicitWidth: padding + label.x + label.implicitWidth + padding
|
|
implicitHeight: label.implicitHeight * 1.5
|
|
|
|
readonly property real indentation: 20
|
|
readonly property real padding: 5
|
|
|
|
// Assigned to by TreeView:
|
|
required property TreeView treeView
|
|
required property bool isTreeNode
|
|
required property bool expanded
|
|
required property bool hasChildren
|
|
required property int depth
|
|
required property int row
|
|
required property int column
|
|
required property bool current
|
|
|
|
// Rotate indicator when expanded by the user
|
|
// (requires TreeView to have a selectionModel)
|
|
property Animation indicatorAnimation: NumberAnimation {
|
|
target: indicator
|
|
property: "rotation"
|
|
from: expanded ? 0 : 90
|
|
to: expanded ? 90 : 0
|
|
duration: 100
|
|
easing.type: Easing.OutQuart
|
|
}
|
|
TableView.onPooled: indicatorAnimation.complete()
|
|
TableView.onReused: if (current) indicatorAnimation.start()
|
|
onExpandedChanged: indicator.rotation = expanded ? 90 : 0
|
|
|
|
Rectangle {
|
|
id: background
|
|
anchors.fill: parent
|
|
color: row === treeView.currentRow ? palette.highlight : "black"
|
|
opacity: (treeView.alternatingRows && row % 2 !== 0) ? 0.3 : 0.1
|
|
}
|
|
|
|
Controls.Label {
|
|
id: indicator
|
|
x: padding + (depth * indentation)
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
visible: isTreeNode && hasChildren
|
|
text: "▶"
|
|
|
|
TapHandler {
|
|
onSingleTapped: {
|
|
let index = treeView.index(row, column)
|
|
treeView.selectionModel.setCurrentIndex(index, ItemSelectionModel.NoUpdate)
|
|
treeView.toggleExpanded(row)
|
|
}
|
|
}
|
|
}
|
|
|
|
Controls.Label {
|
|
id: label
|
|
x: padding + (isTreeNode ? (depth + 1) * indentation : 0)
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
width: parent.width - padding - x
|
|
clip: true
|
|
text: model.display
|
|
}
|
|
|
|
Controls.ToolButton {
|
|
id: restartButton
|
|
anchors.right: parent.right
|
|
visible: !hasChildren
|
|
icon.name: "system-restart"
|
|
text: i18n("Restart")
|
|
Controls.ToolTip.visible: hovered
|
|
Controls.ToolTip.text: i18n("Restarts the current service.")
|
|
onClicked: {
|
|
kcm.tryRestartService(model.display);
|
|
}
|
|
}
|
|
Controls.ToolButton {
|
|
id: stopButton
|
|
anchors.right: restartButton.left
|
|
visible: !hasChildren
|
|
icon.name: "delete"
|
|
text: i18n("Stop")
|
|
Controls.ToolTip.visible: hovered
|
|
Controls.ToolTip.text: i18n("Stops the current service.")
|
|
onClicked: {
|
|
kcm.tryStopService(model.display);
|
|
}
|
|
}
|
|
Controls.ToolButton {
|
|
id: deleteButton
|
|
anchors.right: stopButton.left
|
|
visible: !hasChildren
|
|
icon.name: "delete"
|
|
text: i18n("Remove")
|
|
Controls.ToolTip.visible: hovered
|
|
Controls.ToolTip.text: i18n("Removes this service from the default runlevel (for OpenRC).")
|
|
onClicked: {
|
|
console.log("Start remove " + model.display);
|
|
kcm.tryDisableService(model.display);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|