Debian Codegraph @

tests/unit/layouts13/Visibility.qml

raw
1 /*
2 * Copyright 2014 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.0
18 import Lomiri.Components 1.3
19 import Lomiri.Layouts 1.0
20
21 MainView {
22 id: main
23 objectName: "mainView"
24 applicationName: "test-app"
25
26 /*
27 This property enables the application to change orientation
28 when the device is rotated. The default is false.
29 */
30 automaticOrientation: true // TODO: support wide aspect ratios, esp. on prepareGamePage
31
32 property bool boundValue: true
33
34 width: units.gu(100)
35 height: units.gu(75)
36
37 function portraitLayout() {
38 width = units.gu(50);
39 }
40 function landscapeLayout() {
41 width = units.gu(100);
42 }
43
44 PageStack {
45 Component.onCompleted: push(testPage)
46
47 Page {
48 title: i18n.tr("Conditional Layouts with PageStack")
49 id: testPage
50 visible: false
51
52 Layouts {
53 id: layouts
54 objectName: "layoutManager"
55 width: parent.width
56 height: parent.height
57 layouts: [
58 ConditionalLayout {
59 name: "wide"
60 when: layouts.width < units.gu(60)
61 LomiriShape {
62 width: units.gu(20)
63 height: units.gu(20)
64 backgroundColor: "red"
65 Label { text: "wide" }
66 }
67 }
68 ]
69
70 // This is a default layout.
71 // When using a PageStack and layouts is not empty, it won't display or switch to the default layout.
72 // However it only works when putting it into the layouts list with an inversed condition.
73 LomiriShape {
74 objectName: "DefaultLayout"
75 width: units.gu(20)
76 height: units.gu(20)
77 backgroundColor: "green"
78 visible: main.boundValue
79 Label { text: "default" }
80 }
81 }
82 }
83 }
84 }