on xenial help sign in
Advance welcome wizard when pressing enter in text fields
commit0a3913bd0eec7d0b2d0bf536ff9732b1af0550d1 authorMiguel Gutiérrez <nikalon@users.noreply.github.com> dateSun 14 Oct 2018, 14:59 (8 years ago) parent2a68cb3
3 files changed+34−19
qml/Wizard/Pages/60-account.qml+10−10 qml/Wizard/Pages/passcode-desktop.qml+13−5 qml/Wizard/Pages/password-set.qml+11−4
qml/Wizard/Pages/60-account.qml+10−10
@@ -26,9 +26,13 @@ LocalComponents.Page {
2626 forwardButtonSourceComponent: forwardButton
2727 onlyOnInstall: true
2828
29− QtObject {
30− id: d
31− readonly property string validName: nameInput.text.trim()
29+ readonly property string validName: nameInput.text.trim()
30+
31+ function saveNameAndGoNext() {
32+ if (validName) {
33+ AccountsService.realName = validName;
34+ }
35+ pageStack.next();
3236 }
3337
3438 Column {
@@ -57,19 +61,15 @@ LocalComponents.Page {
5761 anchors.left: parent.left
5862 anchors.right: parent.right
5963 inputMethodHints: Qt.ImhNoPredictiveText
64+ onAccepted: saveNameAndGoNext()
6065 }
6166 }
6267
6368 Component {
6469 id: forwardButton
6570 LocalComponents.StackButton {
66− text: d.validName ? i18n.tr("Next") : i18n.tr("Skip")
67− onClicked: {
68− if (d.validName) {
69− AccountsService.realName = d.validName;
70− }
71− pageStack.next();
72− }
71+ text: validName ? i18n.tr("Next") : i18n.tr("Skip")
72+ onClicked: saveNameAndGoNext()
7373 }
7474 }
7575}
qml/Wizard/Pages/passcode-desktop.qml+13−5
@@ -33,6 +33,12 @@ LocalComponents.Page {
3333
3434 readonly property alias password: passwordField.text
3535 readonly property alias password2: password2Field.text
36+ readonly property bool passwordsMatching: password != "" && password == password2
37+
38+ function savePasswordAndGoNext() {
39+ root.password = password;
40+ pageStack.next();
41+ }
3642
3743 Flickable {
3844 id: column
@@ -105,6 +111,11 @@ LocalComponents.Page {
105111 inputMethodHints: Qt.ImhDigitsOnly
106112 validator: RegExpValidator { regExp: /^\d{4}$/ }
107113 maximumLength: 4
114+ onAccepted: {
115+ if (passwordsMatching) {
116+ savePasswordAndGoNext();
117+ }
118+ }
108119 onActiveFocusChanged: {
109120 if (activeFocus) {
110121 column.contentY = y
@@ -140,11 +151,8 @@ LocalComponents.Page {
140151 id: forwardButton
141152 LocalComponents.StackButton {
142153 text: i18n.tr("Next")
143− enabled: password != "" && password == password2
144− onClicked: {
145− root.password = password;
146− pageStack.next();
147− }
154+ enabled: passwordsMatching
155+ onClicked: savePasswordAndGoNext()
148156 }
149157 }
150158}
qml/Wizard/Pages/password-set.qml+11−4
@@ -35,6 +35,11 @@ LocalComponents.Page {
3535 readonly property alias password2: password2Field.text
3636 readonly property bool passwordsMatching: password == password2 && password.trim().length > 7
3737
38+ function savePasswordAndGoNext() {
39+ root.password = password;
40+ pageStack.next();
41+ }
42+
3843 Flickable {
3944 id: column
4045 clip: true
@@ -114,6 +119,11 @@ LocalComponents.Page {
114119 id: password2Field
115120 objectName: "password2Field"
116121 echoMode: TextInput.Password
122+ onAccepted: {
123+ if (passwordsMatching) {
124+ savePasswordAndGoNext();
125+ }
126+ }
117127 onActiveFocusChanged: {
118128 if (activeFocus) {
119129 column.contentY = pass2Label.y
@@ -141,10 +151,7 @@ LocalComponents.Page {
141151 LocalComponents.StackButton {
142152 text: i18n.tr("Next")
143153 enabled: passwordsMatching
144− onClicked: {
145− root.password = password;
146− pageStack.next();
147− }
154+ onClicked: savePasswordAndGoNext()
148155 }
149156 }
150157}