Warning, /plasma-mobile/qmlkonsole/src/contents/ui/SavedCommandsDialog.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2021-2022 Devin Lin <espidev@gmail.com>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 import QtQuick 2.15
0006 import QtQuick.Layouts 1.1
0007 import QtQuick.Controls 2.15
0008 
0009 import QMLTermWidget 1.0
0010 import org.kde.kirigami 2.19 as Kirigami
0011 
0012 import org.kde.qmlkonsole 1.0
0013 
0014 Kirigami.Dialog {
0015     id: savedCommandsDialog
0016     
0017     property var terminal
0018     
0019     title: i18nc("@title:window", "Saved Commands")
0020     preferredHeight: Kirigami.Units.gridUnit * 25
0021     preferredWidth: Kirigami.Units.gridUnit * 16
0022     standardButtons: Kirigami.Dialog.NoButton
0023     
0024     customFooterActions: [
0025         Kirigami.Action {
0026             text: i18n("Configure")
0027             iconName: "settings-configure"
0028             onTriggered: {
0029                 pageStack.push("qrc:/SavedCommandsSettings.qml");
0030                 savedCommandsDialog.close();
0031             }
0032         },
0033         Kirigami.Action {
0034             text: i18n("Close")
0035             iconName: "dialog-close"
0036             onTriggered: savedCommandsDialog.close()
0037         }
0038     ]
0039     
0040     ListView {
0041         id: listView
0042         model: SavedCommandsModel
0043         
0044         Kirigami.PlaceholderMessage {
0045             anchors.verticalCenter: parent.verticalCenter
0046             anchors.left: parent.left
0047             anchors.right: parent.right
0048             anchors.leftMargin: Kirigami.Units.largeSpacing
0049             anchors.rightMargin: Kirigami.Units.largeSpacing
0050             
0051             visible: listView.count === 0
0052             icon.name: "dialog-scripts"
0053             text: i18n("No saved commands")
0054             explanation: i18n("Save commands to quickly run them without typing them out.")
0055         }
0056         
0057         delegate: ItemDelegate {
0058             width: tabListView.width
0059             
0060             onClicked: {
0061                 terminal.simulateKeyPress(0, 0, 0, 0, model.display);
0062                 savedCommandsDialog.close();
0063                 terminal.forceActiveFocus()
0064             }
0065         
0066             contentItem: RowLayout {
0067                 Kirigami.Icon {
0068                     source: "dialog-scripts"
0069                 }
0070                 Label {
0071                     id: label
0072                     text: model.display
0073                     font.family: "Monospace"
0074                 }
0075                 Item {
0076                     Layout.fillWidth: true
0077                 }
0078             }
0079         }
0080     }
0081 }