Merge lp:~nik90/ubuntu-clock-app/edit-alarm-feature into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 13
Proposed branch: lp:~nik90/ubuntu-clock-app/edit-alarm-feature
Merge into: lp:ubuntu-clock-app
Diff against target: 1036 lines (+793/-129)
11 files modified
app/alarm/AlarmLabel.qml (+61/-0)
app/alarm/AlarmList.qml (+117/-72)
app/alarm/AlarmPage.qml (+14/-0)
app/alarm/AlarmRepeat.qml (+108/-0)
app/alarm/AlarmSound.qml (+115/-0)
app/alarm/AlarmUtils.qml (+109/-50)
app/alarm/EditAlarmPage.qml (+131/-0)
app/clock/ClockPage.qml (+6/-2)
app/components/PullToAdd.qml (+77/-0)
app/components/SubtitledListItem.qml (+55/-0)
app/ubuntu-clock-app.qml (+0/-5)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/edit-alarm-feature
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Victor Thompson Approve
Andrew Hayzen Pending
Ubuntu Clock Developers Pending
Review via email: mp+224360@code.launchpad.net

Commit message

Added support for creating new alarms and made the pulltoadd component as a generic component since it is required in two places.

Description of the change

This MP adds the following,

- Added support for creating new alarms
- Made the pulltoadd component as a generic component since it is required in two places

I will add support to edit saved alarms in my next branch

To post a comment you must log in.
29. By Nekhelesh Ramananthan

merged trunk

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

merge master

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

Just a note that browsing the ringtones does not work on Trusty, conceivably because /usr/share/sounds/ubuntu/ringtones does not exist. This defaults to the current directory in this case. Perhaps you need some sort of fall back to show nothing when this directory does not exist. Otherwise the user can select random files in the current directory. Likewise, filtering on ogg and mp3 files might be a good idea.

Consider making the naming on the AlarmLabel.qml consistent. The page title is "Label", but the Label component on top of the text field is "Alarm Label". Consider getting rid of the Label "Alarm Label" since it is redundant information. Similarly, the word "Label" is poor terminology. I know it is what is in the design spec, but it is a poor term for a title or name of an alarm.

In my opinion there should not be a default "label" for a new alarm. The user should simply be required to add a label. No real person makes an alarm and lets it be labeled "Alarm #1".

The new alarm date picker should conform to the user's locale. In my locale I should see 7 AM, 12 PM, etc for 12 hour time.

When selecting multiple dates for an alarm, say Monday and Tuesday, when they are displayed in a comma separated fashion there is no space between them. Instead the days are displayed as "Monday,Tuesday". It'd be best to have a space in between.

There are numerous instances where "anchors" properties can be grouped. Consider doing so.

review: Needs Fixing
31. By Nekhelesh Ramananthan

Ensured strings are translatable

32. By Nekhelesh Ramananthan

Corrected code style for anchor properties

33. By Nekhelesh Ramananthan

reported upstream bug about date picker ignoring time locale of user. Added fixme note for that

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> Consider making the naming on the AlarmLabel.qml consistent. The page title is
> "Label", but the Label component on top of the text field is "Alarm Label".
> Consider getting rid of the Label "Alarm Label" since it is redundant
> information. Similarly, the word "Label" is poor terminology. I know it is
> what is in the design spec, but it is a poor term for a title or name of an
> alarm.
>

I cannot change this without consulting with the with the designers about this. I would like to remove the "Alarm Label" as it is indeed redundant. Will see if I get a reply within 1-2 days. If not we should proceed to take care of this later as the current implementation does follow the design specs.

> In my opinion there should not be a default "label" for a new alarm. The user
> should simply be required to add a label. No real person makes an alarm and
> lets it be labeled "Alarm #1".
>
> The new alarm date picker should conform to the user's locale. In my locale I
> should see 7 AM, 12 PM, etc for 12 hour time.

This is a SDK bug. I have reported the issue and added a FIXME note in rev 33

>
> When selecting multiple dates for an alarm, say Monday and Tuesday, when they
> are displayed in a comma separated fashion there is no space between them.
> Instead the days are displayed as "Monday,Tuesday". It'd be best to have a
> space in between.

I am not sure how to fix this. In the output I have already added a empty string " " but it seems to be ignored. Got any ideas on how to fix this?

577 + else {
578 + return occurs + " "
579 + }

>
> There are numerous instances where "anchors" properties can be grouped.
> Consider doing so.

Fixed in rev 31

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

> Just a note that browsing the ringtones does not work on Trusty, conceivably
> because /usr/share/sounds/ubuntu/ringtones does not exist. This defaults to
> the current directory in this case. Perhaps you need some sort of fall back to
> show nothing when this directory does not exist. Otherwise the user can select
> random files in the current directory. Likewise, filtering on ogg and mp3
> files might be a good idea.

From Ubuntu 14.04 onwards, you need a specific package to get the ubuntu touch ringtones on the desktop. I am unable to remember what that package is. I have it installed on my 14.04 setup and I can browse the ringtones properly. Once we get the packaging fixed, that package will be added as a dependency for the clock app. So this shouldn't be an issue then.

