Warning, /maui/station/src/widgets/CommandShortcuts.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.15
0002 import QtQuick.Controls 2.14
0003 import QtQuick.Layouts 1.3
0004 import org.mauikit.controls 1.3 as Maui
0005 
0006 import org.maui.station 1.0 as Station
0007 
0008 Maui.PopupPage
0009 {
0010     id: control
0011     maxHeight: 600
0012     maxWidth: 400
0013 
0014     persistent: false
0015 
0016     headBar.visible: true
0017     signal commandTriggered(string command)
0018 
0019     headBar.middleContent: TextField
0020     {
0021         Layout.fillWidth: true
0022         Layout.maximumWidth: 500
0023         onAccepted: _commandsList.insert(text)
0024         placeholderText: i18n("New Command")
0025 
0026     }
0027 
0028     Maui.InputDialog
0029     {
0030         id: _editCommandDialog
0031         property int index : -1
0032 
0033         title: i18n("Edit Command")
0034         message: i18n("Edit a command shortcut")
0035 
0036         onFinished: _commandsList.edit(index, text)
0037     }
0038 
0039 
0040     stack: Maui.ListBrowser
0041     {
0042         id: _commandsShortcutList
0043         Layout.fillWidth: true
0044         Layout.fillHeight: true
0045 
0046         holder.visible: _commandsShortcutList.count === 0
0047         holder.emoji: "qrc:/station/edit-rename.svg"
0048         holder.title: i18n("No Commands")
0049         holder.body: i18n("Start adding new command shortcuts")
0050 
0051         model: Maui.BaseModel
0052         {
0053             list: Station.CommandsModel
0054             {
0055                 id: _commandsList
0056             }
0057         }
0058 
0059         delegate: Maui.ListBrowserDelegate
0060         {
0061             width: ListView.view.width
0062             label1.text: model.value
0063 
0064             onClicked:
0065             {
0066                 _commandsShortcutList.currentIndex = index
0067                 commandTriggered(model.value)
0068                 control.close()
0069             }
0070 
0071             onRightClicked:
0072             {
0073                 _commandsShortcutList.currentIndex = index
0074                 _menu.popup()
0075             }
0076 
0077             onPressAndHold:
0078             {
0079                 _commandsShortcutList.currentIndex = index
0080                 _menu.popup()
0081             }
0082         }
0083     }
0084 
0085     Menu
0086     {
0087         id: _menu
0088 
0089         MenuItem
0090         {
0091             text: i18n("Remove")
0092             icon.name: "edit-clear"
0093             onTriggered:
0094             {
0095                 _commandsList.remove(index)
0096             }
0097         }
0098 
0099         MenuItem
0100         {
0101             text: i18n("Edit")
0102             icon.name: "edit-rename"
0103             onTriggered:
0104             {
0105                 _editCommandDialog.index= _commandsShortcutList.currentIndex
0106                 _editCommandDialog.textEntry.text = _commandsShortcutList.model.get(_commandsShortcutList.currentIndex).value
0107                 _editCommandDialog.open()
0108             }
0109         }
0110     }
0111 }