Debian Codegraph @

src/imports/Components/2.0/PageColumnsLayout.qml

raw
1 /*
2 * Copyright 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 import QtQuick 2.4
18
19 /*!
20 \qmltype PageColumnsLayout
21 \inqmlmodule Lomiri.Components
22 \since Lomiri.Components 1.3
23 \ingroup lomiri
24 \brief Component configuring a layout in an AdaptivePageLayout component.
25
26 The component specifies the column configuration of a specific layout. The layout
27 will have as many columns as many PageColumn elements will be declared. The layout
28 will be activated when the \l when property evaluates to \c true. There can be
29 many layouts evaluated to true, only the first one evaluated to true in the
30 \l AdaptivePageLayout::layouts list will be activated.
31
32 \qml
33 import QtQuick 2.4
34 import Lomiri.Components
35
36 MainView {
37 width: units.gu(100)
38 height: units.gu(60)
39
40 AdaptivePageLayout {
41 anchors.fill: parent
42 primaryPage: page1
43 layouts: [
44 PageColumnsLayout {
45 when: width > units.gu(80)
46 // column #0
47 PageColumn {
48 minimumWidth: units.gu(30)
49 maximumWidth: units.gu(60)
50 preferredWidth: units.gu(40)
51 }
52 // column #1
53 PageColumn {
54 fillWidth: true
55 }
56 },
57 PageColumnsLayout {
58 when: true
59 PageColumn {
60 fillWidth: true
61 minimumWidth: units.gu(10)
62 }
63 }
64 ]
65
66 Page {
67 id: page1
68 title: "Main page"
69 Column {
70 Button {
71 text: "Add Page2 above " + page1.title
72 onClicked: page1.pageStack.addPageToCurrentColumn(page1, page2)
73 }
74 Button {
75 text: "Add Page3 next to " + page1.title
76 onClicked: page1.pageStack.addPageToNextColumn(page1, page3)
77 }
78 }
79 }
80 Page {
81 id: page2
82 title: "Page #2"
83 }
84 Page {
85 id: page3
86 title: "Page #3"
87 }
88 }
89 }
90 \endqml
91 In the example above the second PageColumnLayout's condition is always set to
92 true, which means that that the layout will be always active unless the first
93 layout's condition evaluates to true. The layout overrides the single column
94 minimumWidth default value. Note that \l PageColumn::fillWidth must be also set.
95
96 \note When none of the conditions is met, a single column layout will be used.
97
98 \sa PageColumn
99 */
100 QtObject {
101 id: layout
102
103 /*!
104 Condition activating the layout. Defaults to false.
105 */
106 property bool when: false
107
108 /*!
109 \qmlproperty list<PageColumn> data
110 \default
111 Default property holding the PageColumn elements configuring each column.
112 */
113 default property alias data: layout.__data
114 property list<PageColumn> __data
115 }