Kirigami2

ApplicationWindow.qml
1 /*
2  * SPDX-FileCopyrightText: 2015 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.5
8 import org.kde.kirigami 2.4 as Kirigami
9 
10 /**
11  * @brief A window that provides some basic features needed for all apps
12  *
13  * It's usually used as a root QML component for the application.
14  * It's based around the PageRow component, the application will be
15  * about pages adding and removal.
16  * For most of the usages, this class should be used instead
17  * of AbstractApplicationWindow
18  * @see AbstractApplicationWindow
19  *
20  * Setting a width and height property on the ApplicationWindow
21  * will set its initial size, but it won't set it as an automatically binding.
22  * to resize programmatically the ApplicationWindow they need to
23  * be assigned again in an imperative fashion
24  *
25  * Example usage:
26  * @code
27  * import org.kde.kirigami 2.4 as Kirigami
28  *
29  * Kirigami.ApplicationWindow {
30  * [...]
31  * globalDrawer: Kirigami.GlobalDrawer {
32  * actions: [
33  * Kirigami.Action {
34  * text: "View"
35  * iconName: "view-list-icons"
36  * Kirigami.Action {
37  * text: "action 1"
38  * }
39  * Kirigami.Action {
40  * text: "action 2"
41  * }
42  * Kirigami.Action {
43  * text: "action 3"
44  * }
45  * },
46  * Kirigami.Action {
47  * text: "Sync"
48  * iconName: "folder-sync"
49  * }
50  * ]
51  * }
52  *
53  * contextDrawer: Kirigami.ContextDrawer {
54  * id: contextDrawer
55  * }
56  *
57  * pageStack.initialPage: Kirigami.Page {
58  * mainAction: Kirigami.Action {
59  * iconName: "edit"
60  * onTriggered: {
61  * // do stuff
62  * }
63  * }
64  * contextualActions: [
65  * Kirigami.Action {
66  * iconName: "edit"
67  * text: "Action text"
68  * onTriggered: {
69  * // do stuff
70  * }
71  * },
72  * Kirigami.Action {
73  * iconName: "edit"
74  * text: "Action text"
75  * onTriggered: {
76  * // do stuff
77  * }
78  * }
79  * ]
80  * [...]
81  * }
82  * [...]
83  * }
84  * @endcode
85  *
86 */
87 Kirigami.AbstractApplicationWindow {
88  id: root
89 
90  /**
91  * @brief This property holds the stack used to allocate the pages and to
92  * manage the transitions between them.
93  *
94  * It's using a PageRow, while having the same API as PageStack,
95  * it positions the pages as adjacent columns, with as many columns
96  * as can fit in the screen. An handheld device would usually have a single
97  * fullscreen column, a tablet device would have many tiled columns.
98  *
99  * @warning This property is not currently readonly, but it should be treated like it is readonly.
100  * @property org::kde::kirigami::PageRow pageStack
101  */
102  property alias pageStack: __pageStack // TODO KF6 make readonly
103 
104  // Redefined here as here we can know a pointer to PageRow.
105  // We negate the canBeEnabled check because we don't want to factor in the automatic drawer provided by Kirigami for page actions for our calculations
106  wideScreen: width >= (root.pageStack.defaultColumnWidth) + ((contextDrawer && !(contextDrawer instanceof Kirigami.ContextDrawer)) ? contextDrawer.width : 0) + (globalDrawer ? globalDrawer.width : 0)
107 
108  Component.onCompleted: {
109  if (pageStack.currentItem) {
110  pageStack.currentItem.forceActiveFocus()
111  }
112  }
113 
114  PageRow {
115  id: __pageStack
116  globalToolBar.style: Kirigami.ApplicationHeaderStyle.Auto
117  anchors {
118  fill: parent
119  // HACK: workaround a bug in android iOS keyboard management
120  bottomMargin: ((Qt.platform.os === "android" || Qt.platform.os === "ios") || !Qt.inputMethod.visible) ? 0 : Qt.inputMethod.keyboardRectangle.height
121  onBottomMarginChanged: {
122  if (__pageStack.anchors.bottomMargin > 0) {
123  root.reachableMode = false;
124  }
125  }
126  }
127  // FIXME
128  onCurrentIndexChanged: root.reachableMode = false;
129 
130  focus: true
131  }
132 }
PageRow implements a row-based navigation model, which can be used with a set of interlinked informat...
Definition: PageRow.qml:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.