Merge lp:~nik90/ubuntu-clock-app/dynamic-pageheadstate-load into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 156
Merged at revision: 156
Proposed branch: lp:~nik90/ubuntu-clock-app/dynamic-pageheadstate-load
Merge into: lp:ubuntu-clock-app
Diff against target: 399 lines (+139/-111)
7 files modified
app/alarm/AlarmPage.qml (+77/-64)
app/alarm/AlarmSettingsPage.qml (+4/-4)
app/alarm/AlarmSound.qml (+0/-1)
app/alarm/EditAlarmPage.qml (+0/-1)
app/components/EmptyState.qml (+7/-1)
app/worldclock/WorldCityList.qml (+49/-40)
debian/changelog (+2/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/dynamic-pageheadstate-load
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Clock Developers Pending
Review via email: mp+238594@code.launchpad.net

Commit message

Dynamically load/unload the search mode in world city list and multiselect view in the alarm page which reduces the creation time by a few ms.

Description of the change

This MP implements the following,
- Dynamically load/unload the alarm page multiselection PageHeadState which reduces the creation time by 5ms.
- Dynamically load/unload the search mode in the worldcitypage which reduces the creation time by 7ms.
- Unload the Empty alarm state when not required

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Dont let the big code diff trick you ;). It is just moving some code into a Component{} and using a Loader{}. No UI changes. Just performance patches.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
156. By Nekhelesh Ramananthan

