Merge lp:~nik90/ubuntu-clock-app/migrate-u1db-to-qtlabs into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Work in progress
Proposed branch: lp:~nik90/ubuntu-clock-app/migrate-u1db-to-qtlabs
Merge into: lp:ubuntu-clock-app
Diff against target: 241 lines (+40/-53)
8 files modified
app/clock/ClockPage.qml (+10/-20)
app/clock/MainClock.qml (+1/-1)
app/components/Clock.qml (+1/-4)
app/ubuntu-clock-app.qml (+12/-14)
app/worldclock/UserWorldCityDelegate.qml (+2/-2)
debian/changelog (+1/-0)
debian/control (+1/-0)
tests/unit/MockClockApp.qml (+12/-12)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/migrate-u1db-to-qtlabs
Reviewer Review Type Date Requested Status
Bartosz Kosiorek Needs Fixing
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+268384@code.launchpad.net

Commit message

Migrated user clock settings from u1db to qt.labs.settings.

Description of the change

Migrates clock settings such as user location settings, digital/analogue mode setting from u1db to Qt.labs.settings for the following reasons,

- Recommended by the SDK developers to store app settings using Qt.labs.settings
- Code syntax is also much easier to understand and maintain
- Future stopwatch branch is also using Qt.labs.settings to store stopwatch status. So this will be a good point to unify them.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
342. By Nekhelesh Ramananthan

Added qt labs depedency to debian to fix failing unit test

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

Added u1db database as it is needed for world city list

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
Bartosz Kosiorek (gang65) wrote :

I notices some issues regarding restoring clock type (analog or digital).
Steps to reproduce:

1. Add several world clock
2. Change clock from analog to digital. Notice that world clock are changed to digital
3. Close app
4. Run clock again
5. Notice that main clock face is digital, but all world clock is analog. Switching to analog is causing that world cities times are switching to digital

review: Needs Fixing
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

After further testing, it seems that time need to start increased from 3,825s to 5.15s

I think it needs to be fixed.

review: Needs Fixing

Unmerged revisions

343. By Nekhelesh Ramananthan

Added u1db database as it is needed for world city list

342. By Nekhelesh Ramananthan

Added qt labs depedency to debian to fix failing unit test

341. By Nekhelesh Ramananthan

Updated debian changelog

340. By Nekhelesh Ramananthan

merged lp:ubuntu-clock-app

339. By Nekhelesh Ramananthan

