2 * Copyright (C) 2013-2016 Canonical, Ltd.
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.
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.
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/>.
18 import Ubuntu.Components 1.3
22 readonly property real maximumContentWidth: units.gu(50)
23 readonly property bool wideMode: width > units.gu(90) && width > height
24 readonly property bool contentAnimationRunning: contentAnimation.running
26 readonly property real buttonMargin: units.gu(3)
27 readonly property real buttonWidth: (width - buttonMargin * 2) / 2 -
29 readonly property real buttonBarHeight: units.gu(5)
30 readonly property real titleRectHeight: customTitle ? units.gu(10) : units.gu(16)
32 readonly property real topMargin: units.gu(11)
33 readonly property real bottomMargin: units.gu(3)
34 readonly property real leftMargin: Math.max(units.gu(3), (width - maximumContentWidth) / 3)
35 readonly property real rightMargin: leftMargin
36 readonly property real customMargin: wideMode ? units.gu(8) : units.gu(4) // margin for the content
37 readonly property real staticMargin: units.gu(3)
40 readonly property color backgroundColor: "#fdfdfd"
41 readonly property color dividerColor: UbuntuColors.silk
42 readonly property color textColor: UbuntuColors.slate
43 readonly property color errorColor: theme.palette.normal.negative
44 readonly property color okColor: theme.palette.normal.positive
45 readonly property color whiteColor: "white" // workaround for a UITK bug
47 // If you want to skip a page, mark skipValid false while you figure out
48 // whether to skip, then set it to true once you've determined the value
49 // of the skip property.
50 property bool skipValid: true
51 property bool skip: false
53 property bool hasBackButton: true
54 property string backButtonText: i18n.ctr("Button: Go back one page in the Wizard", "Back")
55 property bool customBack: false
56 property bool customTitle: false
57 property alias forwardButtonSourceComponent: forwardButton.sourceComponent
58 property alias content: contentHolder
59 property bool lastPage: false
60 property bool buttonBarVisible: true
62 property string title: ""
72 triggeredOnStart: true
74 running: System.wizardEnabled
76 indicatorTime.text = Qt.formatTime(new Date(), "h:mm")
89 source: customTitle ? "" : (wideMode ? "Pages/data/Desktop_header_bkg.png" : "Pages/data/Phone_header_bkg.png")
90 height: titleRectHeight
96 property real animatedTopMargin: 0
100 bottom: parent.bottom
101 bottomMargin: bottomMargin
102 leftMargin: staticMargin
103 rightMargin: rightMargin
104 topMargin: titleLabel.animatedTopMargin
107 color: customTitle ? textColor : backgroundColor
108 fontSize: customTitle ? "large" : "x-large"
109 font.weight: Font.Light
110 wrapMode: Text.WordWrap
112 elide: Text.ElideRight
118 visible: !customTitle
122 topMargin: units.gu(.5)
123 rightMargin: units.gu(.5)
130 anchors.verticalCenter: parent.verticalCenter
132 height: parent.height
134 visible: !(root.simManager0.present || root.simManager1.present) && root.modemManager.modems.length > 0
140 anchors.verticalCenter: parent.verticalCenter
141 name: Status.networkIcon
142 height: parent.height
149 anchors.verticalCenter: parent.verticalCenter
150 name: Status.batteryIcon
151 height: parent.height
152 width: height * 1.4 // the battery icon is not rectangular :/
158 anchors.verticalCenter: parent.verticalCenter
168 property real animatedMargin: 0
169 property real animatedTopMargin: 0
171 top: titleRect.bottom
174 bottom: buttonBarVisible ? buttonRect.top : parent.bottom
175 leftMargin: content.animatedMargin
176 rightMargin: -content.animatedMargin
177 topMargin: content.animatedTopMargin
185 visible: buttonBarVisible
187 bottom: parent.bottom
188 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
192 height: buttonBarHeight
198 objectName: "backButton"
202 bottom: parent.bottom
203 leftMargin: staticMargin
204 verticalCenter: parent.verticalCenter
207 visible: pageStack.depth > 1 && hasBackButton
210 onClicked: customBack ? backClicked() : pageStack.prev()
215 objectName: "forwardButton"
219 bottom: parent.bottom
220 rightMargin: staticMargin
221 verticalCenter: parent.verticalCenter
227 function aboutToShow(duration, direction) {
228 startContentAnimation(duration, direction)
229 startControlsAnimation(duration)
232 function aboutToShowSecondary(duration) {
233 secondaryAnimation.restart()
234 startControlsAnimation(duration)
237 function startContentAnimation(duration, direction) {
238 contentAnimation.animationDurationBase = duration
239 contentAnimation.direction = direction
240 contentAnimation.restart()
243 function startControlsAnimation(showDuration) {
244 actionsShowAnimation.showDuration = showDuration
245 actionsShowAnimation.restart()
248 SequentialAnimation { // animation for the button bar
249 id: actionsShowAnimation
250 property int showDuration: 0
256 PauseAnimation { duration: Math.max(0, actionsShowAnimation.showDuration - UbuntuAnimation.SnapDuration) }
261 duration: UbuntuAnimation.SnapDuration
265 SequentialAnimation { // animations for the content
267 objectName: "contentAnimation"
268 property int animationDurationBase: UbuntuAnimation.BriskDuration
269 readonly property int additionalDuration: 200
270 property int direction: Qt.LeftToRight
271 ScriptAction { // direction of the effect
273 if (contentAnimation.direction === Qt.LeftToRight) {
274 content.animatedMargin = -content.width;
276 content.animatedMargin = content.width;
281 NumberAnimation { // the slide-in animation
283 property: 'animatedMargin'
285 duration: contentAnimation.animationDurationBase + contentAnimation.additionalDuration
286 easing.type: Easing.OutCubic
288 NumberAnimation { // opacity animation
289 targets: [titleLabel,content]
293 duration: contentAnimation.animationDurationBase
298 ParallelAnimation { // animation for the secondary pages
299 id: secondaryAnimation
300 objectName: "secondaryAnimation"
301 NumberAnimation { // the slide-up animation
303 property: 'animatedTopMargin'
306 duration: UbuntuAnimation.BriskDuration
307 easing: UbuntuAnimation.StandardEasing
311 property: 'animatedTopMargin'
314 duration: UbuntuAnimation.BriskDuration
315 easing: UbuntuAnimation.StandardEasing
317 NumberAnimation { // opacity animation
322 duration: UbuntuAnimation.BriskDuration