Warning, /plasma-mobile/qmlkonsole/src/contents/ui/SavedCommandsSettings.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 Han Young <hanyoung@protonmail.com>
0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005
0006 import QtQuick 2.0
0007 import QtQuick.Controls 2.14
0008 import QtQuick.Layouts 1.2
0009
0010 import org.kde.kirigami 2.19 as Kirigami
0011
0012 import QMLTermWidget 1.0
0013
0014 import org.kde.qmlkonsole 1.0
0015
0016 Kirigami.ScrollablePage {
0017 title: i18n("Saved Commands")
0018 property QMLTermWidget terminal
0019
0020 actions {
0021 main: Kirigami.Action {
0022 text: i18n("Add Command")
0023 icon.name: "contact-new"
0024 onTriggered: actionDialog.open()
0025 }
0026 }
0027
0028 ListView {
0029 id: listView
0030 model: SavedCommandsModel
0031 width: parent.width
0032 height: contentHeight
0033
0034 Kirigami.PlaceholderMessage {
0035 anchors.verticalCenter: parent.verticalCenter
0036 anchors.left: parent.left
0037 anchors.right: parent.right
0038 anchors.leftMargin: Kirigami.Units.largeSpacing
0039 anchors.rightMargin: Kirigami.Units.largeSpacing
0040
0041 visible: listView.count === 0
0042 icon.name: "dialog-scripts"
0043 text: i18n("No saved commands")
0044 explanation: i18n("Save commands to quickly run them without typing them out.")
0045
0046 helpfulAction: Kirigami.Action {
0047 icon.name: "list-add"
0048 text: i18n("Add command")
0049 onTriggered: actionDialog.open()
0050 }
0051 }
0052
0053 delegate: Kirigami.SwipeListItem {
0054 RowLayout {
0055 Kirigami.Icon {
0056 source: "dialog-scripts"
0057 }
0058 Label {
0059 id: label
0060 text: model.display
0061 font.family: "Monospace"
0062 }
0063 Item {
0064 Layout.fillWidth: true
0065 }
0066 }
0067
0068 actions: [
0069 Kirigami.Action {
0070 icon.name: "delete"
0071 onTriggered: {
0072 SavedCommandsModel.removeRow(index);
0073 showPassiveNotification(i18n("Action %1 removed", label.text));
0074 }
0075 }
0076 ]
0077 }
0078 }
0079
0080 Kirigami.PromptDialog {
0081 id: actionDialog
0082 title: i18n("Add Command")
0083 preferredWidth: Kirigami.Units.gridUnit * 30
0084 padding: Kirigami.Units.largeSpacing
0085 standardButtons: Dialog.Save | Dialog.Cancel
0086
0087 onAccepted: {
0088 if (textField.text != "") {
0089 SavedCommandsModel.addAction(textField.text);
0090 textField.text = ""
0091 }
0092
0093 actionDialog.close();
0094 }
0095
0096 contentItem: RowLayout {
0097 TextField {
0098 id: textField
0099 font.family: "Monospace"
0100 Layout.fillWidth: true
0101 }
0102 }
0103 }
0104 }