I am not sure how to detect the existance of a folder. The QML FolderListModel http://qt-project.org/doc/qt-5/qml-qt-labs-folderlistmodel-folderlistmodel.html does not provide to check that.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Victor, you will need the package ubuntu-touch-sounds package installed on your system. I will add it to the debian control file once the debian packaging is done.

Revision history for this message
Victor Thompson (vthompson) wrote :

In order to fix the comma issue, I think you just need to do this:

bzr diff
=== modified file 'app/alarm/AlarmUtils.qml'
--- app/alarm/AlarmUtils.qml 2014-06-24 20:15:38 +0000
+++ app/alarm/AlarmUtils.qml 2014-07-07 03:34:57 +0000
@@ -129,6 +129,8 @@
             occurs.push(Qt.locale().standaloneDayName(0, Locale.LongFormat))
         }

+ occurs = occurs.join(', ');
+
         return occurs;
     }
 }

Revision history for this message
Victor Thompson (vthompson) wrote :

Nik, could you address this:

> In my opinion there should not be a default "label" for a new alarm. The user should simply be
> required to add a label. No real person makes an alarm and lets it be labeled "Alarm #1".

Revision history for this message
Victor Thompson (vthompson) wrote :

In terms of reacting to when the ringtones folder doesn't exist, perhaps you could do the following:

bzr diff
=== modified file 'app/alarm/AlarmSound.qml'
--- app/alarm/AlarmSound.qml 2014-06-24 20:15:38 +0000
+++ app/alarm/AlarmSound.qml 2014-07-07 04:02:07 +0000
@@ -31,6 +31,8 @@

     FolderListModel {
         id: _soundModel
+ showDirs: false
+ nameFilters: [ "*.ogg", "*.mp3" ]
         folder: "/usr/share/sounds/ubuntu/ringtones"
     }

This would 1) prevent directories from being shown in the model, and 2) filter the files allowable to just mp3 and ogg. I think you should do #1 because a directory can never be selected. I think it would be a good idea to do #2 as an additional safe guard, but one could argue that it would add extra maintenance work if the ringtones include additional filetypes in the future. As of right now they are all ogg files.

34. By Nekhelesh Ramananthan

Fixed alarm days spacing

35. By Nekhelesh Ramananthan

Ensured directories are never shown in the alarm sounds list. Also filtered the type of files that are shown.

36. By Nekhelesh Ramananthan

Set the default alarm name to Alarm

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> In order to fix the comma issue, I think you just need to do this:
>
> bzr diff
> === modified file 'app/alarm/AlarmUtils.qml'
> --- app/alarm/AlarmUtils.qml 2014-06-24 20:15:38 +0000
> +++ app/alarm/AlarmUtils.qml 2014-07-07 03:34:57 +0000
> @@ -129,6 +129,8 @@
> occurs.push(Qt.locale().standaloneDayName(0, Locale.LongFormat))
> }
>
> + occurs = occurs.join(', ');
> +
> return occurs;
> }
> }

Thnx. That did the trick. Fixed in rev 34

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> In terms of reacting to when the ringtones folder doesn't exist, perhaps you
> could do the following:
>
> bzr diff
> === modified file 'app/alarm/AlarmSound.qml'
> --- app/alarm/AlarmSound.qml 2014-06-24 20:15:38 +0000
> +++ app/alarm/AlarmSound.qml 2014-07-07 04:02:07 +0000
> @@ -31,6 +31,8 @@
>
> FolderListModel {
> id: _soundModel
> + showDirs: false
> + nameFilters: [ "*.ogg", "*.mp3" ]
> folder: "/usr/share/sounds/ubuntu/ringtones"
> }
>

Fixed in rev 35
>
> This would 1) prevent directories from being shown in the model, and 2) filter
> the files allowable to just mp3 and ogg. I think you should do #1 because a
> directory can never be selected. I think it would be a good idea to do #2 as
> an additional safe guard, but one could argue that it would add extra
> maintenance work if the ringtones include additional filetypes in the future.
> As of right now they are all ogg files.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> Nik, could you address this:
>
> > In my opinion there should not be a default "label" for a new alarm. The
> user should simply be
> > required to add a label. No real person makes an alarm and lets it be
> labeled "Alarm #1".

I changed the default "label" for new alarms to just "Alarm" as specified in visual mock up shown to us at Malta https://docs.google.com/presentation/d/1JvDyhsW17d1-Mz8OY1YMBKwfRI2z9qgyRjbujEsxEMk/edit#slide=id.g34303b1ce_2_11.

I compared our solution with iOS and Android and noticed they do it as well.

The reason I don't want to keep it empty is because it increases the amount of steps the user needs to do before saving an alarm. As of now, the user needs to only adjust the time to create the alarm. Every other field has a sensible default value defined.

Revision history for this message
Victor Thompson (vthompson) wrote :

Thanks for the explanation. lgtm now!

