Warning, /multimedia/haruna/src/qml/Haruna/Components/SelectActionPopup.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com>
0003 *
0004 * SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Controls
0009 import QtQuick.Layouts
0010 import org.kde.kirigami as Kirigami
0011
0012 import org.kde.haruna
0013
0014 Popup {
0015 id: root
0016
0017 property string title: ""
0018 property string subtitle: ""
0019 property int buttonIndex: -1
0020
0021 signal actionSelected(string actionName)
0022
0023 implicitHeight: parent.height * 0.9
0024 implicitWidth: parent.width * 0.9
0025 modal: true
0026 anchors.centerIn: parent
0027 focus: true
0028
0029 onOpened: {
0030 actionsListView.positionViewAtBeginning()
0031 filterActionsField.selectAll()
0032 filterActionsField.focus = true
0033 }
0034
0035 onActionSelected: close()
0036
0037 ColumnLayout {
0038 anchors.fill: parent
0039
0040 Kirigami.Heading {
0041 text: root.title
0042 visible: text !== ""
0043 }
0044
0045 Label {
0046 text: root.subtitle
0047 visible: text !== ""
0048 Layout.fillWidth: true
0049 Layout.alignment: Qt.AlignTop
0050 }
0051
0052 Kirigami.SearchField {
0053 id: filterActionsField
0054
0055 focus: true
0056 onAccepted: selectActionModel.setNameFilter(text)
0057 Layout.fillWidth: true
0058 Layout.alignment: Qt.AlignTop
0059 KeyNavigation.up: actionsListView
0060 KeyNavigation.down: actionsListView
0061 KeyNavigation.tab: actionsListView
0062 Keys.onReturnPressed: {
0063 actionSelected(actionsListView.currentItem.actionName)
0064 }
0065 Keys.onEnterPressed: {
0066 actionSelected(actionsListView.currentItem.actionName)
0067 }
0068 }
0069
0070 ScrollView {
0071 Layout.fillWidth: true
0072 Layout.fillHeight: true
0073 Layout.alignment: Qt.AlignTop
0074
0075 ListView {
0076 id: actionsListView
0077
0078 model: ProxyActionsModel {
0079 id: selectActionModel
0080
0081 sourceModel: actionsModel
0082 }
0083
0084 spacing: 1
0085 clip: true
0086 delegate: ItemDelegate {
0087 property string actionName: model.name
0088
0089 width: actionsListView.width
0090
0091 contentItem: RowLayout {
0092 Label {
0093 text: model.text
0094
0095 Layout.fillWidth: true
0096 }
0097
0098 Label {
0099 text: model.shortcut
0100 opacity: 0.7
0101 }
0102 }
0103 onClicked: actionSelected(model.name)
0104 Keys.onEnterPressed: actionSelected(model.name)
0105 Keys.onReturnPressed: actionSelected(model.name)
0106 }
0107
0108 KeyNavigation.up: filterActionsField
0109 KeyNavigation.down: filterActionsField
0110 Keys.onPressed: {
0111 if (event.key === Qt.Key_End) {
0112 actionsListView.currentIndex = actionsListView.count - 1
0113 actionsListView.positionViewAtEnd()
0114 }
0115 if (event.key === Qt.Key_Home) {
0116 actionsListView.currentIndex = 0
0117 actionsListView.positionViewAtBeginning()
0118 }
0119 }
0120 }
0121 }
0122 }
0123 }