Warning, /frameworks/kirigami/src/controls/ApplicationItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import org.kde.kirigami 2.4 as Kirigami 0009 0010 /** 0011 * @brief An item that provides the features of ApplicationWindow without the window itself. 0012 * 0013 * This allows embedding into a larger application. 0014 * It's based around the PageRow component that allows adding/removing of pages. 0015 * 0016 * Example usage: 0017 * @code{.qml} 0018 * import org.kde.kirigami 2.4 as Kirigami 0019 * 0020 * Kirigami.ApplicationItem { 0021 * globalDrawer: Kirigami.GlobalDrawer { 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 * } 0040 * ] 0041 * } 0042 * 0043 * contextDrawer: Kirigami.ContextDrawer { 0044 * id: contextDrawer 0045 * } 0046 * 0047 * pageStack.initialPage: Kirigami.Page { 0048 * actions { 0049 * main: Kirigami.Action { 0050 * icon.name: "edit" 0051 * onTriggered: { 0052 * // do stuff 0053 * } 0054 * } 0055 * contextualActions: [ 0056 * Kirigami.Action { 0057 * icon.name: "edit" 0058 * text: "Action text" 0059 * onTriggered: { 0060 * // do stuff 0061 * } 0062 * }, 0063 * Kirigami.Action { 0064 * icon.name: "edit" 0065 * text: "Action text" 0066 * onTriggered: { 0067 * // do stuff 0068 * } 0069 * } 0070 * ] 0071 * [...] 0072 * } 0073 * } 0074 * } 0075 * @endcode 0076 */ 0077 Kirigami.AbstractApplicationItem { 0078 id: root 0079 0080 /** 0081 * @brief This property holds the PageRow that is used to allocate 0082 * the pages and manage the transitions between them. 0083 * 0084 * @see kirigami::PageRow 0085 * @warning This property is not currently readonly, but it should be treated like it is readonly. 0086 * @property Kirigami.PageRow pageStack 0087 */ 0088 property alias pageStack: __pageStack // TODO KF6 make readonly 0089 0090 // Redefines here as here we can know a pointer to PageRow 0091 wideScreen: width >= applicationWindow().pageStack.defaultColumnWidth * 2 0092 0093 Component.onCompleted: { 0094 if (pageStack.currentItem) { 0095 pageStack.currentItem.forceActiveFocus(); 0096 } 0097 } 0098 0099 Kirigami.PageRow { 0100 id: __pageStack 0101 anchors { 0102 fill: parent 0103 // HACK: workaround a bug in android iOS keyboard management 0104 bottomMargin: ((Qt.platform.os === "android" || Qt.platform.os === "ios") || !Qt.inputMethod.visible) ? 0 : Qt.inputMethod.keyboardRectangle.height 0105 onBottomMarginChanged: { 0106 if (bottomMargin > 0) { 0107 root.reachableMode = false; 0108 } 0109 } 0110 } 0111 // FIXME 0112 onCurrentIndexChanged: root.reachableMode = false; 0113 0114 function goBack() { 0115 // NOTE: drawers are handling the back button by themselves 0116 const backEvent = {accepted: false} 0117 if (root.pageStack.currentIndex >= 1) { 0118 root.pageStack.currentItem.backRequested(backEvent); 0119 if (!backEvent.accepted) { 0120 root.pageStack.flickBack(); 0121 backEvent.accepted = true; 0122 } 0123 } 0124 0125 if (Kirigami.Settings.isMobile && !backEvent.accepted && Qt.platform.os !== "ios") { 0126 Qt.quit(); 0127 } 0128 } 0129 function goForward() { 0130 root.pageStack.currentIndex = Math.min(root.pageStack.depth - 1, root.pageStack.currentIndex + 1); 0131 } 0132 Keys.onBackPressed: event => { 0133 goBack(); 0134 event.accepted = true; 0135 } 0136 Shortcut { 0137 sequences: [StandardKey.Forward] 0138 onActivated: __pageStack.goForward(); 0139 } 0140 Shortcut { 0141 sequences: [StandardKey.Back] 0142 onActivated: __pageStack.goBack(); 0143 } 0144 0145 background: Rectangle { 0146 color: root.color 0147 } 0148 0149 focus: true 0150 } 0151 }