Unity 8
10-welcome.qml
1 /*
2  * Copyright (C) 2013 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 Ubuntu.Components 1.3
19 import Ubuntu.Components.ListItems 1.3
20 import Ubuntu.SystemSettings.LanguagePlugin 1.0
21 import Wizard 0.1
22 import ".." as LocalComponents
23 
24 LocalComponents.Page {
25  objectName: "languagePage"
26 
27  title: i18n.tr("Hi!")
28  forwardButtonSourceComponent: forwardButton
29 
30  UbuntuLanguagePlugin {
31  id: plugin
32  }
33 
34  Column {
35  id: column
36  anchors.fill: content
37  spacing: units.gu(1)
38 
39  Label {
40  id: label1
41  anchors.left: parent.left
42  anchors.right: parent.right
43  wrapMode: Text.Wrap
44  text: i18n.tr("Welcome to your Ubuntu phone.")
45  }
46 
47  Label {
48  id: label2
49  anchors.left: parent.left
50  anchors.right: parent.right
51  wrapMode: Text.Wrap
52  text: i18n.tr("Let’s get started.")
53  }
54 
55  Item { // spacer
56  height: units.gu(2)
57  width: units.gu(1) // needed else it will be ignored
58  }
59 
60  ComboButton {
61  id: combo
62  objectName: "languageCombo"
63  anchors.left: parent.left
64  anchors.right: parent.right
65  text: listview.currentItem.text
66  onClicked: expanded = !expanded
67  expandedHeight: column.height - combo.y
68  UbuntuListView {
69  id: listview
70  model: plugin.languageNames
71  currentIndex: plugin.currentLanguage
72  delegate: Standard {
73  objectName: "languageDelegate" + index
74  text: modelData
75  onClicked: {
76  listview.currentIndex = index
77  combo.expanded = false
78  i18n.language = plugin.languageCodes[index]
79  }
80  }
81  }
82  }
83  }
84 
85  Component {
86  id: forwardButton
87  LocalComponents.StackButton {
88  text: i18n.tr("Continue")
89  onClicked: {
90  if (plugin.currentLanguage !== listview.currentIndex) {
91  plugin.currentLanguage = listview.currentIndex;
92  System.updateSessionLanguage(plugin.languageCodes[listview.currentIndex]);
93  i18n.language = i18n.language; // re-notify of change after above call (for qlocale change)
94  }
95  pageStack.next()
96  }
97  }
98  }
99 }