Merge lp:~attente/ubuntu-system-settings/1392699 into lp:ubuntu-system-settings

Proposed by William Hua
Status: Needs review
Proposed branch: lp:~attente/ubuntu-system-settings/1392699
Merge into: lp:ubuntu-system-settings
Diff against target: 269 lines (+102/-16)
4 files modified
plugins/language/DisplayLanguage.qml (+14/-6)
plugins/language/PageComponent.qml (+40/-4)
plugins/language/language-plugin.cpp (+37/-6)
plugins/language/language-plugin.h (+11/-0)
To merge this branch: bzr merge lp:~attente/ubuntu-system-settings/1392699
Reviewer Review Type Date Requested Status
Ken VanDine Needs Information
PS Jenkins bot continuous-integration Pending
Review via email: mp+296271@code.launchpad.net

Commit message

Make language and formats locale independent settings

Description of the change

Make language and formats locale independent settings

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good and seems to work fine.

Please update the test plan to match https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-system-settings#Language_.26_Text

review: Approve
Revision history for this message
Ken VanDine (ken-vandine) wrote :

We need Pat and design to agree to what we're implementing here and from the conversation on IRC I have the feeling not everyone is agreement to land this.

review: Needs Information

Unmerged revisions

1662. By William Hua

Only change the language if the mode is 0

1661. By William Hua