Migrated clock settings from U1db to Qt.labs.settings

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/clock/ClockPage.qml'
2--- app/clock/ClockPage.qml 2015-08-07 11:45:17 +0000
3+++ app/clock/ClockPage.qml 2015-08-18 21:21:30 +0000
4@@ -17,7 +17,6 @@
5 */
6
7 import QtQuick 2.4
8-import U1db 1.0 as U1db
9 import QtPositioning 5.2
10 import Ubuntu.Components 1.2
11 import GeoLocation 1.0
12@@ -74,12 +73,8 @@
13
14 // If this is the first time, then set location as Denied
15 // to indicate user denying clock app location access.
16- if (userLocationDocument.contents.location === "Null") {
17- var locationData = JSON.parse
18- (JSON.stringify(userLocationDocument.contents))
19-
20- locationData.location = "Denied"
21- userLocationDocument.contents = locationData
22+ if (clockLocationSetting.location === "Null") {
23+ clockLocationSetting.location = "Denied"
24 }
25 }
26 }
27@@ -94,8 +89,8 @@
28 Stop querying for the user location if it is found to be
29 the same as the one stored in the app setting database
30 */
31- if (userLongitude === userLocationDocument.contents.long ||
32- userLatitude === userLocationDocument.contents.lat) {
33+ if (userLongitude === clockLocationSetting.longitude ||
34+ userLatitude === clockLocationSetting.latitude) {
35 if (geoposition.active) {
36 console.log("[LOG]: Stopping geolocation update service")
37 geoposition.stop()
38@@ -146,14 +141,9 @@
39 }
40
41 onLocationChanged: {
42- var locationData = JSON.parse
43- (JSON.stringify(userLocationDocument.contents))
44-
45- locationData.lat = geoposition.userLatitude
46- locationData.long = geoposition.userLongitude
47- locationData.location = userLocation.location
48-
49- userLocationDocument.contents = locationData
50+ clockLocationSetting.latitude = geoposition.userLatitude
51+ clockLocationSetting.longitude = geoposition.userLongitude
52+ clockLocationSetting.location = userLocation.location
53
54 /*
55 Stop querying the user coordinates once the user location has been
56@@ -278,14 +268,14 @@
57 color: UbuntuColors.midAubergine
58
59 text: {
60- if (userLocationDocument.contents.location === "Null"
61- || userLocationDocument.contents.location === "Denied"
62+ if (clockLocationSetting.location === "Null"
63+ || clockLocationSetting.location === "Denied"
64 && geoposition.sourceError === PositionSource.NoError) {
65 return i18n.tr("Retrieving location...")
66 }
67
68 else {
69- return userLocationDocument.contents.location
70+ return clockLocationSetting.location
71 }
72 }
73 }
74
75=== modified file 'app/clock/MainClock.qml'
76--- app/clock/MainClock.qml 2015-05-27 16:03:23 +0000
77+++ app/clock/MainClock.qml 2015-08-18 21:21:30 +0000
78@@ -32,7 +32,7 @@
79
80 isMainClock: true
81
82- isDigital: clockModeDocument.contents.digitalMode ? true : false
83+ isDigital: clockSetting.digitalMode ? true : false
84
85 Component.onCompleted: {
86 clockOpenAnimation.start()
87
88=== modified file 'app/components/Clock.qml'
89--- app/components/Clock.qml 2015-08-14 05:34:49 +0000
90+++ app/components/Clock.qml 2015-08-18 21:21:30 +0000
91@@ -243,10 +243,7 @@
92 analogShadow.source = digitalShadow.source = ""
93
94 if(isMainClock) {
95- var isDigitalSetting = JSON.parse
96- (JSON.stringify(clockModeDocument.contents))
97- isDigitalSetting.digitalMode = isDigital
98- clockModeDocument.contents = isDigitalSetting
99+ clockSetting.digitalMode = isDigital
100 }
101 }
102 }
103
104=== modified file 'app/ubuntu-clock-app.qml'
105--- app/ubuntu-clock-app.qml 2015-07-15 22:31:52 +0000
106+++ app/ubuntu-clock-app.qml 2015-08-18 21:21:30 +0000
107@@ -19,6 +19,7 @@
108 import QtQuick 2.4
109 import DateTime 1.0
110 import U1db 1.0 as U1db
111+import Qt.labs.settings 1.0
112 import Ubuntu.Components 1.2
113 import "clock"
114 import "components"
115@@ -55,27 +56,24 @@
116
117 Background {}
118
119- // Database to store the user preferences locally
120+ // Database to store the saved user world city list locally
121 U1db.Database {
122 id: clockDB
123 path: "user-preferences"
124 }
125
126- // Document to store clock mode chosen by user
127- U1db.Document {
128- id: clockModeDocument
129- create: true
130- database: clockDB
131- docId: "clockModeDocument"
132- defaults: { "digitalMode": false }
133+ Settings {
134+ id: clockSetting
135+ category: "Clock"
136+ property bool digitalMode: false
137 }
138
139- U1db.Document {
140- id: userLocationDocument
141- create: true
142- database: clockDB
143- docId: "userLocationDocument"
144- defaults: { "lat": "NaN", "long": "Nan", "location": "Null" }
145+ Settings {
146+ id: clockLocationSetting
147+ category: "Location"
148+ property string latitude: "NaN"
149+ property string longitude: "NaN"
150+ property string location: "Null"
151 }
152
153 DateTime {
154
155=== modified file 'app/worldclock/UserWorldCityDelegate.qml'
156--- app/worldclock/UserWorldCityDelegate.qml 2015-08-14 05:34:49 +0000
157+++ app/worldclock/UserWorldCityDelegate.qml 2015-08-18 21:21:30 +0000
158@@ -104,8 +104,8 @@
159 }
160
161 Component.onCompleted: {
162- isDigital = clockModeDocument.contents.digitalMode ? true : false
163- if (clockModeDocument.contents.digitalMode) {
164+ isDigital = clockSetting.digitalMode ? true : false
165+ if (clockSetting.digitalMode) {
166 digitalModeLoader.setSource
167 ("../components/DigitalMode.qml",
168 {
169
170=== modified file 'debian/changelog'
171--- debian/changelog 2015-08-16 20:53:03 +0000
172+++ debian/changelog 2015-08-18 21:21:30 +0000
173@@ -14,6 +14,7 @@
174 * Added README.mergeproposal checklist to help with the review process.
175 * Fix alarm interval information being inconsistent (LP: #1466000)
176 * Changed default alarm sound (LP: #1354370)
177+ * Migrated clock settings from U1db to Qt.labs.settings 1.0
178
179 [Victor Thompson]
180 * Show all README files in QtCreator
181
182=== modified file 'debian/control'
183--- debian/control 2015-07-27 20:52:03 +0000
184+++ debian/control 2015-08-18 21:21:30 +0000
185@@ -10,6 +10,7 @@
186 ubuntu-touch-sounds,
187 suru-icon-theme | ubuntu-mobile-icons,
188 qml-module-qttest,
189+ qml-module-qt-labs-settings,
190 qtdeclarative5-u1db1.0,
191 qtdeclarative5-qtmultimedia-plugin,
192 qtdeclarative5-qtpositioning-plugin,
193
194=== modified file 'tests/unit/MockClockApp.qml'
195--- tests/unit/MockClockApp.qml 2015-08-14 05:34:49 +0000
196+++ tests/unit/MockClockApp.qml 2015-08-18 21:21:30 +0000
197@@ -19,6 +19,7 @@
198 import QtQuick 2.4
199 import DateTime 1.0
200 import U1db 1.0 as U1db
201+import Qt.labs.settings 1.0
202 import Ubuntu.Components 1.2
203 import "../../app/clock"
204 import "../../app/components"
205@@ -39,25 +40,24 @@
206 height: units.gu(70)
207 applicationName: "com.ubuntu.fakeclock.test"
208
209+ // Database to store the saved user world city list locally
210 U1db.Database {
211 id: clockDB
212 path: "user-preferences"
213 }
214
215- U1db.Document {
216- id: clockModeDocument
217- create: true
218- database: clockDB
219- docId: "clockModeDocument"
220- defaults: { "digitalMode": false }
221+ Settings {
222+ id: clockSetting
223+ category: "Clock"
224+ property bool digitalMode: false
225 }
226
227- U1db.Document {
228- id: userLocationDocument
229- create: true
230- database: clockDB
231- docId: "userLocationDocument"
232- defaults: { "lat": "NaN", "long": "Nan", "location": "Null" }
233+ Settings {
234+ id: clockLocationSetting
235+ category: "Location"
236+ property string latitude: "NaN"
237+ property string longitude: "NaN"
238+ property string location: "Null"
239 }
240
241 DateTime {

Subscribers

People subscribed via source and target branches