Dekko
Loading...
Searching...
No Matches
AutoConfigState.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import QtQml.StateMachine 1.0 as DSM
20import Lomiri.Components.Popups 1.3
21import QuickFlux 1.0
22import Dekko.Mail.API 1.0
23import Dekko.Mail.Stores.Accounts 1.0
25DSM.State {
26 id: noAccountsState
27
28 property alias nextTargetState: next.targetState
29
30 onEntered: {
31 Log.logStatus("AutoConfigState::onEntered", "Loading processing overlay");
32 d.overlay = PopupUtils.open(Qt.resolvedUrl("../components/ProcessingOverlay.qml"),
33 wizard,
34 {
35 text: qsTr("Searching for configuration.")
36 })
37 WizardActions.lookForServerDetails()
38 }
39
40 onExited: {
41 Log.logStatus("AutoConfigState::onExited", "Destroying overlay");
42 if (d.overlay !== undefined) {
43 PopupUtils.close(d.overlay)
44 }
45 }
46
47 AppScript {
48 runWhen: WizardKeys.askAboutImapInstead
49 script: {
50 WizardActions.showUseImapDialog()
51 once(PopupKeys.confirmationDialogConfirmed, function (message) {
52 if (message.id !== d.useImapId) {
53 return;
54 }
55 Log.logInfo("AutoConfigState::confirmationDialogConfirmed", "Seems they do! Using imap config instead")
56 WizardActions.useImapInstead()
57 })
58 once(PopupKeys.confirmationDialogCancelled, function (message) {
59 if (message.id !== d.useImapId) {
60 return;
61 }
62 Log.logInfo("AutoConfigState::confirmationDialogConfirmed", "Sticking with pop")
63 WizardActions.stickWithPop()
64 })
65 }
66 }
67
68 AppListener {
69 filter: WizardKeys.showUseImapDialog
70 onDispatched: {
71 if (d.overlay !== undefined) {
72 PopupUtils.close(d.overlay)
73 }
74 PopupActions.showConfirmationDialog(
75 PopupKeys.popupSetupWizard,
76 d.useImapId,
77 qsTr("IMAP server found"),
78 qsTr("A IMAP server configuration was found for your domain.\n\nWould you like to use this instead?"
79 ))
80 }
81 }
82
83 DSM.SignalTransition {
84 id: next
85 signal: AccountSetup.goNext
86 }
87
88 QtObject {
89 id: d
90 property var overlay: undefined
91 readonly property string useImapId: "use-imap-dlg"
92 }
93}