Unity 8
Page.qml
1 /*
2  * Copyright (C) 2013,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 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 import QtQuick 2.4
18 import Ubuntu.Components 1.3
19 
20 Item {
21  readonly property real buttonMargin: units.gu(2)
22  readonly property real buttonWidth: (width - buttonMargin * 2) / 2 -
23  buttonMargin / 2
24  readonly property real topMargin: units.gu(8)
25  readonly property real leftMargin: units.gu(2)
26  readonly property real rightMargin: units.gu(2)
27 
28  // If you want to skip a page, mark skipValid false while you figure out
29  // whether to skip, then set it to true once you've determined the value
30  // of the skip property.
31  property bool skipValid: true
32  property bool skip: false
33 
34  property bool hasBackButton: true
35  property bool customBack: false
36  property alias forwardButtonSourceComponent: forwardButton.sourceComponent
37  property alias content: contentHolder
38 
39  property string title: ""
40 
41  signal backClicked()
42 
43  visible: false
44  anchors.fill: parent
45 
46  // We want larger than even fontSize: "x-large", so we use a Text instead
47  // of a Label.
48  Text {
49  id: titleLabel
50  anchors {
51  top: parent.top
52  left: parent.left
53  right: parent.right
54  topMargin: topMargin
55  leftMargin: leftMargin
56  rightMargin: rightMargin
57  }
58  wrapMode: Text.Wrap
59  text: title
60  color: theme.palette.normal.baseText
61  font.pixelSize: units.gu(4)
62  }
63 
64  Item {
65  id: contentHolder
66  anchors {
67  top: titleLabel.bottom
68  left: parent.left
69  right: parent.right
70  bottom: backButton.top
71  topMargin: units.gu(4)
72  leftMargin: leftMargin
73  rightMargin: rightMargin
74  bottomMargin: buttonMargin
75  }
76  }
77 
78  StackButton {
79  id: backButton
80  objectName: "backButton"
81  width: buttonWidth
82  anchors {
83  left: parent.left
84  bottom: parent.bottom
85  leftMargin: buttonMargin
86  bottomMargin: buttonMargin
87  }
88  z: 1
89  text: i18n.ctr("Button: Go back one page in the Wizard", "Back")
90  visible: pageStack.depth > 1 && hasBackButton
91  backArrow: true
92 
93  onClicked: customBack ? backClicked() : pageStack.prev()
94  }
95 
96  Loader {
97  id: forwardButton
98  objectName: "forwardButton"
99  width: buttonWidth
100  anchors {
101  right: parent.right
102  bottom: parent.bottom
103  rightMargin: buttonMargin
104  bottomMargin: buttonMargin
105  }
106  z: 1
107  }
108 }