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 2.15 0008 import QtQuick.Layouts 1.15 0009 import QtQuick.Controls 2.15 as QQC2 0010 import org.kde.kirigami 2.20 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 0023 actions: [ 0024 Kirigami.Action { 0025 text: "View" 0026 icon.name: "view-list-icons" 0027 Kirigami.Action { 0028 text: "action 1" 0029 } 0030 Kirigami.Action { 0031 text: "action 2" 0032 } 0033 Kirigami.Action { 0034 text: "action 3" 0035 } 0036 }, 0037 Kirigami.Action { 0038 text: "Sync" 0039 icon.name: "folder-sync" 0040 Kirigami.Action { 0041 text: "action 4" 0042 } 0043 Kirigami.Action { 0044 text: "action 5" 0045 } 0046 }, 0047 Kirigami.Action { 0048 text: "Checkable" 0049 icon.name: "view-list-details" 0050 checkable: true 0051 checked: false 0052 onTriggered: { 0053 print("Action checked:" + checked) 0054 } 0055 }, 0056 Kirigami.Action { 0057 text: "Settings" 0058 icon.name: "configure" 0059 checkable: true 0060 //Need to do this, otherwise it breaks the bindings 0061 property bool current: pageStack.currentItem ? pageStack.currentItem.objectName == "settingsPage" : false 0062 onCurrentChanged: { 0063 checked = current; 0064 } 0065 onTriggered: { 0066 pageStack.push(settingsComponent); 0067 } 0068 } 0069 ] 0070 0071 QQC2.CheckBox { 0072 checked: true 0073 text: "Option 1" 0074 } 0075 QQC2.CheckBox { 0076 text: "Option 2" 0077 } 0078 QQC2.CheckBox { 0079 text: "Option 3" 0080 } 0081 QQC2.Slider { 0082 Layout.fillWidth: true 0083 value: 0.5 0084 } 0085 } 0086 contextDrawer: Kirigami.ContextDrawer { 0087 id: contextDrawer 0088 } 0089 0090 pageStack: QQC2.StackView { 0091 anchors.fill: parent 0092 property int currentIndex: 0 0093 focus: true 0094 onCurrentIndexChanged: { 0095 if (depth > currentIndex+1) { 0096 pop(get(currentIndex)); 0097 } 0098 } 0099 onDepthChanged: { 0100 currentIndex = depth-1; 0101 } 0102 initialItem: mainPageComponent 0103 0104 Keys.onReleased: event => { 0105 if (event.key === Qt.Key_Back || 0106 (event.key === Qt.Key_Left && (event.modifiers & Qt.AltModifier))) { 0107 event.accepted = true; 0108 if (root.contextDrawer && root.contextDrawer.drawerOpen) { 0109 root.contextDrawer.close(); 0110 } else if (root.globalDrawer && root.globalDrawer.drawerOpen) { 0111 root.globalDrawer.close(); 0112 } else { 0113 var backEvent = {accepted: false} 0114 if (root.pageStack.currentIndex >= 1) { 0115 root.pageStack.currentItem.backRequested(backEvent); 0116 if (!backEvent.accepted) { 0117 if (root.pageStack.depth > 1) { 0118 root.pageStack.currentIndex = Math.max(0, root.pageStack.currentIndex - 1); 0119 backEvent.accepted = true; 0120 } else { 0121 Qt.quit(); 0122 } 0123 } 0124 } 0125 0126 if (!backEvent.accepted) { 0127 Qt.quit(); 0128 } 0129 } 0130 } 0131 } 0132 } 0133 0134 Component { 0135 id: settingsComponent 0136 Kirigami.Page { 0137 title: "Settings" 0138 objectName: "settingsPage" 0139 Rectangle { 0140 anchors.fill: parent 0141 } 0142 } 0143 } 0144 0145 //Main app content 0146 Component { 0147 id: mainPageComponent 0148 MultipleColumnsGallery {} 0149 } 0150 }