Warning, /frameworks/kirigami/examples/simpleexamples/AbstractApplicationWindow.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls as QQC2 0010 import org.kde.kirigami as Kirigami 0011 0012 Kirigami.AbstractApplicationWindow { 0013 id: root 0014 0015 width: 500 0016 height: 800 0017 visible: true 0018 0019 globalDrawer: Kirigami.GlobalDrawer { 0020 title: "Widget gallery" 0021 titleIcon: "applications-graphics" 0022 actions: [ 0023 Kirigami.Action { 0024 text: "View" 0025 icon.name: "view-list-icons" 0026 Kirigami.Action { 0027 text: "action 1" 0028 } 0029 Kirigami.Action { 0030 text: "action 2" 0031 } 0032 Kirigami.Action { 0033 text: "action 3" 0034 } 0035 }, 0036 Kirigami.Action { 0037 text: "Sync" 0038 icon.name: "folder-sync" 0039 Kirigami.Action { 0040 text: "action 4" 0041 } 0042 Kirigami.Action { 0043 text: "action 5" 0044 } 0045 }, 0046 Kirigami.Action { 0047 text: "Checkable" 0048 icon.name: "view-list-details" 0049 checkable: true 0050 checked: false 0051 onTriggered: { 0052 print("Action checked:" + checked) 0053 } 0054 }, 0055 Kirigami.Action { 0056 text: "Settings" 0057 icon.name: "configure" 0058 checkable: true 0059 //Need to do this, otherwise it breaks the bindings 0060 property bool current: pageStack.currentItem?.objectName === "settingsPage" ?? false 0061 onCurrentChanged: { 0062 checked = current; 0063 } 0064 onTriggered: { 0065 pageStack.push(settingsComponent); 0066 } 0067 } 0068 ] 0069 0070 QQC2.CheckBox { 0071 checked: true 0072 text: "Option 1" 0073 } 0074 QQC2.CheckBox { 0075 text: "Option 2" 0076 } 0077 QQC2.CheckBox { 0078 text: "Option 3" 0079 } 0080 QQC2.Slider { 0081 Layout.fillWidth: true 0082 value: 0.5 0083 } 0084 } 0085 contextDrawer: Kirigami.ContextDrawer { 0086 id: contextDrawer 0087 } 0088 0089 pageStack: QQC2.StackView { 0090 anchors.fill: parent 0091 property int currentIndex: 0 0092 focus: true 0093 onCurrentIndexChanged: { 0094 if (depth > currentIndex + 1) { 0095 pop(get(currentIndex)); 0096 } 0097 } 0098 onDepthChanged: { 0099 currentIndex = depth-1; 0100 } 0101 initialItem: mainPageComponent 0102 0103 Keys.onReleased: event => { 0104 if (event.key === Qt.Key_Back || 0105 (event.key === Qt.Key_Left && (event.modifiers & Qt.AltModifier))) { 0106 event.accepted = true; 0107 if (root.contextDrawer && root.contextDrawer.drawerOpen) { 0108 root.contextDrawer.close(); 0109 } else if (root.globalDrawer && root.globalDrawer.drawerOpen) { 0110 root.globalDrawer.close(); 0111 } else { 0112 var backEvent = {accepted: false} 0113 if (root.pageStack.currentIndex >= 1) { 0114 root.pageStack.currentItem.backRequested(backEvent); 0115 if (!backEvent.accepted) { 0116 if (root.pageStack.depth > 1) { 0117 root.pageStack.currentIndex = Math.max(0, root.pageStack.currentIndex - 1); 0118 backEvent.accepted = true; 0119 } else { 0120 Qt.quit(); 0121 } 0122 } 0123 } 0124 0125 if (!backEvent.accepted) { 0126 Qt.quit(); 0127 } 0128 } 0129 } 0130 } 0131 } 0132 0133 Component { 0134 id: settingsComponent 0135 Kirigami.Page { 0136 title: "Settings" 0137 objectName: "settingsPage" 0138 Rectangle { 0139 anchors.fill: parent 0140 } 0141 } 0142 } 0143 0144 //Main app content 0145 Component { 0146 id: mainPageComponent 0147 MultipleColumnsGallery {} 0148 } 0149 }