Make language and formats locale independent settings

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/language/DisplayLanguage.qml'
2--- plugins/language/DisplayLanguage.qml 2015-08-10 13:31:45 +0000
3+++ plugins/language/DisplayLanguage.qml 2016-06-14 14:37:20 +0000
4@@ -28,12 +28,13 @@
5 id: root
6 objectName: "displayLanguageDialog"
7
8+ property int displayMode: 0
9 property string initialLanguage
10
11 signal languageChanged (int newLanguage, int oldLanguage)
12
13 modal: true
14- title: i18n.tr("Display language")
15+ title: displayMode == 0 ? i18n.tr("Display language") : i18n.tr("Date & number formats")
16
17 contentsWidth: parent.width
18 contentsHeight: parent.height
19@@ -58,7 +59,7 @@
20 otherwise the UI might end up in a situation where scrolling doesn't work */
21 flickableDirection: Flickable.VerticalFlick
22
23- currentIndex: plugin.currentLanguage
24+ currentIndex: displayMode == 0 ? plugin.currentLanguage : plugin.currentFormat
25
26 model: plugin.languageNames
27 delegate: ListItem.Standard {
28@@ -72,7 +73,8 @@
29 }
30
31 onCurrentIndexChanged: {
32- i18n.language = plugin.languageCodes[currentIndex]
33+ if (displayMode == 0)
34+ i18n.language = plugin.languageCodes[currentIndex]
35 }
36 }
37
38@@ -114,7 +116,7 @@
39 id: confirmButton
40 objectName: "confirmChangeLanguage"
41 text: i18n.tr("Confirm")
42- enabled: languageList.currentIndex != plugin.currentLanguage
43+ enabled: languageList.currentIndex != (displayMode == 0 ? plugin.currentLanguage : plugin.currentFormat)
44
45 anchors.left: parent.horizontalCenter
46 anchors.right: parent.right
47@@ -125,10 +127,16 @@
48 anchors.bottomMargin: units.gu(1)
49
50 onClicked: {
51- var oldLang = plugin.currentLanguage;
52+ var oldLang = displayMode == 0 ? plugin.currentLanguage : plugin.currentFormat;
53 var newLang = languageList.currentIndex;
54+
55 languageChanged(newLang, oldLang);
56- plugin.currentLanguage = newLang;
57+
58+ if (displayMode == 0)
59+ plugin.currentLanguage = newLang;
60+ else
61+ plugin.currentFormat = newLang;
62+
63 PopupUtils.close(root);
64 }
65 }
66
67=== modified file 'plugins/language/PageComponent.qml'
68--- plugins/language/PageComponent.qml 2016-03-02 13:15:34 +0000
69+++ plugins/language/PageComponent.qml 2016-06-14 14:37:20 +0000
70@@ -53,8 +53,24 @@
71 id: displayLanguage
72
73 DisplayLanguage {
74- onLanguageChanged: {
75- PopupUtils.open(rebootNecessaryNotification, root, {
76+ displayMode: 0
77+
78+ onLanguageChanged: {
79+ PopupUtils.open(rebootNecessaryNotificationLanguage, root, {
80+ revertTo: oldLanguage
81+ })
82+ }
83+ }
84+ }
85+
86+ Component {
87+ id: displayFormat
88+
89+ DisplayLanguage {
90+ displayMode: 1
91+
92+ onLanguageChanged: {
93+ PopupUtils.open(rebootNecessaryNotificationFormat, root, {
94 revertTo: oldLanguage
95 })
96 }
97@@ -68,7 +84,7 @@
98 }
99
100 Component {
101- id: rebootNecessaryNotification
102+ id: rebootNecessaryNotificationLanguage
103
104 RebootNecessary {
105
106@@ -82,6 +98,20 @@
107 }
108 }
109
110+ Component {
111+ id: rebootNecessaryNotificationFormat
112+
113+ RebootNecessary {
114+
115+ onReboot: {
116+ plugin.reboot();
117+ }
118+ onRevert: {
119+ plugin.currentFormat = to;
120+ }
121+ }
122+ }
123+
124 GSettings {
125 id: settings
126
127@@ -106,7 +136,6 @@
128 iconSource: "image://theme/language-chooser"
129 text: i18n.tr("Display languageā€¦")
130 objectName: "displayLanguage"
131- showDivider: false
132 component: Label {
133 property int currentLanguage: plugin.currentLanguage
134 objectName: "currentLanguage"
135@@ -118,6 +147,13 @@
136 onClicked: PopupUtils.open(displayLanguage)
137 }
138
139+ ListItem.SingleValue {
140+ text: i18n.tr("Date & number formats")
141+ progression: true
142+ value: plugin.languageNames[plugin.currentFormat]
143+ onClicked: PopupUtils.open(displayFormat)
144+ }
145+
146 ListItem.Divider {}
147
148 ListItem.SingleValue {
149
150=== modified file 'plugins/language/language-plugin.cpp'
151--- plugins/language/language-plugin.cpp 2015-12-22 13:49:39 +0000
152+++ plugins/language/language-plugin.cpp 2016-06-14 14:37:20 +0000
153@@ -86,6 +86,8 @@
154 QObject(parent),
155 m_currentLanguage(-1),
156 m_nextCurrentLanguage(-1),
157+ m_currentFormat(-1),
158+ m_nextCurrentFormat(-1),
159 m_manager(act_user_manager_get_default()),
160 m_user(nullptr)
161 {
162@@ -159,6 +161,22 @@
163 }
164 }
165
166+int
167+LanguagePlugin::currentFormat() const
168+{
169+ return m_currentFormat;
170+}
171+
172+void
173+LanguagePlugin::setCurrentFormat(int index)
174+{
175+ if (index >= 0 && index < m_languageCodes.length()) {
176+ m_nextCurrentFormat = index;
177+
178+ updateCurrentLanguage();
179+ }
180+}
181+
182 SubsetModel *
183 LanguagePlugin::spellCheckingModel()
184 {
185@@ -246,6 +264,7 @@
186 LanguagePlugin::updateCurrentLanguage()
187 {
188 int previousLanguage(m_currentLanguage);
189+ int previousFormat(m_currentFormat);
190
191 if (m_user != nullptr && act_user_is_loaded(m_user)) {
192 if (m_nextCurrentLanguage >= 0) {
193@@ -255,23 +274,35 @@
194 QString formatsLocale(m_languageCodes[m_currentLanguage]);
195 QString language(formatsLocale.left(formatsLocale.indexOf('.')));
196 act_user_set_language(m_user, qPrintable(language));
197+ } else if (m_nextCurrentFormat >= 0) {
198+ m_currentFormat = m_nextCurrentFormat;
199+ m_nextCurrentFormat = -1;
200+
201+ QString formatsLocale(m_languageCodes[m_currentFormat]);
202 act_user_set_formats_locale(m_user, qPrintable(formatsLocale));
203 } else {
204+ QString language(act_user_get_language(m_user));
205 QString formatsLocale(act_user_get_formats_locale(m_user));
206- m_currentLanguage = indexForLocale(formatsLocale);
207-
208- if (m_currentLanguage < 0) {
209- QString language(act_user_get_language(m_user));
210- m_currentLanguage = indexForLocale(language);
211- }
212+
213+ m_currentLanguage = indexForLocale(language);
214+ m_currentFormat = indexForLocale(formatsLocale);
215+
216+ if (m_currentLanguage < 0)
217+ m_currentLanguage = m_currentFormat;
218 }
219 }
220
221 if (m_currentLanguage < 0)
222 m_currentLanguage = indexForLocale(QLocale::system().name());
223
224+ if (m_currentFormat < 0)
225+ m_currentFormat = indexForLocale(QLocale::system().name());
226+
227 if (m_currentLanguage != previousLanguage)
228 Q_EMIT currentLanguageChanged();
229+
230+ if (m_currentFormat != previousFormat)
231+ Q_EMIT currentFormatChanged();
232 }
233
234
235
236=== modified file 'plugins/language/language-plugin.h'
237--- plugins/language/language-plugin.h 2015-12-22 13:49:39 +0000
238+++ plugins/language/language-plugin.h 2016-06-14 14:37:20 +0000
239@@ -56,6 +56,11 @@
240 WRITE setCurrentLanguage
241 NOTIFY currentLanguageChanged)
242
243+ Q_PROPERTY(int currentFormat
244+ READ currentFormat
245+ WRITE setCurrentFormat
246+ NOTIFY currentFormatChanged)
247+
248 Q_PROPERTY(SubsetModel *spellCheckingModel
249 READ spellCheckingModel
250 CONSTANT)
251@@ -73,6 +78,10 @@
252 void setCurrentLanguage(int index);
253 Q_SIGNAL void currentLanguageChanged() const;
254
255+ int currentFormat() const;
256+ void setCurrentFormat(int index);
257+ Q_SIGNAL void currentFormatChanged() const;
258+
259 SubsetModel *spellCheckingModel();
260 Q_SLOT void spellCheckingModelChanged();
261
262@@ -104,6 +113,8 @@
263
264 int m_currentLanguage;
265 int m_nextCurrentLanguage;
266+ int m_currentFormat;
267+ int m_nextCurrentFormat;
268 ActUserManager *m_manager;
269 ActUser *m_user;
270

Subscribers

People subscribed via source and target branches