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
34 property string defaultPage
39 property list<Kirigami.PagePoolAction> actions
41 property alias _stack: root
44 readonly
property string title: root.depth < 2 ?
i18ndc(
"kirigami-addons6",
"@title:window",
"Settings") :
i18ndc(
"kirigami-addons6",
"@title:window",
"Settings — %1", root.get(1).title)
46 property bool completed: false
54 function applicationWindow() {
55 return _fakeApplicationWindow;
58 readonly
property QtObject _fakeApplicationWindow: QtObject {
59 readonly
property Kirigami.PageRow pageStack: root
60 readonly
property bool controlsVisible:
true
61 readonly
property QtObject globalDrawer: null
62 readonly
property QtObject contextDrawer: null
63 readonly
property double width: root.width
64 readonly
property double height: root.height
65 readonly
property var overlay: root
69 style:
Kirigami.ApplicationHeaderStyle.ToolBar
70 showNavigationButtons:
if (root.currentIndex > 0) {
71 Kirigami.ApplicationHeaderStyle.ShowBackButton
77 signal backRequested(var event)
78 onBackRequested:
event => {
79 if (root.depth > 1 && !root.wideMode && root.currentIndex !== 0) {
80 event.accepted =
true;
85 columnView.columnWidth:
Kirigami.Units.gridUnit * 13
87 initialPage:
Kirigami.ScrollablePage {
93 titleDelegate: RowLayout {
94 Layout.fillWidth:
true
97 icon.name:
"go-previous-view"
98 text:
i18nc(
"@action:intoolbar",
"Go back")
99 display: QQC2.AbstractButton.IconOnly
100 onClicked: pageStack.layers.pop()
101 visible: pageStack.layers.depth > 1
105 Layout.fillWidth:
true
106 onTextChanged: listview.filterText = text.toLowerCase();
113 property string filterText:
""
114 property bool initDone:
false
117 topMargin: Math.round(
Kirigami.Units.smallSpacing / 2)
118 bottomMargin: Math.round(
Kirigami.Units.smallSpacing / 2)
120 onWidthChanged:
if (!initDone && root.width >=
Kirigami.Units.gridUnit * 30) {
121 let defaultAction = getActionByName(defaultPage);
123 defaultAction.trigger();
124 listview.currentIndex = indexOfAction(defaultAction);
126 actions[0].trigger();
127 listview.currentIndex = 0;
128 if (root.currentItem.title.length === 0) {
129 root.currentItem.title = actions[0].text;
135 const isFiltering = filterText.length !== 0;
136 let filteredActions = [];
137 for (let i in actions) {
138 const action = actions[i];
139 const actionPassesFilter = action.text.toLowerCase().includes(filterText);
140 if (action.visible && (isFiltering ? actionPassesFilter : true)) {
141 filteredActions.push(action);
144 return filteredActions;
146 delegate: Delegates.RoundedItemDelegate {
149 required
property int index
150 required
property var modelData
153 checked: ListView.view.currentIndex === settingDelegate.index
156 ListView.view.currentIndex = settingDelegate.index;
157 if (root.currentItem.title.length === 0) {
158 root.currentItem.title = text;
165 Component.onCompleted: {
166 root.completed =
true;
169 function getActionByName(actionName) {
170 for (let i in actions) {
171 if (actions[i].actionName == actionName) {
177 function indexOfAction(action) {
178 for (let i in actions) {
179 if (actions[i] == action) {
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)