Removed clip whereever it is unnecessary

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmPage.qml'
2--- app/alarm/AlarmPage.qml 2014-10-11 11:46:39 +0000
3+++ app/alarm/AlarmPage.qml 2014-10-16 19:04:00 +0000
4@@ -61,68 +61,76 @@
5 }
6 }
7
8- contents: Item {
9+ contents: Loader {
10+ id: selectionStateLoader
11+ active: alarmPage.state === "selection"
12+ sourceComponent: selectionStateComponent
13+ height: parent ? parent.height : undefined
14 anchors.right: parent ? parent.right: undefined
15- height: parent ? parent.height : undefined
16-
17- HeaderButton {
18- id: selectButton
19-
20- anchors {
21- right: deleteButton.left
22- rightMargin: units.gu(1)
23- }
24-
25- text: {
26- if(alarmListView.selectedItems.count === alarmListView.count) {
27- return i18n.tr("Select None")
28- } else {
29- return i18n.tr("Select All")
30- }
31- }
32-
33- iconSource: {
34- if(alarmListView.selectedItems.count === alarmListView.count) {
35- return Qt.resolvedUrl("../graphics/select-none.svg")
36- } else {
37- return Qt.resolvedUrl("../graphics/select.svg")
38- }
39- }
40-
41- onTriggered: {
42- if(alarmListView.selectedItems.count === alarmListView.count) {
43- alarmListView.clearSelection()
44- } else {
45- alarmListView.selectAll()
46- }
47- }
48- }
49-
50- HeaderButton {
51- id: deleteButton
52-
53- anchors.right: parent.right
54- anchors.rightMargin: units.gu(2)
55-
56- iconName: "delete"
57- text: i18n.tr("Delete")
58- enabled: alarmListView.selectedItems.count !== 0
59-
60- onTriggered: {
61- var items = alarmListView.selectedItems
62-
63- for(var i=0; i < items.count; i++) {
64- var alarm = alarmModel.get(items.get(i).itemsIndex)
65- alarm.cancel()
66- }
67-
68- alarmListView.endSelection()
69- }
70- }
71 }
72 }
73 ]
74
75+ Component {
76+ id: selectionStateComponent
77+ Item {
78+ HeaderButton {
79+ id: selectButton
80+
81+ anchors {
82+ right: deleteButton.left
83+ rightMargin: units.gu(1)
84+ }
85+
86+ text: {
87+ if(alarmListView.selectedItems.count === alarmListView.count) {
88+ return i18n.tr("Select None")
89+ } else {
90+ return i18n.tr("Select All")
91+ }
92+ }
93+
94+ iconSource: {
95+ if(alarmListView.selectedItems.count === alarmListView.count) {
96+ return Qt.resolvedUrl("../graphics/select-none.svg")
97+ } else {
98+ return Qt.resolvedUrl("../graphics/select.svg")
99+ }
100+ }
101+
102+ onTriggered: {
103+ if(alarmListView.selectedItems.count === alarmListView.count) {
104+ alarmListView.clearSelection()
105+ } else {
106+ alarmListView.selectAll()
107+ }
108+ }
109+ }
110+
111+ HeaderButton {
112+ id: deleteButton
113+
114+ anchors.right: parent.right
115+ anchors.rightMargin: units.gu(2)
116+
117+ iconName: "delete"
118+ text: i18n.tr("Delete")
119+ enabled: alarmListView.selectedItems.count !== 0
120+
121+ onTriggered: {
122+ var items = alarmListView.selectedItems
123+
124+ for(var i=0; i < items.count; i++) {
125+ var alarm = alarmModel.get(items.get(i).itemsIndex)
126+ alarm.cancel()
127+ }
128+
129+ alarmListView.endSelection()
130+ }
131+ }
132+ }
133+ }
134+
135 AlarmList {
136 id: alarmListView
137 listModel: alarmModel
138@@ -130,12 +138,17 @@
139 localTime: clockTime
140 }
141
142- EmptyState {
143- visible: alarmModel ? alarmModel.count === 0 : true
144- anchors.verticalCenter: parent.verticalCenter
145-
146- iconName: "alarm-clock"
147- title: i18n.tr("No saved alarms")
148- subTitle: i18n.tr("Tap the + icon to add an alarm")
149+ Loader {
150+ id: emptyStateLoader
151+ anchors.centerIn: parent
152+ active: alarmModel ? alarmModel.count === 0 : true
153+ Component.onCompleted: {
154+ setSource(Qt.resolvedUrl("../components/EmptyState.qml"),
155+ {
156+ "iconName": "alarm-clock",
157+ "title": i18n.tr("No saved alarms"),
158+ "subTitle": i18n.tr("Tap the + icon to add an alarm")
159+ })
160+ }
161 }
162 }
163
164=== modified file 'app/alarm/AlarmSettingsPage.qml'
165--- app/alarm/AlarmSettingsPage.qml 2014-10-15 20:59:05 +0000
166+++ app/alarm/AlarmSettingsPage.qml 2014-10-16 19:04:00 +0000
167@@ -28,7 +28,7 @@
168
169 title: i18n.tr("Settings")
170 visible: false
171- flickable: null
172+ flickable: settingsPlugin
173
174 Connections {
175 target: clockApp
176@@ -74,7 +74,6 @@
177
178 contentHeight: _settingsColumn.height
179 anchors.fill: parent
180- clip: true
181
182 Column {
183 id: _settingsColumn
184@@ -169,11 +168,12 @@
185
186 ListView {
187 id: _resultsList
188- clip: true
189+
190 interactive: false
191 model: durationModel
192 width: parent.width
193 height: units.gu(24)
194+
195 delegate: ListItem.Standard {
196 text: model.text
197 onClicked: {
198@@ -237,7 +237,7 @@
199
200 ListView {
201 id: _snoozeResultsList
202- clip: true
203+
204 interactive: false
205 model: snoozeModel
206 width: parent.width
207
208=== modified file 'app/alarm/AlarmSound.qml'
209--- app/alarm/AlarmSound.qml 2014-09-25 11:26:43 +0000
210+++ app/alarm/AlarmSound.qml 2014-10-16 19:04:00 +0000
211@@ -53,7 +53,6 @@
212 Flickable {
213 id: _pageFlickable
214
215- clip: true
216 anchors.fill: parent
217 contentHeight: soundModel.count * units.gu(7)
218
219
220=== modified file 'app/alarm/EditAlarmPage.qml'
221--- app/alarm/EditAlarmPage.qml 2014-10-15 09:52:24 +0000
222+++ app/alarm/EditAlarmPage.qml 2014-10-16 19:04:00 +0000
223@@ -262,7 +262,6 @@
224 margins: units.gu(-2)
225 }
226
227- clip: true
228 mode: "Hours|Minutes"
229 date: {
230 if(isNewAlarm) {
231
232=== modified file 'app/components/EmptyState.qml'
233--- app/components/EmptyState.qml 2014-09-12 15:36:38 +0000
234+++ app/components/EmptyState.qml 2014-10-16 19:04:00 +0000
235@@ -19,14 +19,20 @@
236 import QtQuick 2.3
237 import Ubuntu.Components 1.1
238
239+/*
240+ Component which displays an empty state (approved by design). It offers an
241+ icon, title and subtitle to describe the empty state.
242+*/
243+
244 Item {
245+ id: emptyState
246
247+ // Public APIs
248 property alias iconName: emptyIcon.name
249 property alias title: emptyLabel.text
250 property alias subTitle: emptySublabel.text
251
252 height: childrenRect.height
253- width: parent.width
254
255 Icon {
256 id: emptyIcon
257
258=== modified file 'app/worldclock/WorldCityList.qml'
259--- app/worldclock/WorldCityList.qml 2014-10-15 20:42:24 +0000
260+++ app/worldclock/WorldCityList.qml 2014-10-16 19:04:00 +0000
261@@ -64,8 +64,9 @@
262 text: i18n.tr("City")
263 onTriggered: {
264 worldCityList.state = "search"
265+ searchComponentLoader.sourceComponent = searchComponent
266 jsonTimeZoneModelLoader.sourceComponent = jsonTimeZoneModelComponent
267- searchField.forceActiveFocus()
268+ searchComponentLoader.item.forceActiveFocus()
269 }
270 }
271 ]
272@@ -79,59 +80,66 @@
273 text: i18n.tr("Back")
274 onTriggered: {
275 cityList.forceActiveFocus()
276- searchField.text = ""
277+ searchComponentLoader.item.text = ""
278 worldCityList.state = "default"
279 isOnlineMode = false
280+ searchComponentLoader.sourceComponent = undefined
281 jsonTimeZoneModelLoader.sourceComponent = undefined
282 }
283 }
284
285- contents: TextField {
286- id: searchField
287- objectName: "searchField"
288-
289- inputMethodHints: Qt.ImhNoPredictiveText
290- placeholderText: i18n.tr("Search...")
291-
292+ contents: Loader {
293+ id: searchComponentLoader
294 anchors {
295 left: parent ? parent.left : undefined
296 right: parent ? parent.right : undefined
297 rightMargin: units.gu(2)
298 }
299-
300- Timer {
301- id: search_timer
302- interval: isOnlineMode ? 1 : 500
303- repeat: false
304- onTriggered: {
305- isOnlineMode = false
306- console.log("Search string: " + searchField.text)
307-
308- if(!isOnlineMode && sortedTimeZoneModel.count === 0) {
309- console.log("Enabling online mode")
310- isOnlineMode = true
311- }
312-
313- if(isOnlineMode) {
314- var url = String("%1%2%3")
315- .arg("http://geoname-lookup.ubuntu.com/?query=")
316- .arg(searchField.text)
317- .arg("&app=com.ubuntu.clock&version=3.2.x")
318- console.log("Online URL: " + url)
319- if (jsonTimeZoneModelLoader.status === Loader.Ready) {
320- jsonTimeZoneModel.source = Qt.resolvedUrl(url)
321- }
322- }
323- }
324- }
325-
326- onTextChanged: {
327- search_timer.restart()
328- }
329 }
330 }
331 ]
332
333+ Component {
334+ id: searchComponent
335+ TextField {
336+ id: searchField
337+ objectName: "searchField"
338+
339+ inputMethodHints: Qt.ImhNoPredictiveText
340+ placeholderText: i18n.tr("Search...")
341+
342+ Timer {
343+ id: search_timer
344+ interval: isOnlineMode ? 1 : 500
345+ repeat: false
346+ onTriggered: {
347+ isOnlineMode = false
348+ console.log("Search string: " + searchField.text)
349+
350+ if(!isOnlineMode && sortedTimeZoneModel.count === 0) {
351+ console.log("Enabling online mode")
352+ isOnlineMode = true
353+ }
354+
355+ if(isOnlineMode) {
356+ var url = String("%1%2%3")
357+ .arg("http://geoname-lookup.ubuntu.com/?query=")
358+ .arg(searchField.text)
359+ .arg("&app=com.ubuntu.clock&version=3.2.x")
360+ console.log("Online URL: " + url)
361+ if (jsonTimeZoneModelLoader.status === Loader.Ready) {
362+ jsonTimeZoneModel.source = Qt.resolvedUrl(url)
363+ }
364+ }
365+ }
366+ }
367+
368+ onTextChanged: {
369+ search_timer.restart()
370+ }
371+ }
372+ }
373+
374 Connections {
375 target: clockApp
376 onApplicationStateChanged: {
377@@ -193,7 +201,8 @@
378 sort.property: "city"
379 sort.order: Qt.AscendingOrder
380 filter.property: "city"
381- filter.pattern: RegExp(searchField.text, "gi")
382+ filter.pattern: searchComponentLoader.status === Loader.Ready ? RegExp(searchComponentLoader.item.text, "gi")
383+ : RegExp("", "gi")
384 }
385
386 Label {
387
388=== modified file 'debian/changelog'
389--- debian/changelog 2014-10-15 21:01:31 +0000
390+++ debian/changelog 2014-10-16 19:04:00 +0000
391@@ -21,6 +21,8 @@
392 dynamically (LP: #1381429)
393 * Replaced ListItem.Base with ListItem.Empty throughout the clock app to reduce
394 creation time (performance).
395+ * Dynamically load/unload the search mode in world city list and multiselect view in
396+ alarm page which reduces the creation time by a few ms.
397 * Customised splash screen (white background) (LP: #1377638)
398
399 [Akiva Shammai Avraham]

Subscribers

People subscribed via source and target branches