2021-02-27 19:04:47 +00:00
|
|
|
/**
|
|
|
|
* SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
|
|
|
|
2022-12-13 20:45:50 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15 as QQC2
|
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
2019-10-27 17:08:51 +00:00
|
|
|
import org.kde.kdeconnect 1.0
|
|
|
|
|
|
|
|
ListView {
|
2022-12-13 20:45:50 +00:00
|
|
|
id: view
|
2019-10-27 17:08:51 +00:00
|
|
|
Component.onCompleted: {
|
2022-12-13 20:45:50 +00:00
|
|
|
root.leftPadding = 0
|
|
|
|
root.rightPadding = 0
|
|
|
|
root.topPadding = 0
|
|
|
|
root.bottomPadding = 0
|
2019-10-27 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
property string device
|
|
|
|
|
|
|
|
property var action: Kirigami.Action {
|
|
|
|
icon.name: "list-add"
|
|
|
|
text: i18n("Add command")
|
|
|
|
onTriggered: addDialog.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
model: CommandsModel {
|
|
|
|
id: commandModel
|
|
|
|
deviceId: device
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: Kirigami.SwipeListItem {
|
2022-12-13 20:45:50 +00:00
|
|
|
width: parent.width
|
|
|
|
enabled: true
|
2019-10-27 17:08:51 +00:00
|
|
|
|
2023-11-08 21:06:14 +00:00
|
|
|
contentItem: QQC2.Label {
|
2022-12-13 20:45:50 +00:00
|
|
|
text: i18n("%1 <br> <i>%2</i>", name, command)
|
|
|
|
}
|
2019-10-27 17:08:51 +00:00
|
|
|
|
2022-12-13 20:45:50 +00:00
|
|
|
actions: Kirigami.Action {
|
|
|
|
text: i18n("Delete")
|
|
|
|
icon.name: "delete"
|
|
|
|
onTriggered: commandModel.removeCommand(index)
|
2019-10-27 17:08:51 +00:00
|
|
|
}
|
2022-12-13 20:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Kirigami.PlaceholderMessage {
|
|
|
|
icon.name: 'utilities-terminal'
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: view.count === 0
|
|
|
|
width: parent.width - Kirigami.Units.gridUnit * 4
|
|
|
|
text: i18n("No Commands")
|
|
|
|
explanation: i18n("Add commands to run them remotely from other devices")
|
|
|
|
helpfulAction: view.action
|
|
|
|
}
|
2019-10-27 17:08:51 +00:00
|
|
|
|
2024-08-01 23:14:33 +01:00
|
|
|
Kirigami.Dialog {
|
2019-10-27 17:08:51 +00:00
|
|
|
id: addDialog
|
|
|
|
title: "Add command"
|
|
|
|
|
2022-12-13 20:45:50 +00:00
|
|
|
standardButtons: QQC2.Dialog.Save | QQC2.Dialog.Cancel
|
2024-08-01 23:14:33 +01:00
|
|
|
padding: Kirigami.Units.largeSpacing
|
2019-10-27 17:08:51 +00:00
|
|
|
|
|
|
|
Kirigami.FormLayout {
|
2022-12-13 20:45:50 +00:00
|
|
|
QQC2.TextField {
|
2019-10-27 17:08:51 +00:00
|
|
|
id: nameField
|
|
|
|
Kirigami.FormData.label: i18n("Name:")
|
|
|
|
}
|
2022-12-13 20:45:50 +00:00
|
|
|
QQC2.TextField {
|
2019-10-27 17:08:51 +00:00
|
|
|
id: commandField
|
|
|
|
Kirigami.FormData.label: i18n("Command:")
|
|
|
|
}
|
|
|
|
|
2022-12-13 20:45:50 +00:00
|
|
|
QQC2.ComboBox {
|
2019-10-27 17:08:51 +00:00
|
|
|
Kirigami.FormData.label: i18n("Sample commands:")
|
|
|
|
textRole: "name"
|
|
|
|
model: ListModel {
|
|
|
|
id: sampleCommands
|
|
|
|
ListElement {
|
|
|
|
name: "Sample command"
|
|
|
|
command: ""
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Suspend"
|
|
|
|
command: "systemctl suspend"
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Maximum Brightness"
|
|
|
|
command: "qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl org.kde.Solid.PowerManagement.Actions.BrightnessControl.setBrightness `qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl org.kde.Solid.PowerManagement.Actions.BrightnessControl.brightnessMax`"
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Lock Screen"
|
|
|
|
command: "loginctl lock-session"
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Unlock Screen"
|
|
|
|
command: "loginctl unlock-session"
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Close All Vaults"
|
|
|
|
command: "qdbus org.kde.kded5 /modules/plasmavault closeAllVaults"
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Forcefully Close All Vaults"
|
|
|
|
command: "qdbus org.kde.kded5 /modules/plasmavault forceCloseAllVaults"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onActivated: {
|
|
|
|
if (index > 0) {
|
|
|
|
nameField.text = sampleCommands.get(index).name
|
|
|
|
commandField.text = sampleCommands.get(index).command
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccepted: commandModel.addCommand(nameField.text, commandField.text)
|
|
|
|
}
|
|
|
|
}
|