Dekko
Loading...
Searching...
No Matches
UserInputUI.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 QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Dekko.Mail.API 1.0
22import Dekko.Mail.Stores.Accounts 1.0
23import QuickFlux 1.0
24import Dekko.Lomiri.Components 1.0
25import Dekko.Lomiri.Constants 1.0
27DekkoPage {
28 objectName: "userInputUI"
29 pageHeader.title: AccountSetup.accountDescripion
30
32
34 id: name
35 objectName: "userInputNameField"
36 title: qsTr("Name")
37 placeholderText: qsTr("Full name")
38 inputMethodHints: Qt.ImhNoPredictiveText
39 }
40
42 id: nickname
43 objectName: "descriptionInput"
44 title: qsTr("Description")
45 placeholderText: qsTr("E.g Home, Work...")
46 inputMethodHints: Qt.ImhNoPredictiveText
47 }
48
50 id: email
51 objectName: "userInputEmailField"
52 title: qsTr("Email address")
53 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhEmailCharactersOnly | Qt.ImhNoPredictiveText
54 placeholderText: qsTr("email@example.org")
55 }
56
58 id: password
59 objectName: "userInputPasswordField"
60 title: qsTr("Password")
61 inputMethodHints: Qt.ImhHiddenText | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
62 echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password
63 placeholderText: qsTr("Password")
64 }
65
67 id: showPassword
68 objectName: "showPwdCheckBox"
69 text: qsTr("Show password")
70 textColor: Suru.secondaryForegroundColor
71 }
72
74 anchors {
75 left: parent.left
76 right: parent.right
77 }
78 previousAction: Action {
79 text: qsTr("Cancel")
80 onTriggered: WizardActions.wizardStepBack()
81 }
82 nextAction: Action {
83 text: qsTr("Next")
84 onTriggered: WizardActions.validateUserDetails()
85 }
86 }
87 }
88
89 AppScript {
90 property var userDetails
91 runWhen: WizardKeys.validateUserDetails
92 script: {
93 userDetails = {
94 "name": name.text,
95 "email": email.text,
96 "password": password.text,
97 "nickname": nickname.text
98 };
99
100 WizardActions.validateUser(userDetails)
101 // It passed \o/. Now commit the details to the account object
102 // and signal to go to the next stop
103 once(WizardKeys.userDetailsValid, function() {
104
105 Log.logInfo("UserInputUI", "User details valid")
106 WizardActions.setUserDetails(userDetails)
107 name.requiredField = false
108 email.requiredField = false
109 WizardActions.wizardStepForward()
110
111 })
112 // Somethings not right. Show the invalid fields.
113 once(WizardKeys.userDetailsInvalid, function(message) {
114
115 Log.logInfo("UserInputUI::userDetailsInvalid", "User details invalid")
116 name.requiredField = message.result.indexOf("name") > -1
117 email.requiredField = message.result.indexOf("email") > -1
118 nickname.requiredField = message.result.indexOf("nickname") > -1
119
120 })
121
122 once(WizardKeys.noPasswordSet, function() {
123
124 Log.logWarning("UserInputUI::noPasswordSet", "No password set, :-/ asking user if this is what they want")
125 PopupActions.showConfirmationDialog(PopupKeys.popupSetupWizard, "userinputpwd", qsTr("Password empty"), qsTr("Would you like to continue?"))
126
127 }).then(PopupKeys.confirmationDialogConfirmed,function(message) {
128 if (message.id !== "userinputpwd") {
129 return;
130 }
131 Log.logInfo("UserInputUI::confirmationDialogConfirmed", "Seems they do! Setting validation to allow empty password")
132 WizardActions.setNoPasswordAllowed()
133 WizardActions.validateUserDetails()
134 })
135 // Disconnect all callbacks if the user steps back or forward
136 once(WizardKeys.wizardStepBack, exit.bind(this, 0))
137 once(WizardKeys.wizardStepForward, exit.bind(this, 0))
138 }
139 }
140}
141