Warning, /multimedia/haruna/src/qml/Settings/ShortcutsSettings.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2022 George Florea Bănuș <georgefb899@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 import QtQml
0008 import QtQuick
0009 import QtQuick.Layouts
0010 import QtQuick.Controls
0011 import QtQuick.Dialogs
0012 
0013 import org.kde.kirigami as Kirigami
0014 import org.kde.kquickcontrols
0015 import org.kde.haruna
0016 
0017 SettingsBasePage {
0018     id: root
0019 
0020     hasHelp: false
0021     helpFile: ""
0022 
0023     onVisibleChanged: {
0024         if (!visible) {
0025             proxyActionsModel.setNameFilter("")
0026         }
0027     }
0028 
0029     header: ToolBar {
0030         width: parent.width
0031 
0032         RowLayout {
0033             anchors.fill: parent
0034 
0035             Kirigami.SearchField {
0036                 id: searchField
0037 
0038                 focus: true
0039                 onAccepted: proxyActionsModel.setNameFilter(text)
0040                 Layout.fillWidth: true
0041                 KeyNavigation.up: actionsListView
0042                 KeyNavigation.down: actionsListView
0043                 Component.onCompleted: forceActiveFocus()
0044             }
0045         }
0046     }
0047     ListView {
0048         id: actionsListView
0049 
0050         model: proxyActionsModel
0051 
0052         delegate: ItemDelegate {
0053             width: actionsListView.width
0054 
0055             contentItem: RowLayout {
0056                 Kirigami.IconTitleSubtitle {
0057                     title: model.text
0058                     icon.name: model.icon
0059 
0060                     Layout.fillWidth: true
0061                 }
0062 
0063                 KeySequenceItem {
0064                     checkForConflictsAgainst: ShortcutType.None
0065                     modifierlessAllowed: true
0066                     keySequence: model.shortcut
0067 
0068                     onKeySequenceChanged: {
0069                         if (keySequence !== model.shortcut) {
0070                             if (!proxyActionsModel.saveShortcut(model.index, keySequence)) {
0071                                 keySequence = model.shortcut
0072                             }
0073                         }
0074                     }
0075                 }
0076             }
0077         }
0078         KeyNavigation.down: searchField
0079         KeyNavigation.up: searchField
0080         Keys.onPressed: {
0081             if (event.key === Qt.Key_End) {
0082                 actionsListView.currentIndex = actionsListView.count - 1
0083                 actionsListView.positionViewAtIndex(actionsListView.currentIndex,ListView.Center)
0084             }
0085             if (event.key === Qt.Key_Home) {
0086                 actionsListView.currentIndex = 0
0087                 actionsListView.positionViewAtIndex(actionsListView.currentIndex,ListView.Center)
0088             }
0089         }
0090     }
0091 }