Merge lp:~nik90/ubuntu-clock-app/implement-snooze-settings into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 90
Merged at revision: 89
Proposed branch: lp:~nik90/ubuntu-clock-app/implement-snooze-settings
Merge into: lp:ubuntu-clock-app
Diff against target: 517 lines (+273/-134)
4 files modified
app/alarm/AlarmSettingsPage.qml (+224/-134)
backend/modules/Alarm/Settings/alarmsettings.cpp (+30/-0)
backend/modules/Alarm/Settings/alarmsettings.h (+18/-0)
debian/changelog (+1/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/implement-snooze-settings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Charles Kerr (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+233622@code.launchpad.net

Commit message

Implement Alarm Snooze settings option as per design spec

Description of the change

Implement Alarm Snooze settings option as per design spec [1]. You will need image 228 or higher to test alarm snooze functionality!

Also do note that this MP is more about exposing alarm snooze settings in the clock app and less about the actual UI itself since I used the settings wireframes to implement it. I was told by the designer that we will be getting proper visual specs for the entire settings page.

[1] https://docs.google.com/presentation/d/1JvDyhsW17d1-Mz8OY1YMBKwfRI2z9qgyRjbujEsxEMk/edit#slide=id.g18895458d_024

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: Approve (continuous-integration)
90. By Nekhelesh Ramananthan

merged trunk

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
Charles Kerr (charlesk) wrote :

Reviewing the C++ parts of this MP; looks fine.

review: Approve
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

tested on flo. Works well, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmSettingsPage.qml'
2--- app/alarm/AlarmSettingsPage.qml 2014-09-04 13:50:49 +0000
3+++ app/alarm/AlarmSettingsPage.qml 2014-09-08 13:10:00 +0000
4@@ -28,6 +28,7 @@
5
6 title: i18n.tr("Settings")
7 visible: false
8+ flickable: null
9
10 Connections {
11 target: clockApp
12@@ -56,151 +57,240 @@
13 }
14 }
15
16- Column {
17- id: _settingsColumn
18-
19+ ListModel {
20+ id: snoozeModel
21+ Component.onCompleted: initialise()
22+
23+ function initialise() {
24+ snoozeModel.append({ "duration": 2, "text": i18n.tr("%1 minutes").arg(2) })
25+ snoozeModel.append({ "duration": 4, "text": i18n.tr("%1 minutes").arg(4) })
26+ snoozeModel.append({ "duration": 5, "text": i18n.tr("%1 minutes").arg(5) })
27+ snoozeModel.append({ "duration": 10, "text": i18n.tr("%1 minutes").arg(10) })
28+ }
29+ }
30+
31+ Flickable {
32+ id: settingsPlugin
33+
34+ contentHeight: _settingsColumn.height
35 anchors.fill: parent
36-
37- ListItem.Base {
38- height: 2 * implicitHeight
39-
40- Label {
41- color: UbuntuColors.midAubergine
42- text: i18n.tr("Alarm volume")
43- anchors.top: parent.top
44- anchors.topMargin: units.gu(1)
45- }
46-
47- Slider {
48- anchors.centerIn: parent
49- width: parent.width
50-
51- minimumValue: 1
52- maximumValue: 100
53- value: alarmSettings.volume
54-
55- onValueChanged: {
56- alarmSettings.volume = formatValue(value)
57- }
58- }
59- }
60-
61- ListItem.Expandable {
62- id: _alarmDuration
63+ clip: true
64+
65+ Column {
66+ id: _settingsColumn
67
68 anchors {
69+ top: parent.top
70 left: parent.left
71 right: parent.right
72- margins: units.gu(-2)
73- }
74-
75- collapseOnClick: true
76- expandedHeight: _contentColumn.height + units.gu(1)
77-
78- Column {
79- id: _contentColumn
80- width: parent.width
81-
82- Item {
83- width: parent.width
84- height: _alarmDuration.collapsedHeight
85-
86- SubtitledListItem {
87- id: _header
88- text: i18n.tr("Silence after")
89- subText: i18n.tr("%1 minutes").arg(alarmSettings.duration)
90- onClicked: _alarmDuration.expanded = true
91-
92- Icon {
93- id: _upArrow
94-
95- width: units.gu(2)
96- height: width
97- anchors.right: parent.right
98- anchors.verticalCenter: parent.verticalCenter
99-
100- name: "go-down"
101- color: "Grey"
102- rotation: _alarmDuration.expanded ? 180 : 0
103-
104- Behavior on rotation {
105- UbuntuNumberAnimation {}
106- }
107- }
108- }
109- }
110-
111- ListView {
112- id: _resultsList
113- clip: true
114- model: durationModel
115- width: parent.width
116- height: units.gu(24)
117- delegate: ListItem.Standard {
118- text: model.text
119- onClicked: {
120- alarmSettings.duration = duration
121- _alarmDuration.expanded = false
122- }
123- }
124- }
125- }
126- }
127-
128- ListItem.Base {
129- Label {
130- text: i18n.tr("Vibration")
131- color: UbuntuColors.midAubergine
132- anchors.verticalCenter: parent.verticalCenter
133- }
134-
135- Switch {
136- id: vibrateSwitch
137-
138- anchors {
139- right: parent.right
140- verticalCenter: parent.verticalCenter
141- }
142-
143- checked: alarmSettings.vibration === "pulse"
144- onCheckedChanged: {
145- if(checked) {
146- alarmSettings.vibration = "pulse"
147- } else {
148- alarmSettings.vibration = "none"
149- }
150- }
151- }
152-
153- onClicked: {
154- vibrateSwitch.checked = !vibrateSwitch.checked
155- }
156- }
157-
158- SubtitledListItem {
159- text: i18n.tr("Change time and date")
160- subText: {
161- /*
162+ }
163+
164+ ListItem.Base {
165+ height: 2 * implicitHeight
166+
167+ Label {
168+ color: UbuntuColors.midAubergine
169+ text: i18n.tr("Alarm volume")
170+ anchors.top: parent.top
171+ anchors.topMargin: units.gu(1)
172+ }
173+
174+ Slider {
175+ anchors.centerIn: parent
176+ width: parent.width
177+
178+ minimumValue: 1
179+ maximumValue: 100
180+ value: alarmSettings.volume
181+
182+ onValueChanged: {
183+ alarmSettings.volume = formatValue(value)
184+ }
185+ }
186+ }
187+
188+ ListItem.Expandable {
189+ id: _alarmDuration
190+
191+ anchors {
192+ left: parent.left
193+ right: parent.right
194+ margins: units.gu(-2)
195+ }
196+
197+ collapseOnClick: true
198+ expandedHeight: _contentColumn.height + units.gu(1)
199+
200+ Column {
201+ id: _contentColumn
202+ width: parent.width
203+
204+ Item {
205+ width: parent.width
206+ height: _alarmDuration.collapsedHeight
207+
208+ SubtitledListItem {
209+ id: _header
210+ text: i18n.tr("Silence after")
211+ subText: i18n.tr("%1 minutes").arg(alarmSettings.duration)
212+ onClicked: _alarmDuration.expanded = true
213+
214+ Icon {
215+ id: _upArrow
216+
217+ width: units.gu(2)
218+ height: width
219+ anchors.right: parent.right
220+ anchors.verticalCenter: parent.verticalCenter
221+
222+ name: "go-down"
223+ color: "Grey"
224+ rotation: _alarmDuration.expanded ? 180 : 0
225+
226+ Behavior on rotation {
227+ UbuntuNumberAnimation {}
228+ }
229+ }
230+ }
231+ }
232+
233+ ListView {
234+ id: _resultsList
235+ clip: true
236+ interactive: false
237+ model: durationModel
238+ width: parent.width
239+ height: units.gu(24)
240+ delegate: ListItem.Standard {
241+ text: model.text
242+ onClicked: {
243+ alarmSettings.duration = duration
244+ _alarmDuration.expanded = false
245+ }
246+ }
247+ }
248+ }
249+ }
250+
251+ ListItem.Expandable {
252+ id: _alarmSnooze
253+
254+ anchors {
255+ left: parent.left
256+ right: parent.right
257+ margins: units.gu(-2)
258+ }
259+
260+ collapseOnClick: true
261+ expandedHeight: _snoozeContentColumn.height + units.gu(1)
262+
263+ Column {
264+ id: _snoozeContentColumn
265+ width: parent.width
266+
267+ Item {
268+ width: parent.width
269+ height: _alarmSnooze.collapsedHeight
270+
271+ SubtitledListItem {
272+ id: _snoozeHeader
273+ text: i18n.tr("Snooze for")
274+ subText: i18n.tr("%1 minutes").arg(alarmSettings.snoozeDuration)
275+ onClicked: _alarmSnooze.expanded = true
276+
277+ Icon {
278+ id: _snoozeUpArrow
279+
280+ width: units.gu(2)
281+ height: width
282+ anchors.right: parent.right
283+ anchors.verticalCenter: parent.verticalCenter
284+
285+ name: "go-down"
286+ color: "Grey"
287+ rotation: _alarmSnooze.expanded ? 180 : 0
288+
289+ Behavior on rotation {
290+ UbuntuNumberAnimation {}
291+ }
292+ }
293+ }
294+ }
295+
296+ ListView {
297+ id: _snoozeResultsList
298+ clip: true
299+ interactive: false
300+ model: snoozeModel
301+ width: parent.width
302+ height: units.gu(24)
303+
304+ delegate: ListItem.Standard {
305+ text: model.text
306+ onClicked: {
307+ alarmSettings.snoozeDuration = duration
308+ _alarmSnooze.expanded = false
309+ }
310+ }
311+ }
312+ }
313+ }
314+
315+ ListItem.Base {
316+ Label {
317+ text: i18n.tr("Vibration")
318+ color: UbuntuColors.midAubergine
319+ anchors.verticalCenter: parent.verticalCenter
320+ }
321+
322+ Switch {
323+ id: vibrateSwitch
324+
325+ anchors {
326+ right: parent.right
327+ verticalCenter: parent.verticalCenter
328+ }
329+
330+ checked: alarmSettings.vibration === "pulse"
331+ onCheckedChanged: {
332+ if(checked) {
333+ alarmSettings.vibration = "pulse"
334+ } else {
335+ alarmSettings.vibration = "none"
336+ }
337+ }
338+ }
339+
340+ onClicked: {
341+ vibrateSwitch.checked = !vibrateSwitch.checked
342+ }
343+ }
344+
345+ SubtitledListItem {
346+ text: i18n.tr("Change time and date")
347+ subText: {
348+ /*
349 FIXME: When the upstream QT bug at
350 https://bugreports.qt-project.org/browse/QTBUG-40275 is fixed
351 it will be possible to receive a datetime object directly
352 instead of using this hack.
353 */
354- var localTime = new Date
355- (
356- localTimeSource.localDateString.split(":")[0],
357- localTimeSource.localDateString.split(":")[1]-1,
358- localTimeSource.localDateString.split(":")[2],
359- localTimeSource.localTimeString.split(":")[0],
360- localTimeSource.localTimeString.split(":")[1],
361- localTimeSource.localTimeString.split(":")[2],
362- localTimeSource.localTimeString.split(":")[3]
363- )
364- return localTime.toLocaleString()
365- }
366+ var localTime = new Date
367+ (
368+ localTimeSource.localDateString.split(":")[0],
369+ localTimeSource.localDateString.split(":")[1]-1,
370+ localTimeSource.localDateString.split(":")[2],
371+ localTimeSource.localTimeString.split(":")[0],
372+ localTimeSource.localTimeString.split(":")[1],
373+ localTimeSource.localTimeString.split(":")[2],
374+ localTimeSource.localTimeString.split(":")[3]
375+ )
376+ return localTime.toLocaleString()
377+ }
378
379- onClicked: {
380- Qt.openUrlExternally("settings:///system/time-date")
381+ onClicked: {
382+ Qt.openUrlExternally("settings:///system/time-date")
383+ }
384 }
385 }
386 }
387
388=== modified file 'backend/modules/Alarm/Settings/alarmsettings.cpp'
389--- backend/modules/Alarm/Settings/alarmsettings.cpp 2014-08-02 14:54:00 +0000
390+++ backend/modules/Alarm/Settings/alarmsettings.cpp 2014-09-08 13:10:00 +0000
391@@ -66,6 +66,16 @@
392 }
393 }
394
395+ it = properties.find("SnoozeDuration");
396+
397+ if (it != properties.end()) {
398+ const int snoozeDuration = it.value().toInt();
399+ if (m_snoozeDuration != snoozeDuration) {
400+ m_snoozeDuration = snoozeDuration;
401+ emit snoozeDurationChanged();
402+ }
403+ }
404+
405 it = properties.find("HapticFeedback");
406
407 if (it != properties.end()) {
408@@ -97,6 +107,7 @@
409
410 m_volume = map["DefaultVolume"].toInt();
411 m_duration = map["Duration"].toInt();
412+ m_snoozeDuration = map["SnoozeDuration"].toInt();
413 m_vibration = map["HapticFeedback"].toString();
414 }
415
416@@ -124,6 +135,11 @@
417 return m_duration;
418 }
419
420+int AlarmSettings::snoozeDuration() const
421+{
422+ return m_snoozeDuration;
423+}
424+
425 QString AlarmSettings::vibration() const
426 {
427 return m_vibration;
428@@ -157,6 +173,20 @@
429 setDBusProperty("Duration", QVariant(m_duration));
430 }
431
432+void AlarmSettings::setSnoozeDuration(int snoozeDuration)
433+{
434+ if(m_snoozeDuration == snoozeDuration) {
435+ // Don't send the snooze duration over dbus if it is the same one already
436+ return;
437+ }
438+
439+ // Change the property and let qml know about it
440+ m_snoozeDuration = snoozeDuration;
441+ emit snoozeDurationChanged();
442+
443+ setDBusProperty("SnoozeDuration", QVariant(m_snoozeDuration));
444+}
445+
446 void AlarmSettings::setVibration(QString vibration)
447 {
448 if(m_vibration == vibration) {
449
450=== modified file 'backend/modules/Alarm/Settings/alarmsettings.h'
451--- backend/modules/Alarm/Settings/alarmsettings.h 2014-08-02 14:54:00 +0000
452+++ backend/modules/Alarm/Settings/alarmsettings.h 2014-09-08 13:10:00 +0000
453@@ -38,6 +38,12 @@
454 WRITE setDuration
455 NOTIFY durationChanged)
456
457+ // Property to control the snooze duration
458+ Q_PROPERTY(int snoozeDuration
459+ READ snoozeDuration
460+ WRITE setSnoozeDuration
461+ NOTIFY snoozeDurationChanged)
462+
463 // Property to control the haptic feedback mode
464 Q_PROPERTY(QString vibration
465 READ vibration
466@@ -53,6 +59,9 @@
467 // Function to return the alarm duration
468 int duration() const;
469
470+ // Function to return the snooze duration
471+ int snoozeDuration() const;
472+
473 // Function to return the alarm haptic mode
474 QString vibration() const;
475
476@@ -62,6 +71,9 @@
477 // Function to set the alarm duration
478 void setDuration(int duration);
479
480+ // Function to set the snooze duration
481+ void setSnoozeDuration(int snoozeDuration);
482+
483 // Function to set the alarm haptic mode
484 void setVibration(QString vibration);
485
486@@ -72,6 +84,9 @@
487 // Signal to notify the duration change to QML
488 void durationChanged();
489
490+ // Signal to notify the snooze duration change to QML
491+ void snoozeDurationChanged();
492+
493 // Signal to notify the vibration mode change to QML
494 void vibrationChanged();
495
496@@ -82,6 +97,9 @@
497 // Keep a store of the alarm duration
498 int m_duration;
499
500+ // Keep a store of the alarm snooze duration
501+ int m_snoozeDuration;
502+
503 // Keep a store of the alarm haptic mode
504 QString m_vibration;
505
506
507=== modified file 'debian/changelog'
508--- debian/changelog 2014-09-04 22:03:57 +0000
509+++ debian/changelog 2014-09-08 13:10:00 +0000
510@@ -29,6 +29,7 @@
511 * Added pressed visual state to the settings button (LP: #1364553)
512 * Fixed no UI hint being show to add cities (LP: #1362263)
513 * Fixed add world city being triggered accidentally (LP: #1359180)
514+ * Added alarm snooze settings (LP: #1354400)
515
516 [Zsombor Egri]
517 * Fixed alarm status toggle being reverted immediately (LP: #1272337)

Subscribers

People subscribed via source and target branches