Kirigami2

ApplicationWindow.qml
1/*
2 * SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7import QtQuick
8import org.kde.kirigami 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 as Kirigami
28 *
29 * Kirigami.ApplicationWindow {
30 * [...]
31 * globalDrawer: Kirigami.GlobalDrawer {
32 * actions: [
33 * Kirigami.Action {
34 * text: "View"
35 * icon.name: "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 * icon.name: "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 * icon.name: "edit"
60 * onTriggered: {
61 * // do stuff
62 * }
63 * }
64 * contextualActions: [
65 * Kirigami.Action {
66 * icon.name: "edit"
67 * text: "Action text"
68 * onTriggered: {
69 * // do stuff
70 * }
71 * },
72 * Kirigami.Action {
73 * icon.name: "edit"
74 * text: "Action text"
75 * onTriggered: {
76 * // do stuff
77 * }
78 * }
79 * ]
80 * [...]
81 * }
82 * [...]
83 * }
84 * @endcode
85 *
86*/
87Kirigami.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 * @property org::kde::kirigami::PageRow pageStack
100 */
101 readonly property alias pageStack: __pageStack
102
103 // Redefined here as here we can know a pointer to PageRow.
104 // 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
105 wideScreen: width >= (root.pageStack.defaultColumnWidth) + ((contextDrawer && !(contextDrawer instanceof Kirigami.ContextDrawer)) ? contextDrawer.width : 0) + (globalDrawer ? globalDrawer.width : 0)
106
107 Component.onCompleted: {
108 pageStack.currentItem?.forceActiveFocus()
109 }
110
111 Kirigami.PageRow {
112 id: __pageStack
113 globalToolBar.style: Kirigami.ApplicationHeaderStyle.Auto
114 anchors {
115 fill: parent
116 }
117
118 focus: true
119 }
120}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:05:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.