2 * Copyright (C) 2018 The UBports project
3 * Copyright (C) 2013-2016 Canonical Ltd.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19import Lomiri.Components 1.3
23 readonly property real maximumContentWidth: units.gu(50)
24 readonly property bool wideMode: width > units.gu(90) && width > height
25 readonly property alias contentAnimationRunning: contentAnimation.running
27 readonly property real buttonMargin: units.gu(3)
28 readonly property real buttonWidth: (width - buttonMargin * 2) / 2 -
30 readonly property real buttonBarHeight: units.gu(5)
31 readonly property real titleRectHeight: customTitle ? units.gu(10) : units.gu(16)
33 readonly property real topMargin: units.gu(11)
34 readonly property real bottomMargin: units.gu(3)
35 readonly property real leftMargin: Math.max(units.gu(3), (width - maximumContentWidth) / 3)
36 readonly property real rightMargin: leftMargin
37 readonly property real customMargin: wideMode ? units.gu(8) : units.gu(4) // margin for the content
38 readonly property real staticMargin: units.gu(3)
41 readonly property color backgroundColor: "#fdfdfd"
42 readonly property color dividerColor: LomiriColors.silk
43 readonly property color textColor: LomiriColors.slate
44 readonly property color errorColor: theme.palette.normal.negative
45 readonly property color okColor: theme.palette.normal.positive
46 readonly property color whiteColor: "white" // workaround for a UITK bug
48 // If you want to skip a page, mark skipValid false while you figure out
49 // whether to skip, then set it to true once you've determined the value
50 // of the skip property.
51 property bool skipValid: true
52 property bool skip: false
54 // Marks if should be only shown if update or install
55 property bool onlyOnUpdate: false
56 property bool onlyOnInstall: false
58 property bool hasBackButton: true
59 property string backButtonText: i18n.ctr("Button: Go back one page in the Wizard", "Back")
60 property bool customBack: false
61 property bool customTitle: false
62 property alias forwardButtonSourceComponent: forwardButton.sourceComponent
63 property alias content: contentHolder
64 property bool lastPage: false
65 property bool buttonBarVisible: true
67 // Item that will receive input focus when the page is in front
68 // May be useful to open the keyboard automatically for a text field
69 property Item focusItem
71 property string title: ""
79 if (visible && focusItem) {
80 focusItem.forceActiveFocus();
87 triggeredOnStart: true
89 running: System.wizardEnabled
91 indicatorTime.text = Qt.formatTime(new Date(), "h:mm")
104 source: customTitle ? "" : (wideMode ? "Pages/data/Desktop_header_bkg.png" : "Pages/data/Phone_header_bkg.png")
105 height: titleRectHeight
111 property real animatedTopMargin: 0
115 bottom: parent.bottom
116 bottomMargin: bottomMargin
117 leftMargin: staticMargin
118 rightMargin: rightMargin
119 topMargin: titleLabel.animatedTopMargin
122 color: customTitle ? textColor : backgroundColor
123 fontSize: customTitle ? "large" : "x-large"
124 font.weight: Font.Light
125 wrapMode: Text.WordWrap
127 elide: Text.ElideRight
133 visible: !customTitle
137 topMargin: units.gu(.5)
138 rightMargin: units.gu(.5)
145 anchors.verticalCenter: parent.verticalCenter
147 height: parent.height
149 visible: !(root.simManager0.present || root.simManager1.present) && root.modemManager.modems.length > 0
155 anchors.verticalCenter: parent.verticalCenter
156 name: Status.networkIcon
157 height: parent.height
164 anchors.verticalCenter: parent.verticalCenter
165 name: Status.batteryIcon
166 height: parent.height
167 width: height * 1.4 // the battery icon is not rectangular :/
173 anchors.verticalCenter: parent.verticalCenter
183 property real animatedMargin: 0
184 property real animatedTopMargin: 0
186 top: titleRect.bottom
189 bottom: buttonBarVisible ? buttonRect.top : parent.bottom
190 leftMargin: content.animatedMargin
191 rightMargin: -content.animatedMargin
192 topMargin: content.animatedTopMargin
200 visible: buttonBarVisible
202 bottom: parent.bottom
203 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
207 height: buttonBarHeight
213 objectName: "backButton"
217 bottom: parent.bottom
218 leftMargin: staticMargin
219 verticalCenter: parent.verticalCenter
222 visible: pageStack.depth > 1 && hasBackButton
225 onClicked: customBack ? backClicked() : pageStack.prev()
230 objectName: "forwardButton"
234 bottom: parent.bottom
235 rightMargin: staticMargin
236 verticalCenter: parent.verticalCenter
242 function aboutToShow(duration, direction) {
243 startContentAnimation(duration, direction)
244 startControlsAnimation(duration)
247 function aboutToShowSecondary(duration) {
248 secondaryAnimation.restart()
249 startControlsAnimation(duration)
252 function startContentAnimation(duration, direction) {
253 contentAnimation.animationDurationBase = duration
254 contentAnimation.direction = direction
255 contentAnimation.restart()
258 function startControlsAnimation(showDuration) {
259 actionsShowAnimation.showDuration = showDuration
260 actionsShowAnimation.restart()
263 SequentialAnimation { // animation for the button bar
264 id: actionsShowAnimation
265 property int showDuration: 0
271 PauseAnimation { duration: Math.max(0, actionsShowAnimation.showDuration - LomiriAnimation.SnapDuration) }
276 duration: LomiriAnimation.SnapDuration
280 SequentialAnimation { // animations for the content
282 objectName: "contentAnimation"
283 property int animationDurationBase: LomiriAnimation.BriskDuration
284 readonly property int additionalDuration: 200
285 property int direction: Qt.LeftToRight
286 ScriptAction { // direction of the effect
288 if (contentAnimation.direction === Qt.LeftToRight) {
289 content.animatedMargin = -content.width;
291 content.animatedMargin = content.width;
296 NumberAnimation { // the slide-in animation
298 property: 'animatedMargin'
300 duration: contentAnimation.animationDurationBase + contentAnimation.additionalDuration
301 easing.type: Easing.OutCubic
303 NumberAnimation { // opacity animation
304 targets: [titleLabel,content]
308 duration: contentAnimation.animationDurationBase
313 ParallelAnimation { // animation for the secondary pages
314 id: secondaryAnimation
315 objectName: "secondaryAnimation"
316 NumberAnimation { // the slide-up animation
318 property: 'animatedTopMargin'
321 duration: LomiriAnimation.BriskDuration
322 easing: LomiriAnimation.StandardEasing
326 property: 'animatedTopMargin'
329 duration: LomiriAnimation.BriskDuration
330 easing: LomiriAnimation.StandardEasing
332 NumberAnimation { // opacity animation
337 duration: LomiriAnimation.BriskDuration