9import QtQuick.Controls 2.15 as QQC2
10import QtQuick.Layouts 1.15
11import org.kde.kirigami 2.20 as Kirigami
12import org.kde.kirigamiaddons.delegates 1.0 as Delegates
35 property string defaultPage
40 property list<Kirigami.PagePoolAction> actions
42 property alias _stack: root
45 readonly
property string title: root.depth < 2 ?
i18ndc(
"kirigami-addons6",
"@title:window",
"Settings") :
i18ndc(
"kirigami-addons6",
"@title:window",
"Settings — %1", root.get(1).title)
47 property bool completed: false
55 function applicationWindow() {
56 return _fakeApplicationWindow;
59 readonly
property QtObject _fakeApplicationWindow: QtObject {
60 readonly
property Kirigami.PageRow pageStack: root
61 readonly
property bool controlsVisible:
true
62 readonly
property QtObject globalDrawer: null
63 readonly
property QtObject contextDrawer: null
64 readonly
property double width: root.width
65 readonly
property double height: root.height
66 readonly
property var overlay: root
70 style:
Kirigami.ApplicationHeaderStyle.ToolBar
71 showNavigationButtons:
if (root.currentIndex > 0) {
72 Kirigami.ApplicationHeaderStyle.ShowBackButton
78 signal backRequested(var event)
79 onBackRequested:
event => {
80 if (root.depth > 1 && !root.wideMode && root.currentIndex !== 0) {
81 event.accepted =
true;
86 columnView.columnWidth:
Kirigami.Units.gridUnit * 13
88 initialPage:
Kirigami.ScrollablePage {
94 titleDelegate: RowLayout {
95 Layout.fillWidth:
true
98 icon.name:
"go-previous-view"
99 text:
i18ndc(
"kirigami-addons6",
"@action:intoolbar",
"Go back")
100 display: QQC2.AbstractButton.IconOnly
101 onClicked: pageStack.layers.pop()
102 visible: pageStack.layers.depth > 1
106 Layout.fillWidth:
true
107 onTextChanged: listview.filterText = text.toLowerCase();
114 property string filterText:
""
115 property bool initDone:
false
118 topMargin: Math.round(
Kirigami.Units.smallSpacing / 2)
119 bottomMargin: Math.round(
Kirigami.Units.smallSpacing / 2)
121 onWidthChanged:
if (!initDone && root.width >=
Kirigami.Units.gridUnit * 30) {
122 let defaultAction = getActionByName(defaultPage);
124 defaultAction.trigger();
125 listview.currentIndex = indexOfAction(defaultAction);
127 actions[0].trigger();
128 listview.currentIndex = 0;
129 if (root.currentItem.title.length === 0) {
130 root.currentItem.title = actions[0].text;
136 const isFiltering = filterText.length !== 0;
137 let filteredActions = [];
138 for (let i in actions) {
139 const action = actions[i];
140 const actionPassesFilter = action.text.toLowerCase().includes(filterText);
141 if (action.visible && (isFiltering ? actionPassesFilter :
true)) {
142 filteredActions.push(action);
145 return filteredActions;
147 delegate: Delegates.RoundedItemDelegate {
150 required
property int index
151 required
property var modelData
154 checked: ListView.view.currentIndex === settingDelegate.index
157 ListView.view.currentIndex = settingDelegate.index;
158 if (root.currentItem.title.length === 0) {
159 root.currentItem.title = text;
166 Component.onCompleted: {
167 root.completed =
true;
170 function getActionByName(actionName) {
171 for (let i in actions) {
172 if (actions[i].actionName == actionName) {
178 function indexOfAction(action) {
179 for (let i in actions) {
180 if (actions[i] == action) {
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)