Debian Codegraph @

src/imports/Components/2.0/MainView.qdoc

raw
1 /*
2 * Copyright 2012-2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 /*!
18 \qmltype MainView
19 \inqmlmodule Lomiri.Components 1.2
20 \ingroup lomiri
21 \brief MainView is the root Item that should be used for all applications.
22 It automatically adds a header and toolbar for its contents and can
23 rotate its content based on the device orientation.
24
25 The simplest way to use a MainView is to include a single \l Page object
26 inside the MainView:
27 \qml
28 import QtQuick 2.4
29 import Lomiri.Components 1.2
30
31 MainView {
32 width: units.gu(48)
33 height: units.gu(60)
34
35 Page {
36 title: "Simple page"
37 Button {
38 anchors.centerIn: parent
39 text: "Push me"
40 width: units.gu(15)
41 onClicked: print("Click!")
42 }
43 }
44 }
45 \endqml
46 It is not required to set the anchors of the \l Page as it will automatically fill its parent.
47 The MainView has a header that automatically shows the title of the \l Page.
48
49 Do not include multiple Pages directly inside the MainView, but use \l Tabs
50 or \l PageStack inside MainView to navigate between several Pages.
51
52 For the MainView to automatically rotate its content following the orientation
53 of the device, set the \l automaticOrientation property to true.
54
55 If the \l Page inside the MainView includes a Flickable with enough contents for scrolling,
56 the header will automatically hide and show when the user scrolls up or down:
57 \qml
58 import QtQuick 2.4
59 import Lomiri.Components 1.2
60
61 MainView {
62 width: units.gu(48)
63 height: units.gu(60)
64
65 Page {
66 title: "Page with Flickable"
67
68 Flickable {
69 anchors.fill: parent
70 contentHeight: column.height
71
72 Column {
73 id: column
74 Repeater {
75 model: 100
76 Label {
77 text: "line "+index
78 }
79 }
80 }
81 }
82 }
83 }
84 \endqml
85 The same header behavior is automatic when using a ListView instead of a Flickable in the above
86 example.
87
88 The examples above show how to include a single \l Page inside a MainView, but more
89 advanced application structures are possible using \l PageStack and \l Tabs.
90 */
91
92
93 /*!
94 \qmlproperty string MainView::applicationName
95 The property holds the application's name, which must be the same as the
96 desktop file's name.
97 The name also sets the name of the QCoreApplication and defaults for data
98 and cache folders that work on the desktop and under confinement, as well as
99 the default gettext domain.
100 C++ code that writes files may use QStandardPaths::writableLocation with
101 QStandardPaths::DataLocation or QStandardPaths::CacheLocation.
102 */
103
104 /*!
105 \qmlproperty bool MainView::anchorToKeyboard
106 The property holds if the application should automatically resize the
107 contents when the input method appears
108
109 The default value is false.
110 */
111
112 /*!
113 \qmlproperty color MainView::headerColor
114 Color of the header's background.
115
116 \sa backgroundColor, footerColor
117 */
118
119 /*!
120 \qmlproperty color MainView::backgroundColor
121 Color of the background.
122
123 The background is usually a single color. However if \l headerColor
124 or \l footerColor are set then a gradient of colors will be drawn.
125
126 For example, in order for the MainView to draw a color gradient beneath
127 the content:
128 \qml
129 import QtQuick 2.4
130 import Lomiri.Components 1.2
131
132 MainView {
133 width: units.gu(40)
134 height: units.gu(60)
135
136 headerColor: "#343C60"
137 backgroundColor: "#6A69A2"
138 footerColor: "#8896D5"
139 }
140 \endqml
141
142 \sa footerColor, headerColor
143 */
144
145 /*!
146 \qmlproperty color MainView::footerColor
147 Color of the footer's background.
148
149 \sa backgroundColor, headerColor
150 */
151
152 /*!
153 \qmlproperty bool MainView::active
154 MainView is active by default.
155 */
156
157 /*!
158 \qmlproperty bool MainView::automaticOrientation
159
160 Sets whether the application will be automatically rotating when the
161 device is.
162
163 The default value is false.
164 */
165
166 /*!
167 \deprecated
168 \qmlproperty bool MainView::useDeprecatedToolbar
169 Setting this option will enable the old toolbar, and disable the new features
170 that are being added to the new header. Unsetting it removes the toolbar and
171 enables developers to have a sneak peek at the new features that are coming to
172 the header, even before all the required functionality is implemented.
173 Default value up to version 1.1: true.
174 NOT AVAILABLE in version 1.2 where the deprecated toolbar is not supported.
175 */
176
177 /*!
178 \qmlproperty list<Action> MainView::actions
179 A global list of actions that will be available to the system (including HUD)
180 as long as the application is running. For actions that are not always available to the
181 system, but only when a certain \l Page is active, see the actions property of \l Page.
182 */
183
184 /*!
185 \qmlproperty ActionManager MainView::actionManager
186 \readonly
187
188 The ActionManager that supervises the global and local ActionContexts.
189 The \l actions property should be used preferably since it covers most
190 use cases. The ActionManager is accessible to have a more refined control
191 over the actions, e.g. if one wants to add/remove actions dynamically, create
192 specific action contexts, etc.
193 */