on 8a968c8 help sign in
unity8/qml/Wizard/Pages.qml
136 lines 4.1 kB history raw
1/*
2 * Copyright (C) 2013 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 */
17import QtQuick 2.3
18import Ubuntu.Components 1.1
19import Ubuntu.SystemSettings.SecurityPrivacy 1.0
20import Wizard 0.1
21import "../Components"
23Item {
24 id: root
25 objectName: "wizardPages"
26 focus: true
28 // The background wallpaper to use
29 property string background
31 signal quit()
33 // These should be set by a security page and we apply the settings when
34 // the user exits the wizard.
35 property int passwordMethod: UbuntuSecurityPrivacyPanel.Passcode
36 property string password: ""
38 UbuntuSecurityPrivacyPanel {
39 id: securityPrivacy
40 objectName: "securityPrivacy"
41 }
43 function quitWizard() {
44 var errorMsg = securityPrivacy.setSecurity("", password, passwordMethod)
45 if (errorMsg !== "") {
46 // Ignore (but log) any errors, since we're past where the user set
47 // the method. Worst case, we just leave the user with a swipe
48 // security method and they fix it in the system settings.
49 console.log("Error setting security method:", errorMsg)
50 }
52 quit();
53 }
55 MouseArea { // eat anything that gets past widgets
56 anchors.fill: parent
57 }
59 Image {
60 id: image
61 // Use x/y/height/width instead of anchors so that we don't adjust
62 // the image when the OSK appears.
63 x: 0
64 y: 0
65 height: root.height
66 width: root.width
67 sourceSize.height: height
68 sourceSize.width: width
69 source: root.background
70 fillMode: Image.PreserveAspectCrop
71 visible: status === Image.Ready
72 }
74 PageList {
75 id: pageList
76 }
78 PageStack {
79 id: pageStack
80 objectName: "pageStack"
81 anchors.fill: parent
83 function next() {
84 // If we've opened any extra (non-main) pages, pop them before
85 // continuing so back button returns to the previous main page.
86 while (pageList.index < pageStack.depth - 1)
87 pop()
88 load(pageList.next())
89 }
91 function prev() {
92 if (pageList.index >= pageStack.depth - 1)
93 pageList.prev() // update pageList.index, but not for extra pages
94 pop()
95 if (!currentPage || currentPage.opacity === 0) { // undo skipped pages
96 prev()
97 } else {
98 currentPage.enabled = true
99 }
100 }
102 function load(path) {
103 if (currentPage) {
104 currentPage.enabled = false
105 }
107 // First load it invisible, check that we should actually use
108 // this page, and either skip it or continue.
109 push(path, {"opacity": 0, "enabled": false})
111 // Check for immediate skip or not. We may have to wait for
112 // skipValid to be assigned (see Connections object below)
113 checkSkip()
114 }
116 function checkSkip() {
117 if (!currentPage) { // may have had a parse error
118 next()
119 } else if (currentPage.skipValid) {
120 if (currentPage.skip) {
121 next()
122 } else {
123 currentPage.opacity = 1
124 currentPage.enabled = true
125 }
126 }
127 }
129 Connections {
130 target: pageStack.currentPage
131 onSkipValidChanged: pageStack.checkSkip()
132 }
134 Component.onCompleted: next()
135 }