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/>.
20import Lomiri.Components 1.3
21import Lomiri.SystemSettings.SecurityPrivacy 1.0
22import Lomiri.Connectivity 1.0
28 objectName: "wizardPages"
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: LomiriSecurityPrivacyPanel.Passphrase
36 property string password: ""
38 property bool seenSIMPage: false // we want to see the SIM page at most once
39 readonly property bool connected: NetworkingStatus.online
41 property alias modemManager: modemManager
42 property alias simManager0: simManager0
43 property alias simManager1: simManager1
45 theme: ThemeSettings {
46 name: "Lomiri.Components.Themes.Ambiance"
49 LomiriSecurityPrivacyPanel {
51 objectName: "securityPrivacy"
54 OfonoManager { // need it here for the language and country detection
56 readonly property bool gotSimCard: available && ((simManager0.ready && simManager0.present) || (simManager1.ready && simManager1.present))
57 property bool ready: false
63 // Ideally we would query the system more cleverly than hardcoding two
64 // sims. But we don't yet have a more clever way. :(
67 modemPath: modemManager.modems.length >= 1 ? modemManager.modems[0] : ""
72 modemPath: modemManager.modems.length >= 2 ? modemManager.modems[1] : ""
75 function quitWizard() {
76 pageStack.currentPage.enabled = false;
79 var errorMsg = securityPrivacy.setSecurity("", password, passwordMethod)
80 if (errorMsg !== "") {
81 // Ignore (but log) any errors, since we're past where the user set
82 // the method. Worst case, we just leave the user with a swipe
83 // security method and they fix it in the system settings.
84 console.log("Wizard: Error setting security method:", errorMsg)
91 MouseArea { // eat anything that gets past widgets
107 anchors.centerIn: parent
112 NumberAnimation on opacity {
122 fadeInAnimation.start();
128 id: impatientLoadingTimer
131 console.warn("Wizard: Impatient timer going off. Fix the wizard, it's too slow at skipping pages.")
132 pagesSpinner.running = true;
138 objectName: "pageStack"
142 // If we've opened any extra (non-main) pages, pop them before
143 // continuing so back button returns to the previous main page.
144 while (pageList.index < pageStack.depth - 1)
146 load(pageList.next());
150 var isPrimaryPage = currentPage && !currentPage.customTitle;
151 if (pageList.index >= pageStack.depth - 1) {
152 pageList.prev(); // update pageList.index, but not for extra pages
155 if (!currentPage || currentPage.opacity === 0) { // undo skipped pages
158 currentPage.enabled = true;
162 currentPage.aboutToShow(LomiriAnimation.BriskDuration, Qt.LeftToRight);
164 currentPage.aboutToShowSecondary(LomiriAnimation.BriskDuration);
168 function load(path) {
170 currentPage.enabled = false;
173 // First load it invisible, check that we should actually use
174 // this page, and either skip it or continue.
175 push(path, {"opacity": 0, "enabled": false});
178 impatientLoadingTimer.start();
180 console.info("Wizard: Loading page " + currentPage.objectName);
182 // Check for immediate skip or not. We may have to wait for
183 // skipValid to be assigned (see Connections object below)
186 var isPrimaryPage = !currentPage.customTitle;
188 currentPage.aboutToShow(LomiriAnimation.BriskDuration, Qt.RightToLeft);
190 currentPage.aboutToShowSecondary(LomiriAnimation.BriskDuration);
194 function checkSkip() {
195 if (!currentPage) { // may have had a parse error
196 console.warn("Wizard: page skipped due to possible parse error.");
198 } else if (currentPage.skipValid) {
199 if (currentPage.skip) {
201 } else if ((currentPage.onlyOnUpdate && !wizard.isUpdate) ||
202 (currentPage.onlyOnInstall && wizard.isUpdate)) {
205 impatientLoadingTimer.stop()
206 pagesSpinner.running = false;
207 currentPage.opacity = 1;
208 currentPage.enabled = true;
216 objectName: "timeout"
217 interval: 2000 // wizard pages shouldn't take long
219 console.warn("Wizard: Page " + pageStack.currentPage.objectName + " skipped due to taking too long!!!");
220 pageStack.currentPage.skip = true;
221 pageStack.currentPage.skipValid = true;
226 target: pageStack.currentPage
227 function onSkipValidChanged() { pageStack.checkSkip() }
230 Component.onCompleted: {