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 MeeGo.QOfono 0.2
20import Lomiri.Components 1.3
21import Lomiri.SystemSettings.SecurityPrivacy 1.0
22import Lomiri.SystemSettings.Update 1.0
23import Lomiri.Connectivity 1.0
29 objectName: "wizardPages"
34 // These should be set by a security page and we apply the settings when
35 // the user exits the wizard.
36 property int passwordMethod: LomiriSecurityPrivacyPanel.Passphrase
37 property string password: ""
39 property bool seenSIMPage: false // we want to see the SIM page at most once
40 readonly property bool connected: NetworkingStatus.online
42 property bool checkedForUpdates: false
43 property bool updateDownloaded: false
45 property alias modemManager: modemManager
46 property alias simManager0: simManager0
47 property alias simManager1: simManager1
49 theme: ThemeSettings {
50 name: "Lomiri.Components.Themes.Ambiance"
53 LomiriSecurityPrivacyPanel {
55 objectName: "securityPrivacy"
58 OfonoManager { // need it here for the language and country detection
60 readonly property bool gotSimCard: available && ((simManager0.ready && simManager0.present) || (simManager1.ready && simManager1.present))
61 property bool ready: false
67 // Ideally we would query the system more cleverly than hardcoding two
68 // sims. But we don't yet have a more clever way. :(
71 modemPath: modemManager.modems.length >= 1 ? modemManager.modems[0] : ""
76 modemPath: modemManager.modems.length >= 2 ? modemManager.modems[1] : ""
79 function checkForUpdatesIfConnected() {
80 if (connected && !checkedForUpdates) {
81 console.info("Wizard: Checking for system-image update");
82 SystemImage.checkForUpdate();
83 checkedForUpdates = true;
87 function quitWizard() {
88 pageStack.currentPage.enabled = false;
91 var errorMsg = securityPrivacy.setSecurity("", password, passwordMethod)
92 if (errorMsg !== "") {
93 // Ignore (but log) any errors, since we're past where the user set
94 // the method. Worst case, we just leave the user with a swipe
95 // security method and they fix it in the system settings.
96 console.log("Wizard: Error setting security method:", errorMsg)
103 MouseArea { // eat anything that gets past widgets
119 anchors.centerIn: parent
124 NumberAnimation on opacity {
134 fadeInAnimation.start();
139 onConnectedChanged: {
140 checkForUpdatesIfConnected();
145 onUpdateDownloaded: {
146 console.info("Wizard: A system-image update has been downloaded!")
147 root.updateDownloaded = true;
149 onCheckingForUpdatesChanged: {
150 if (!SystemImage.checkingForUpdates) {
151 console.info("Wizard: Update check finished")
152 if (SystemImage.updateAvailable) {
153 console.info("Wizard: A system-image update is available!")
155 console.info("Wizard: No update found.")
162 id: impatientLoadingTimer
165 console.warn("Wizard: Impatient timer going off. Fix the wizard, it's too slow at skipping pages.")
166 pagesSpinner.running = true;
172 objectName: "pageStack"
176 // If we've opened any extra (non-main) pages, pop them before
177 // continuing so back button returns to the previous main page.
178 while (pageList.index < pageStack.depth - 1)
180 load(pageList.next());
184 var isPrimaryPage = currentPage && !currentPage.customTitle;
185 if (pageList.index >= pageStack.depth - 1) {
186 pageList.prev(); // update pageList.index, but not for extra pages
189 if (!currentPage || currentPage.opacity === 0) { // undo skipped pages
192 currentPage.enabled = true;
196 currentPage.aboutToShow(LomiriAnimation.BriskDuration, Qt.LeftToRight);
198 currentPage.aboutToShowSecondary(LomiriAnimation.BriskDuration);
202 function load(path) {
204 currentPage.enabled = false;
207 // First load it invisible, check that we should actually use
208 // this page, and either skip it or continue.
209 push(path, {"opacity": 0, "enabled": false});
212 impatientLoadingTimer.start();
214 console.info("Wizard: Loading page " + currentPage.objectName);
216 // Check for immediate skip or not. We may have to wait for
217 // skipValid to be assigned (see Connections object below)
220 var isPrimaryPage = !currentPage.customTitle;
222 currentPage.aboutToShow(LomiriAnimation.BriskDuration, Qt.RightToLeft);
224 currentPage.aboutToShowSecondary(LomiriAnimation.BriskDuration);
228 function checkSkip() {
229 if (!currentPage) { // may have had a parse error
230 console.warn("Wizard: page skipped due to possible parse error.");
232 } else if (currentPage.skipValid) {
233 if (currentPage.skip) {
235 } else if ((currentPage.onlyOnUpdate && !wizard.isUpdate) ||
236 (currentPage.onlyOnInstall && wizard.isUpdate)) {
239 impatientLoadingTimer.stop()
240 pagesSpinner.running = false;
241 currentPage.opacity = 1;
242 currentPage.enabled = true;
250 objectName: "timeout"
251 interval: 2000 // wizard pages shouldn't take long
253 console.warn("Wizard: Page " + pageStack.currentPage.objectName + " skipped due to taking too long!!!");
254 pageStack.currentPage.skip = true;
255 pageStack.currentPage.skipValid = true;
260 target: pageStack.currentPage
261 onSkipValidChanged: pageStack.checkSkip()
264 Component.onCompleted: {
265 checkForUpdatesIfConnected();