Lomiri
60-account.qml
1 /*
2  * Copyright (C) 2015-2016 Canonical Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 import QtQuick 2.4
18 import Lomiri.Components 1.3
19 import AccountsService 0.1
20 import ".." as LocalComponents
21 
22 LocalComponents.Page {
23  objectName: "accountPage"
24  title: i18n.tr("Personalize Your Device")
25  focusItem: nameInput
26 
27  forwardButtonSourceComponent: forwardButton
28  onlyOnInstall: true
29 
30  readonly property string validName: nameInput.text.trim()
31 
32  function saveNameAndGoNext() {
33  if (validName) {
34  AccountsService.realName = validName;
35  }
36  pageStack.next();
37  }
38 
39  Column {
40  id: column
41  spacing: units.gu(1)
42  anchors {
43  fill: content
44  leftMargin: parent.leftMargin
45  rightMargin: parent.rightMargin
46  topMargin: customMargin
47  }
48 
49  // name
50  Label {
51  id: nameLabel
52  anchors.left: parent.left
53  anchors.right: parent.right
54  text: i18n.tr("Preferred Name")
55  color: textColor
56  font.weight: Font.Light
57  }
58 
59  LocalComponents.WizardTextField {
60  id: nameInput
61  objectName: "nameInput"
62  anchors.left: parent.left
63  anchors.right: parent.right
64  inputMethodHints: Qt.ImhNoPredictiveText
65  onAccepted: saveNameAndGoNext()
66  }
67  }
68 
69  Component {
70  id: forwardButton
71  LocalComponents.StackButton {
72  text: validName ? i18n.tr("Next") : i18n.tr("Skip")
73  onClicked: saveNameAndGoNext()
74  }
75  }
76 }