9import QtQuick.Controls as QQC2
11import org.kde.kirigami as Kirigami
12import org.kde.kirigamiaddons.delegates as Delegates
13import org.kde.kirigamiaddons.settings
15Kirigami.ApplicationWindow {
18 required property string defaultModule
19 required property list<ConfigurationModule> modules
22 property var pageCache:
Object.create(null)
25 columnView.columnWidth:
Kirigami.Units.gridUnit * 13
30 style:
Kirigami.ApplicationHeaderStyle.ToolBar
31 showNavigationButtons: root.pageStack.depth > 1 ?
Kirigami.ApplicationHeaderStyle.ShowBackButton :
Kirigami.ApplicationHeaderStyle.NoNavigationButtons
35 contentItem.Keys.onEscapePressed: root.close()
37 globalDrawer:
Kirigami.OverlayDrawer {
39 edge:
Qt.application.layoutDirection ===
Qt.RightToLeft ?
Qt.RightEdge :
Qt.LeftEdge
54 contentItem: ColumnLayout {
58 Layout.fillWidth:
true
59 Layout.preferredHeight: pageStack.globalToolBar.preferredHeight
69 Layout.fillWidth:
true
70 onTextChanged: listview.filterText = text.toLowerCase();
75 Layout.fillWidth:
true
76 Layout.fillHeight:
true
81 property string filterText:
""
82 property bool initDone:
false
86 onWidthChanged:
if (!initDone) {
87 let module = getModuleByName(defaultModule);
89 root.pageStack.push(pageForModule(module));
90 listview.currentIndex = modules.findIndex(module => module.moduleId == defaultModule);
92 root.pageStack.push(pageForModule(modules[0]));
93 listview.currentIndex = 0;
94 if (root.pageStack.currentItem.title.length === 0) {
95 root.pageStack.currentItem.title = modules[0].text;
101 const isFiltering = filterText.length !== 0;
102 let filteredModules = [];
103 for (
const module of root.modules) {
104 const modulePassesFilter =
module.text.toLowerCase().includes(filterText);
105 if (module.visible && (isFiltering ? modulePassesFilter :
true)) {
106 filteredModules.push(module);
109 return filteredModules;
111 delegate: Delegates.RoundedItemDelegate {
114 required
property int index
118 icon.name: modelData.icon.name
119 icon.source: modelData.icon.source
120 checked: ListView.view.currentIndex === settingDelegate.index
123 const page = pageForModule(modelData);
124 if (ListView.view.currentIndex === settingDelegate.index) {
127 root.pageStack.replace(page);
129 ListView.view.currentIndex = settingDelegate.index;
130 if (root.pageStack.currentItem.title.length === 0) {
131 root.pageStack.currentItem.title = text;
141 if (pageCache[module.moduleId]) {
142 return pageCache[module.moduleId];
144 const component =
module.page();
146 console.error(
"Unable to create component for moduleId", module.moduleId);
150 if (component.status === Component.Error) {
151 console.error(`Unable to create component
for moduleId:
"${module.moduleId}". Error: ${component.errorString()}`);
155 const page = component.createObject(root, module.initialProperties());
156 if (page.title.length === 0) {
157 page.title =
module.text;
159 pageCache[module.moduleId] = page;
165 return modules.
find(module => module.moduleId == moduleId) ?? null;
This object holds the information of configuration module.
string text
This property holds the name of the module.
const QList< QKeySequence > & find()