review: Approve
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Victor Thanks a lot for taking the time to review :)

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'app/alarm/AlarmLabel.qml'
2--- app/alarm/AlarmLabel.qml 1970-01-01 00:00:00 +0000
3+++ app/alarm/AlarmLabel.qml 2014-07-07 08:40:55 +0000
4@@ -0,0 +1,61 @@
5+/*
6+ * Copyright (C) 2014 Canonical Ltd
7+ *
8+ * This program is free software: you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License version 3 as
10+ * published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+import QtQuick 2.0
22+import Ubuntu.Components 1.1
23+
24+Page {
25+ id: _alarmLabelPage
26+
27+ visible: false
28+ title: i18n.tr("Label")
29+
30+ // Property to set the alarm label in the edit alarm page
31+ property var alarmLabel
32+
33+ Column {
34+ id: _labelColumn
35+
36+ spacing: units.gu(0.5)
37+
38+ anchors {
39+ fill: parent
40+ margins: units.gu(2)
41+ }
42+
43+ Label {
44+ text: i18n.tr("Label")
45+ }
46+
47+ TextField {
48+ id: _labelEntry
49+ text: alarmLabel.subText
50+ width: parent.width
51+ }
52+ }
53+
54+ tools: ToolbarItems {
55+ back: Button {
56+ action: Action {
57+ iconName: "back"
58+ onTriggered: {
59+ alarmLabel.subText = _labelEntry.text
60+ mainStack.pop()
61+ }
62+ }
63+ }
64+ }
65+}
66
67=== modified file 'app/alarm/AlarmList.qml'
68--- app/alarm/AlarmList.qml 2014-06-19 15:31:18 +0000
69+++ app/alarm/AlarmList.qml 2014-07-07 08:40:55 +0000
70@@ -17,89 +17,134 @@
71 import QtQuick 2.0
72 import Ubuntu.Components 1.1
73 import Ubuntu.Components.ListItems 1.0 as ListItem
74+import "../components"
75+import "../components/Utils.js" as Utils
76
77-Column {
78- id: listAlarm
79+Flickable {
80+ id: alarmListFlickable
81+ objectName: "alarmListFlickable"
82
83 // Property to set the model of the saved alarm list
84- property alias model: listSavedAlarm.model
85+ property var model
86+
87+ /*
88+ Property to set the maximum drag distance before freezing the pull to add
89+ button resize
90+ */
91+ property int _maxThreshold: -80
92+
93+ /*
94+ Property to set the minimum drag distance before activating the add
95+ alarm signal
96+ */
97+ property int _minThreshold: _maxThreshold + 10
98+
99+ clip: true
100+ anchors.fill: parent
101+ contentHeight: alarmList.height
102
103 AlarmUtils {
104 id: alarmUtils
105 }
106
107- ListView {
108- id: listSavedAlarm
109- objectName: "listSavedAlarm"
110-
111- clip: true
112- height: parent.height
113- anchors.left: parent.left
114- anchors.right: parent.right
115-
116- currentIndex: -1
117-
118- delegate: ListItem.Base {
119- objectName: "alarm" + index
120-
121- Label {
122- id: alarmTime
123- objectName: "listAlarmTime" + index
124-
125- anchors.verticalCenter: parent.verticalCenter
126- anchors.left: parent.left
127- anchors.leftMargin: units.gu(0)
128-
129- fontSize: "medium"
130- text: Qt.formatTime(date)
131- }
132-
133- Column {
134- id: alarmDetailsColumn
135-
136- anchors {
137- left: alarmTime.right
138- right: alarmStatus.left
139- verticalCenter: parent.verticalCenter
140- margins: units.gu(1)
141- }
142+ PullToAdd {
143+ id: addAlarmButton
144+
145+ anchors {
146+ top: parent.top
147+ topMargin: -labelHeight - units.gu(6)
148+ horizontalCenter: parent.horizontalCenter
149+ }
150+
151+ leftLabel: i18n.tr("Add")
152+ rightLabel: i18n.tr("Alarm")
153+ maxThreshold: alarmListFlickable._maxThreshold
154+ }
155+
156+ Column {
157+ id: alarmList
158+ anchors.fill: parent
159+
160+ Repeater {
161+ model: alarmListFlickable.model
162+ ListItem.Base {
163+
164+ height: units.gu(7)
165
166 Label {
167- id: alarmLabel
168- objectName: "listAlarmLabel" + index
169-
170- text: message
171+ id: alarmTime
172+
173+ anchors {
174+ top: alarmDetailsColumn.top
175+ left: parent.left
176+ leftMargin: units.gu(0)
177+ }
178+
179 fontSize: "medium"
180- elide: Text.ElideRight
181- color: UbuntuColors.midAubergine
182- }
183-
184- Label {
185- id: alarmSubtitle
186- objectName: "listAlarmSubtitle" + index
187-
188- fontSize: "xx-small"
189- text: alarmUtils.format_day_string(daysOfWeek, type)
190- }
191- }
192-
193- Switch {
194- id: alarmStatus
195-
196- anchors.right: parent.right
197- anchors.verticalCenter: parent.verticalCenter
198-
199- enabled: model.enabled
200- }
201-
202- selected: listSavedAlarm.currentIndex == index
203- removable: true
204- confirmRemoval: true
205-
206- onItemRemoved: {
207- var alarm = alarmModel.get(index)
208- alarm.cancel()
209- }
210+ text: Qt.formatTime(date)
211+ }
212+
213+ Column {
214+ id: alarmDetailsColumn
215+
216+ anchors {
217+ left: alarmTime.right
218+ right: alarmStatus.left
219+ verticalCenter: parent.verticalCenter
220+ margins: units.gu(1)
221+ }
222+
223+ Label {
224+ id: alarmLabel
225+
226+ text: message
227+ fontSize: "medium"
228+ elide: Text.ElideRight
229+ color: UbuntuColors.midAubergine
230+ }
231+
232+ Label {
233+ id: alarmSubtitle
234+
235+ fontSize: "xx-small"
236+ width: parent.width
237+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
238+ text: alarmUtils.format_day_string(daysOfWeek)
239+ }
240+ }
241+
242+ Switch {
243+ id: alarmStatus
244+
245+ anchors {
246+ right: parent.right
247+ verticalCenter: parent.verticalCenter
248+ }
249+
250+ checked: enabled
251+ }
252+
253+ removable: true
254+ confirmRemoval: true
255+
256+ onItemRemoved: {
257+ var alarm = alarmModel.get(index)
258+ alarm.cancel()
259+ }
260+ }
261+ }
262+ }
263+
264+ onDragEnded: {
265+ if(contentY < _minThreshold)
266+ mainStack.push(Qt.resolvedUrl("EditAlarmPage.qml"),
267+ {"alarmCount": alarmModel.count})
268+ }
269+
270+ onContentYChanged: {
271+ if(contentY < 0 && atYBeginning) {
272+ addAlarmButton.dragPosition = contentY.toFixed(0)
273 }
274 }
275 }
276+
277
278=== modified file 'app/alarm/AlarmPage.qml'
279--- app/alarm/AlarmPage.qml 2014-06-16 14:09:12 +0000
280+++ app/alarm/AlarmPage.qml 2014-07-07 08:40:55 +0000
281@@ -16,10 +16,20 @@
282
283 import QtQuick 2.0
284 import Ubuntu.Components 1.1
285+import "../components/Utils.js" as Utils
286
287 Page {
288 title: "Alarms"
289
290+ flickable: null
291+
292+ Component.onCompleted: Utils.log(debugMode, "Alarm Page loaded")
293+
294+ AlarmModel {
295+ id: alarmModel
296+ Component.onCompleted: Utils.log(debugMode, "Alarm Database loaded")
297+ }
298+
299 AlarmList{
300 id: listAlarm
301 model: alarmModel
302@@ -39,6 +49,10 @@
303 ToolbarButton {
304 action: Action {
305 iconName: "add"
306+ onTriggered: {
307+ mainStack.push(Qt.resolvedUrl("EditAlarmPage.qml"),
308+ {"alarmCount": alarmModel.count})
309+ }
310 }
311 }
312 }
313
314=== added file 'app/alarm/AlarmRepeat.qml'
315--- app/alarm/AlarmRepeat.qml 1970-01-01 00:00:00 +0000
316+++ app/alarm/AlarmRepeat.qml 2014-07-07 08:40:55 +0000
317@@ -0,0 +1,108 @@
318+/*
319+ * Copyright (C) 2014 Canonical Ltd
320+ *
321+ * This program is free software: you can redistribute it and/or modify
322+ * it under the terms of the GNU General Public License version 3 as
323+ * published by the Free Software Foundation.
324+ *
325+ * This program is distributed in the hope that it will be useful,
326+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
327+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
328+ * GNU General Public License for more details.
329+ *
330+ * You should have received a copy of the GNU General Public License
331+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
332+ */
333+
334+import QtQuick 2.0
335+import Ubuntu.Components 1.1
336+import Ubuntu.Components.ListItems 1.0 as ListItem
337+
338+Page {
339+ id: _alarmRepeatPage
340+
341+ visible: false
342+ title: i18n.tr("Repeat")
343+
344+ // Property to set the alarm days of the week in the edit alarm page
345+ property var alarm
346+
347+ ListModel {
348+ id: daysModel
349+
350+ ListElement {
351+ day: "1"
352+ flag: Alarm.Monday
353+ }
354+
355+ ListElement {
356+ day: "2"
357+ flag: Alarm.Tuesday
358+ }
359+
360+ ListElement {
361+ day: "3"
362+ flag: Alarm.Wednesday
363+ }
364+
365+ ListElement {
366+ day: "4"
367+ flag: Alarm.Thursday
368+ }
369+
370+ ListElement {
371+ day: "5"
372+ flag: Alarm.Friday
373+ }
374+
375+ ListElement {
376+ day: "6"
377+ flag: Alarm.Saturday
378+ }
379+
380+ ListElement {
381+ day: "0"
382+ flag: Alarm.Sunday
383+ }
384+ }
385+
386+ Column {
387+ id: _alarmDayColumn
388+
389+ anchors.fill: parent
390+
391+ Repeater {
392+ id: _alarmDays
393+
394+ model: daysModel
395+
396+ ListItem.Standard {
397+ Label {
398+ id: _alarmDay
399+
400+ anchors {
401+ left: parent.left
402+ leftMargin: units.gu(2)
403+ verticalCenter: parent.verticalCenter
404+ }
405+
406+ color: UbuntuColors.midAubergine
407+ text: Qt.locale().standaloneDayName(day, Locale.LongFormat)
408+ }
409+
410+ control: Switch {
411+ checked: (alarm.daysOfWeek & flag) == flag
412+ onCheckedChanged: {
413+ if (checked) {
414+ alarm.daysOfWeek |= flag
415+ }
416+
417+ else {
418+ alarm.daysOfWeek &= ~flag
419+ }
420+ }
421+ }
422+ }
423+ }
424+ }
425+}
426
427=== added file 'app/alarm/AlarmSound.qml'
428--- app/alarm/AlarmSound.qml 1970-01-01 00:00:00 +0000
429+++ app/alarm/AlarmSound.qml 2014-07-07 08:40:55 +0000
430@@ -0,0 +1,115 @@
431+/*
432+ * Copyright (C) 2014 Canonical Ltd
433+ *
434+ * This program is free software: you can redistribute it and/or modify
435+ * it under the terms of the GNU General Public License version 3 as
436+ * published by the Free Software Foundation.
437+ *
438+ * This program is distributed in the hope that it will be useful,
439+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
440+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
441+ * GNU General Public License for more details.
442+ *
443+ * You should have received a copy of the GNU General Public License
444+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
445+ */
446+
447+import QtQuick 2.0
448+import Ubuntu.Components 1.1
449+import Qt.labs.folderlistmodel 2.1
450+import Ubuntu.Components.ListItems 1.0 as ListItem
451+
452+Page {
453+ id: _alarmSoundPage
454+
455+ title: i18n.tr("Sound")
456+ flickable: _pageFlickable
457+ visible: false
458+
459+ // Property to set the alarm sound in the edit alarm page
460+ property var alarmSound
461+
462+ FolderListModel {
463+ id: _soundModel
464+ showDirs: false
465+ nameFilters: [ "*.ogg", "*.mp3" ]
466+ folder: "/usr/share/sounds/ubuntu/ringtones"
467+ }
468+
469+ Flickable {
470+ id: _pageFlickable
471+
472+ clip: true
473+ anchors.fill: parent
474+ contentHeight: _soundModel.count * units.gu(7)
475+
476+ Column {
477+ id: _alarmSoundColumn
478+
479+ anchors.fill: parent
480+
481+ Repeater {
482+ id: _alarmSounds
483+
484+ model: _soundModel
485+
486+ ListItem.Base {
487+ id: _alarmSoundDelegate
488+
489+ property alias isChecked: _soundStatus.checked
490+
491+ height: units.gu(7)
492+
493+ Label {
494+ id: _soundName
495+
496+ anchors {
497+ left: parent.left
498+ verticalCenter: parent.verticalCenter
499+ }
500+
501+ color: UbuntuColors.midAubergine
502+ fontSize: "medium"
503+ text: fileBaseName
504+ }
505+
506+ CheckBox {
507+ id: _soundStatus
508+
509+ anchors {
510+ right: parent.right
511+ verticalCenter: parent.verticalCenter
512+ }
513+
514+ checked: alarmSound.subText === _soundName.text ? true :
515+ false
516+ onClicked: {
517+ if (checked) {
518+ alarmSound.subText = _soundName.text
519+
520+ // Ensures only one alarm sound is selected
521+ for(var i=0; i<_soundModel.count; i++) {
522+ if(_alarmSounds.itemAt(i).isChecked &&
523+ i !== index) {
524+ _alarmSounds.itemAt(i).isChecked = false
525+ }
526+ }
527+ }
528+ }
529+ }
530+ }
531+ }
532+ }
533+ }
534+
535+ tools: ToolbarItems {
536+ back: Button {
537+ action: Action {
538+ iconName: "back"
539+ onTriggered: {
540+ mainStack.pop()
541+ }
542+ }
543+ }
544+ }
545+}
546
547=== modified file 'app/alarm/AlarmUtils.qml'
548--- app/alarm/AlarmUtils.qml 2014-06-19 15:31:18 +0000
549+++ app/alarm/AlarmUtils.qml 2014-07-07 08:40:55 +0000
550@@ -17,61 +17,120 @@
551 import QtQuick 2.0
552 import Ubuntu.Components 1.1
553
554+/*
555+ Qt Object containing a collection of useful alarm functions
556+*/
557 QtObject {
558 id: alarmUtils
559
560- function format_day_string(value, type) {
561- var occurs = get_day(value, type);
562- var WeekDay = 0;
563+ // Function to format the alarm days accordingly to their occurance
564+ function format_day_string(value) {
565+ var occurs = _get_day(value)
566+
567+ if (value === _get_weekdays()) {
568+ return i18n.tr("Weekdays")
569+ }
570+
571+ else if (value === _get_weekends()) {
572+ return i18n.tr("Weekends")
573+ }
574+
575+ else if (value === Alarm.Daily) {
576+ return i18n.tr("Daily")
577+ }
578+
579+ else {
580+ return occurs
581+ }
582+ }
583+
584+ /*
585+ INTERNAL FUNCTIONS
586+ */
587+
588+ // Function to determine the locale's weekdays value
589+ function _get_weekdays() {
590+ var weekDays = 0
591 for (var i = 0; i < Qt.locale().weekDays.length; ++i) {
592 switch (Qt.locale().weekDays[i]) {
593- case Qt.Monday:
594- WeekDay |= Alarm.Monday
595- break;
596- case Qt.Tuesday:
597- WeekDay |= Alarm.Tuesday
598- break;
599- case Qt.Wednesday:
600- WeekDay |= Alarm.Wednesday
601- break;
602- case Qt.Thursday:
603- WeekDay |= Alarm.Thursday
604- break;
605- case Qt.Friday:
606- WeekDay |= Alarm.Friday
607- break;
608- case Qt.Saturday:
609- WeekDay |= Alarm.Saturday
610- break;
611- case Qt.Sunday:
612- WeekDay |= Alarm.Sunday
613- break;
614- }
615- }
616-
617- if (value == WeekDay) {
618- return i18n.tr("Every weekday")
619- }
620- else if (value == Alarm.Daily) {
621- return i18n.tr("Daily")
622- }
623- else {
624- if (type === Alarm.Repeating)
625- return i18n.tr("Every ") + occurs
626- else
627- return i18n.tr("Once on ") + occurs
628- }
629- }
630-
631- function get_day(value, type) {
632- var occurs = [];
633- if (value & Alarm.Monday) occurs.push(Qt.locale().standaloneDayName(1, Locale.ShortFormat));
634- if (value & Alarm.Tuesday) occurs.push(Qt.locale().standaloneDayName(2, Locale.ShortFormat));
635- if (value & Alarm.Wednesday) occurs.push(Qt.locale().standaloneDayName(3, Locale.ShortFormat));
636- if (value & Alarm.Thursday) occurs.push(Qt.locale().standaloneDayName(4, Locale.ShortFormat));
637- if (value & Alarm.Friday) occurs.push(Qt.locale().standaloneDayName(5, Locale.ShortFormat));
638- if (value & Alarm.Saturday) occurs.push(Qt.locale().standaloneDayName(6, Locale.ShortFormat));
639- if (value & Alarm.Sunday) occurs.push(Qt.locale().standaloneDayName(7, Locale.ShortFormat));
640+ case Qt.Monday: {
641+ weekDays |= Alarm.Monday
642+ break
643+ }
644+
645+ case Qt.Tuesday: {
646+ weekDays |= Alarm.Tuesday
647+ break
648+ }
649+
650+ case Qt.Wednesday: {
651+ weekDays |= Alarm.Wednesday
652+ break
653+ }
654+
655+ case Qt.Thursday: {
656+ weekDays |= Alarm.Thursday
657+ break
658+ }
659+
660+ case Qt.Friday: {
661+ weekDays |= Alarm.Friday
662+ break
663+ }
664+
665+ case Qt.Saturday: {
666+ weekDays |= Alarm.Saturday
667+ break
668+ }
669+
670+ case Qt.Sunday: {
671+ weekDays |= Alarm.Sunday
672+ break
673+ }
674+ }
675+ }
676+ return weekDays
677+ }
678+
679+ // Function to determine the locale's weekends value
680+ function _get_weekends() {
681+ return (Alarm.Daily - _get_weekdays())
682+ }
683+
684+ // Function to retrieve the days of the week in the locale system
685+ function _get_day(value) {
686+ var occurs = []
687+
688+ if (value & Alarm.Monday) {
689+ occurs.push(Qt.locale().standaloneDayName(1, Locale.LongFormat))
690+ }
691+
692+ if (value & Alarm.Tuesday) {
693+ occurs.push(Qt.locale().standaloneDayName(2, Locale.LongFormat))
694+ }
695+
696+ if (value & Alarm.Wednesday) {
697+ occurs.push(Qt.locale().standaloneDayName(3, Locale.LongFormat))
698+ }
699+
700+ if (value & Alarm.Thursday) {
701+ occurs.push(Qt.locale().standaloneDayName(4, Locale.LongFormat))
702+ }
703+
704+ if (value & Alarm.Friday) {
705+ occurs.push(Qt.locale().standaloneDayName(5, Locale.LongFormat))
706+ }
707+
708+ if (value & Alarm.Saturday) {
709+ occurs.push(Qt.locale().standaloneDayName(6, Locale.LongFormat))
710+ }
711+
712+ if (value & Alarm.Sunday) {
713+ occurs.push(Qt.locale().standaloneDayName(0, Locale.LongFormat))
714+ }
715+
716+ occurs = occurs.join(', ');
717+
718 return occurs;
719 }
720 }
721
722=== added file 'app/alarm/EditAlarmPage.qml'
723--- app/alarm/EditAlarmPage.qml 1970-01-01 00:00:00 +0000
724+++ app/alarm/EditAlarmPage.qml 2014-07-07 08:40:55 +0000
725@@ -0,0 +1,131 @@
726+/*
727+ * Copyright (C) 2014 Canonical Ltd
728+ *
729+ * This program is free software: you can redistribute it and/or modify
730+ * it under the terms of the GNU General Public License version 3 as
731+ * published by the Free Software Foundation.
732+ *
733+ * This program is distributed in the hope that it will be useful,
734+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
735+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
736+ * GNU General Public License for more details.
737+ *
738+ * You should have received a copy of the GNU General Public License
739+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
740+ */
741+
742+import QtQuick 2.0
743+import Ubuntu.Components 1.1
744+import Ubuntu.Components.Pickers 1.0
745+import Ubuntu.Components.ListItems 1.0 as ListItem
746+import "../components"
747+import "../components/Utils.js" as Utils
748+
749+Page {
750+ id: _addAlarmPage
751+
752+ title: i18n.tr("New Alarm")
753+ visible: false
754+
755+ // Function to save a new alarm
756+ function saveNewAlarm() {
757+ var alarmTime = new Date()
758+ alarmTime.setHours(_timePicker.hours, _timePicker.minutes, 0)
759+
760+ _alarm.message = _alarmLabel.subText
761+ _alarm.date = alarmTime
762+ _alarm.type = Alarm.Repeating
763+ _alarm.enabled = true
764+ _alarm.save()
765+ }
766+
767+ Alarm {
768+ id: _alarm
769+ onStatusChanged: {
770+ if (status !== Alarm.Ready)
771+ return;
772+ if ((operation > Alarm.NoOperation) &&
773+ (operation < Alarm.Reseting)) {
774+ mainStack.pop();
775+ }
776+ }
777+ }
778+
779+ AlarmUtils {
780+ id: alarmUtils
781+ }
782+
783+ Column {
784+ id: _alarmColumn
785+
786+ anchors.fill: parent
787+
788+ DatePicker {
789+ id: _timePicker
790+
791+ /*
792+ #FIXME: DatePicker does not respect the user's locale. The bug
793+ has been reported at http://pad.lv/1338138
794+ */
795+
796+ anchors {
797+ left: parent.left
798+ right: parent.right
799+ margins: units.gu(-2)
800+ }
801+
802+ clip: true
803+ mode: "Hours|Minutes"
804+ }
805+
806+ SubtitledListItem {
807+ id: _alarmRepeat
808+
809+ text: i18n.tr("Repeat")
810+ subText: alarmUtils.format_day_string(_alarm.daysOfWeek)
811+ onClicked: mainStack.push(Qt.resolvedUrl("AlarmRepeat.qml"),
812+ {"alarm": _alarm})
813+ }
814+
815+ SubtitledListItem {
816+ id: _alarmLabel
817+
818+ text: i18n.tr("Label")
819+ subText: i18n.tr("Alarm")
820+ onClicked: mainStack.push(Qt.resolvedUrl("AlarmLabel.qml"),
821+ {"alarmLabel": _alarmLabel})
822+ }
823+
824+ SubtitledListItem {
825+ id: _alarmSound
826+ /*
827+ #TODO: Add support for choosing new alarm sound when indicator-
828+ datetime supports custom alarm sounds
829+ */
830+ text: i18n.tr("Sound (disabled)")
831+ subText: "Suru arpeggio"
832+ onClicked: mainStack.push(Qt.resolvedUrl("AlarmSound.qml"),
833+ {"alarmSound": _alarmSound})
834+ }
835+ }
836+
837+ tools: ToolbarItems {
838+ back: Button {
839+ action: Action {
840+ iconName: "close"
841+ onTriggered: {
842+ mainStack.pop()
843+ }
844+ }
845+ }
846+
847+ ToolbarButton {
848+ action: Action {
849+ iconName: "save"
850+ onTriggered: {
851+ saveNewAlarm()
852+ }
853+ }
854+ }
855+ }
856+}
857
858=== modified file 'app/clock/ClockPage.qml'
859--- app/clock/ClockPage.qml 2014-06-21 16:42:08 +0000
860+++ app/clock/ClockPage.qml 2014-07-07 08:40:55 +0000
861@@ -49,12 +49,16 @@
862 contentWidth: parent.width
863 contentHeight: clock.height + date.height + locationRow.height
864
865- AddCityButton {
866+ PullToAdd {
867 id: addCityButton
868+
869 anchors.top: parent.top
870 anchors.topMargin: -labelHeight - units.gu(6)
871 anchors.horizontalCenter: parent.horizontalCenter
872- maxThreshold: _maxThreshold
873+
874+ leftLabel: i18n.tr("Add")
875+ rightLabel: i18n.tr("City")
876+ maxThreshold: clockPage._maxThreshold
877 }
878
879 Clock {
880
881=== added file 'app/components/PullToAdd.qml'
882--- app/components/PullToAdd.qml 1970-01-01 00:00:00 +0000
883+++ app/components/PullToAdd.qml 2014-07-07 08:40:55 +0000
884@@ -0,0 +1,77 @@
885+/*
886+ * Copyright (C) 2014 Canonical Ltd
887+ *
888+ * This program is free software: you can redistribute it and/or modify
889+ * it under the terms of the GNU General Public License version 3 as
890+ * published by the Free Software Foundation.
891+ *
892+ * This program is distributed in the hope that it will be useful,
893+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
894+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
895+ * GNU General Public License for more details.
896+ *
897+ * You should have received a copy of the GNU General Public License
898+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
899+ */
900+
901+import QtQuick 2.0
902+import Ubuntu.Components 1.1
903+
904+Row {
905+ id: _pullToAdd
906+
907+ // Property to get the position of the button from the top
908+ property int dragPosition: 0
909+
910+ // Property to store the height of the label
911+ property alias labelHeight: _leftLabel.height
912+
913+ // Property to set the label on the left side of the add button
914+ property alias leftLabel: _leftLabel.text
915+
916+ // Property to set the label on the right side of the add button
917+ property alias rightLabel: _rightLabel.text
918+
919+ // Property to set the maximum threshold beyond which the button shouldn't resize
920+ property int maxThreshold
921+
922+ spacing: units.gu(1)
923+
924+ Label {
925+ id: _leftLabel
926+
927+ text: "pull"
928+ fontSize: "medium"
929+ color: UbuntuColors.midAubergine
930+ anchors.verticalCenter: parent.verticalCenter
931+ }
932+
933+ ClockCircle {
934+ id: _addButton
935+
936+ isOuter: true
937+ width: dragPosition >= maxThreshold ? dragPosition * units.gu(6.5)/maxThreshold : units.gu(6.5)
938+
939+ ClockCircle {
940+ width: dragPosition >= maxThreshold ? dragPosition * units.gu(4.5)/maxThreshold : units.gu(4.5)
941+ anchors.centerIn: parent
942+
943+ Label {
944+ id: plusLabel
945+
946+ anchors.centerIn: parent
947+ font.pixelSize: dragPosition >= maxThreshold ? dragPosition * units.dp(30)/maxThreshold : units.dp(30)
948+ text: "+"
949+ }
950+ }
951+ }
952+
953+ Label {
954+ id: _rightLabel
955+
956+ text: "down"
957+ fontSize: "medium"
958+ color: UbuntuColors.midAubergine
959+ anchors.verticalCenter: parent.verticalCenter
960+ }
961+}
962
963=== added file 'app/components/SubtitledListItem.qml'
964--- app/components/SubtitledListItem.qml 1970-01-01 00:00:00 +0000
965+++ app/components/SubtitledListItem.qml 2014-07-07 08:40:55 +0000
966@@ -0,0 +1,55 @@
967+/*
968+ * Copyright (C) 2014 Canonical Ltd
969+ *
970+ * This program is free software: you can redistribute it and/or modify
971+ * it under the terms of the GNU General Public License version 3 as
972+ * published by the Free Software Foundation.
973+ *
974+ * This program is distributed in the hope that it will be useful,
975+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
976+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
977+ * GNU General Public License for more details.
978+ *
979+ * You should have received a copy of the GNU General Public License
980+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
981+ */
982+
983+import QtQuick 2.0
984+import Ubuntu.Components 1.1
985+import Ubuntu.Components.ListItems 1.0 as ListItem
986+
987+/*
988+ This component is almost an identical copy of the SDK's subtitled with the
989+ exception of the font size and color required by the new clock app design.
990+
991+ #TODO: Revert to using the SDK Subtitled Component when they change the
992+ design to match the new clock app design.
993+ */
994+ListItem.Base {
995+ id: _subtitledContainer
996+
997+ // Property to set the main text label
998+ property alias text: _mainText.text
999+
1000+ // Property to set the subtitle label
1001+ property alias subText: _subText.text
1002+
1003+ height: units.gu(7)
1004+
1005+ Column {
1006+ id: _labelColumn
1007+
1008+ anchors.verticalCenter: parent.verticalCenter
1009+
1010+ Label {
1011+ id: _mainText
1012+ fontSize: "medium"
1013+ color: UbuntuColors.midAubergine
1014+ }
1015+
1016+ Label {
1017+ id: _subText
1018+ fontSize: "xx-small"
1019+ }
1020+ }
1021+}
1022
1023=== modified file 'app/ubuntu-clock-app.qml'
1024--- app/ubuntu-clock-app.qml 2014-06-17 18:06:24 +0000
1025+++ app/ubuntu-clock-app.qml 2014-07-07 08:40:55 +0000
1026@@ -74,11 +74,6 @@
1027 onTriggered: clockPage.updateTime()
1028 }
1029
1030- AlarmModel {
1031- id: alarmModel
1032- Component.onCompleted: Utils.log(debugMode, "Alarm Database loaded")
1033- }
1034-
1035 PageStack {
1036 id: mainStack
1037

Subscribers

People subscribed via source and target branches