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
=== added file 'app/alarm/AlarmLabel.qml'
--- app/alarm/AlarmLabel.qml 1970-01-01 00:00:00 +0000
+++ app/alarm/AlarmLabel.qml 2014-07-07 08:40:55 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19
20Page {
21 id: _alarmLabelPage
22
23 visible: false
24 title: i18n.tr("Label")
25
26 // Property to set the alarm label in the edit alarm page
27 property var alarmLabel
28
29 Column {
30 id: _labelColumn
31
32 spacing: units.gu(0.5)
33
34 anchors {
35 fill: parent
36 margins: units.gu(2)
37 }
38
39 Label {
40 text: i18n.tr("Label")
41 }
42
43 TextField {
44 id: _labelEntry
45 text: alarmLabel.subText
46 width: parent.width
47 }
48 }
49
50 tools: ToolbarItems {
51 back: Button {
52 action: Action {
53 iconName: "back"
54 onTriggered: {
55 alarmLabel.subText = _labelEntry.text
56 mainStack.pop()
57 }
58 }
59 }
60 }
61}
062
=== modified file 'app/alarm/AlarmList.qml'
--- app/alarm/AlarmList.qml 2014-06-19 15:31:18 +0000
+++ app/alarm/AlarmList.qml 2014-07-07 08:40:55 +0000
@@ -17,89 +17,134 @@
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 1.118import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0 as ListItem19import Ubuntu.Components.ListItems 1.0 as ListItem
20import "../components"
21import "../components/Utils.js" as Utils
2022
21Column {23Flickable {
22 id: listAlarm24 id: alarmListFlickable
25 objectName: "alarmListFlickable"
2326
24 // Property to set the model of the saved alarm list27 // Property to set the model of the saved alarm list
25 property alias model: listSavedAlarm.model28 property var model
29
30 /*
31 Property to set the maximum drag distance before freezing the pull to add
32 button resize
33 */
34 property int _maxThreshold: -80
35
36 /*
37 Property to set the minimum drag distance before activating the add
38 alarm signal
39 */
40 property int _minThreshold: _maxThreshold + 10
41
42 clip: true
43 anchors.fill: parent
44 contentHeight: alarmList.height
2645
27 AlarmUtils {46 AlarmUtils {
28 id: alarmUtils47 id: alarmUtils
29 }48 }
3049
31 ListView {50 PullToAdd {
32 id: listSavedAlarm51 id: addAlarmButton
33 objectName: "listSavedAlarm"52
3453 anchors {
35 clip: true54 top: parent.top
36 height: parent.height55 topMargin: -labelHeight - units.gu(6)
37 anchors.left: parent.left56 horizontalCenter: parent.horizontalCenter
38 anchors.right: parent.right57 }
3958
40 currentIndex: -159 leftLabel: i18n.tr("Add")
4160 rightLabel: i18n.tr("Alarm")
42 delegate: ListItem.Base {61 maxThreshold: alarmListFlickable._maxThreshold
43 objectName: "alarm" + index62 }
4463
45 Label {64 Column {
46 id: alarmTime65 id: alarmList
47 objectName: "listAlarmTime" + index66 anchors.fill: parent
4867
49 anchors.verticalCenter: parent.verticalCenter68 Repeater {
50 anchors.left: parent.left69 model: alarmListFlickable.model
51 anchors.leftMargin: units.gu(0)70 ListItem.Base {
5271
53 fontSize: "medium"72 height: units.gu(7)
54 text: Qt.formatTime(date)
55 }
56
57 Column {
58 id: alarmDetailsColumn
59
60 anchors {
61 left: alarmTime.right
62 right: alarmStatus.left
63 verticalCenter: parent.verticalCenter
64 margins: units.gu(1)
65 }
6673
67 Label {74 Label {
68 id: alarmLabel75 id: alarmTime
69 objectName: "listAlarmLabel" + index76
7077 anchors {
71 text: message78 top: alarmDetailsColumn.top
79 left: parent.left
80 leftMargin: units.gu(0)
81 }
82
72 fontSize: "medium"83 fontSize: "medium"
73 elide: Text.ElideRight84 text: Qt.formatTime(date)
74 color: UbuntuColors.midAubergine85 }
75 }86
7687 Column {
77 Label {88 id: alarmDetailsColumn
78 id: alarmSubtitle89
79 objectName: "listAlarmSubtitle" + index90 anchors {
8091 left: alarmTime.right
81 fontSize: "xx-small"92 right: alarmStatus.left
82 text: alarmUtils.format_day_string(daysOfWeek, type)93 verticalCenter: parent.verticalCenter
83 }94 margins: units.gu(1)
84 }95 }
8596
86 Switch {97 Label {
87 id: alarmStatus98 id: alarmLabel
8899
89 anchors.right: parent.right100 text: message
90 anchors.verticalCenter: parent.verticalCenter101 fontSize: "medium"
91102 elide: Text.ElideRight
92 enabled: model.enabled103 color: UbuntuColors.midAubergine
93 }104 }
94105
95 selected: listSavedAlarm.currentIndex == index106 Label {
96 removable: true107 id: alarmSubtitle
97 confirmRemoval: true108
98109 fontSize: "xx-small"
99 onItemRemoved: {110 width: parent.width
100 var alarm = alarmModel.get(index)111 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
101 alarm.cancel()112 text: alarmUtils.format_day_string(daysOfWeek)
102 }113 }
114 }
115
116 Switch {
117 id: alarmStatus
118
119 anchors {
120 right: parent.right
121 verticalCenter: parent.verticalCenter
122 }
123
124 checked: enabled
125 }
126
127 removable: true
128 confirmRemoval: true
129
130 onItemRemoved: {
131 var alarm = alarmModel.get(index)
132 alarm.cancel()
133 }
134 }
135 }
136 }
137
138 onDragEnded: {
139 if(contentY < _minThreshold)
140 mainStack.push(Qt.resolvedUrl("EditAlarmPage.qml"),
141 {"alarmCount": alarmModel.count})
142 }
143
144 onContentYChanged: {
145 if(contentY < 0 && atYBeginning) {
146 addAlarmButton.dragPosition = contentY.toFixed(0)
103 }147 }
104 }148 }
105}149}
150
106151
=== modified file 'app/alarm/AlarmPage.qml'
--- app/alarm/AlarmPage.qml 2014-06-16 14:09:12 +0000
+++ app/alarm/AlarmPage.qml 2014-07-07 08:40:55 +0000
@@ -16,10 +16,20 @@
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 1.118import Ubuntu.Components 1.1
19import "../components/Utils.js" as Utils
1920
20Page {21Page {
21 title: "Alarms"22 title: "Alarms"
2223
24 flickable: null
25
26 Component.onCompleted: Utils.log(debugMode, "Alarm Page loaded")
27
28 AlarmModel {
29 id: alarmModel
30 Component.onCompleted: Utils.log(debugMode, "Alarm Database loaded")
31 }
32
23 AlarmList{33 AlarmList{
24 id: listAlarm34 id: listAlarm
25 model: alarmModel35 model: alarmModel
@@ -39,6 +49,10 @@
39 ToolbarButton {49 ToolbarButton {
40 action: Action {50 action: Action {
41 iconName: "add"51 iconName: "add"
52 onTriggered: {
53 mainStack.push(Qt.resolvedUrl("EditAlarmPage.qml"),
54 {"alarmCount": alarmModel.count})
55 }
42 }56 }
43 }57 }
44 }58 }
4559
=== added file 'app/alarm/AlarmRepeat.qml'
--- app/alarm/AlarmRepeat.qml 1970-01-01 00:00:00 +0000
+++ app/alarm/AlarmRepeat.qml 2014-07-07 08:40:55 +0000
@@ -0,0 +1,108 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0 as ListItem
20
21Page {
22 id: _alarmRepeatPage
23
24 visible: false
25 title: i18n.tr("Repeat")
26
27 // Property to set the alarm days of the week in the edit alarm page
28 property var alarm
29
30 ListModel {
31 id: daysModel
32
33 ListElement {
34 day: "1"
35 flag: Alarm.Monday
36 }
37
38 ListElement {
39 day: "2"
40 flag: Alarm.Tuesday
41 }
42
43 ListElement {
44 day: "3"
45 flag: Alarm.Wednesday
46 }
47
48 ListElement {
49 day: "4"
50 flag: Alarm.Thursday
51 }
52
53 ListElement {
54 day: "5"
55 flag: Alarm.Friday
56 }
57
58 ListElement {
59 day: "6"
60 flag: Alarm.Saturday
61 }
62
63 ListElement {
64 day: "0"
65 flag: Alarm.Sunday
66 }
67 }
68
69 Column {
70 id: _alarmDayColumn
71
72 anchors.fill: parent
73
74 Repeater {
75 id: _alarmDays
76
77 model: daysModel
78
79 ListItem.Standard {
80 Label {
81 id: _alarmDay
82
83 anchors {
84 left: parent.left
85 leftMargin: units.gu(2)
86 verticalCenter: parent.verticalCenter
87 }
88
89 color: UbuntuColors.midAubergine
90 text: Qt.locale().standaloneDayName(day, Locale.LongFormat)
91 }
92
93 control: Switch {
94 checked: (alarm.daysOfWeek & flag) == flag
95 onCheckedChanged: {
96 if (checked) {
97 alarm.daysOfWeek |= flag
98 }
99
100 else {
101 alarm.daysOfWeek &= ~flag
102 }
103 }
104 }
105 }
106 }
107 }
108}
0109
=== added file 'app/alarm/AlarmSound.qml'
--- app/alarm/AlarmSound.qml 1970-01-01 00:00:00 +0000
+++ app/alarm/AlarmSound.qml 2014-07-07 08:40:55 +0000
@@ -0,0 +1,115 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import Qt.labs.folderlistmodel 2.1
20import Ubuntu.Components.ListItems 1.0 as ListItem
21
22Page {
23 id: _alarmSoundPage
24
25 title: i18n.tr("Sound")
26 flickable: _pageFlickable
27 visible: false
28
29 // Property to set the alarm sound in the edit alarm page
30 property var alarmSound
31
32 FolderListModel {
33 id: _soundModel
34 showDirs: false
35 nameFilters: [ "*.ogg", "*.mp3" ]
36 folder: "/usr/share/sounds/ubuntu/ringtones"
37 }
38
39 Flickable {
40 id: _pageFlickable
41
42 clip: true
43 anchors.fill: parent
44 contentHeight: _soundModel.count * units.gu(7)
45
46 Column {
47 id: _alarmSoundColumn
48
49 anchors.fill: parent
50
51 Repeater {
52 id: _alarmSounds
53
54 model: _soundModel
55
56 ListItem.Base {
57 id: _alarmSoundDelegate
58
59 property alias isChecked: _soundStatus.checked
60
61 height: units.gu(7)
62
63 Label {
64 id: _soundName
65
66 anchors {
67 left: parent.left
68 verticalCenter: parent.verticalCenter
69 }
70
71 color: UbuntuColors.midAubergine
72 fontSize: "medium"
73 text: fileBaseName
74 }
75
76 CheckBox {
77 id: _soundStatus
78
79 anchors {
80 right: parent.right
81 verticalCenter: parent.verticalCenter
82 }
83
84 checked: alarmSound.subText === _soundName.text ? true :
85 false
86 onClicked: {
87 if (checked) {
88 alarmSound.subText = _soundName.text
89
90 // Ensures only one alarm sound is selected
91 for(var i=0; i<_soundModel.count; i++) {
92 if(_alarmSounds.itemAt(i).isChecked &&
93 i !== index) {
94 _alarmSounds.itemAt(i).isChecked = false
95 }
96 }
97 }
98 }
99 }
100 }
101 }
102 }
103 }
104
105 tools: ToolbarItems {
106 back: Button {
107 action: Action {
108 iconName: "back"
109 onTriggered: {
110 mainStack.pop()
111 }
112 }
113 }
114 }
115}
0116
=== modified file 'app/alarm/AlarmUtils.qml'
--- app/alarm/AlarmUtils.qml 2014-06-19 15:31:18 +0000
+++ app/alarm/AlarmUtils.qml 2014-07-07 08:40:55 +0000
@@ -17,61 +17,120 @@
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 1.118import Ubuntu.Components 1.1
1919
20/*
21 Qt Object containing a collection of useful alarm functions
22*/
20QtObject {23QtObject {
21 id: alarmUtils24 id: alarmUtils
2225
23 function format_day_string(value, type) {26 // Function to format the alarm days accordingly to their occurance
24 var occurs = get_day(value, type);27 function format_day_string(value) {
25 var WeekDay = 0;28 var occurs = _get_day(value)
29
30 if (value === _get_weekdays()) {
31 return i18n.tr("Weekdays")
32 }
33
34 else if (value === _get_weekends()) {
35 return i18n.tr("Weekends")
36 }
37
38 else if (value === Alarm.Daily) {
39 return i18n.tr("Daily")
40 }
41
42 else {
43 return occurs
44 }
45 }
46
47 /*
48 INTERNAL FUNCTIONS
49 */
50
51 // Function to determine the locale's weekdays value
52 function _get_weekdays() {
53 var weekDays = 0
26 for (var i = 0; i < Qt.locale().weekDays.length; ++i) {54 for (var i = 0; i < Qt.locale().weekDays.length; ++i) {
27 switch (Qt.locale().weekDays[i]) {55 switch (Qt.locale().weekDays[i]) {
28 case Qt.Monday:56 case Qt.Monday: {
29 WeekDay |= Alarm.Monday57 weekDays |= Alarm.Monday
30 break;58 break
31 case Qt.Tuesday:59 }
32 WeekDay |= Alarm.Tuesday60
33 break;61 case Qt.Tuesday: {
34 case Qt.Wednesday:62 weekDays |= Alarm.Tuesday
35 WeekDay |= Alarm.Wednesday63 break
36 break;64 }
37 case Qt.Thursday:65
38 WeekDay |= Alarm.Thursday66 case Qt.Wednesday: {
39 break;67 weekDays |= Alarm.Wednesday
40 case Qt.Friday:68 break
41 WeekDay |= Alarm.Friday69 }
42 break;70
43 case Qt.Saturday:71 case Qt.Thursday: {
44 WeekDay |= Alarm.Saturday72 weekDays |= Alarm.Thursday
45 break;73 break
46 case Qt.Sunday:74 }
47 WeekDay |= Alarm.Sunday75
48 break;76 case Qt.Friday: {
49 }77 weekDays |= Alarm.Friday
50 }78 break
5179 }
52 if (value == WeekDay) {80
53 return i18n.tr("Every weekday")81 case Qt.Saturday: {
54 }82 weekDays |= Alarm.Saturday
55 else if (value == Alarm.Daily) {83 break
56 return i18n.tr("Daily")84 }
57 }85
58 else {86 case Qt.Sunday: {
59 if (type === Alarm.Repeating)87 weekDays |= Alarm.Sunday
60 return i18n.tr("Every ") + occurs88 break
61 else89 }
62 return i18n.tr("Once on ") + occurs90 }
63 }91 }
64 }92 return weekDays
6593 }
66 function get_day(value, type) {94
67 var occurs = [];95 // Function to determine the locale's weekends value
68 if (value & Alarm.Monday) occurs.push(Qt.locale().standaloneDayName(1, Locale.ShortFormat));96 function _get_weekends() {
69 if (value & Alarm.Tuesday) occurs.push(Qt.locale().standaloneDayName(2, Locale.ShortFormat));97 return (Alarm.Daily - _get_weekdays())
70 if (value & Alarm.Wednesday) occurs.push(Qt.locale().standaloneDayName(3, Locale.ShortFormat));98 }
71 if (value & Alarm.Thursday) occurs.push(Qt.locale().standaloneDayName(4, Locale.ShortFormat));99
72 if (value & Alarm.Friday) occurs.push(Qt.locale().standaloneDayName(5, Locale.ShortFormat));100 // Function to retrieve the days of the week in the locale system
73 if (value & Alarm.Saturday) occurs.push(Qt.locale().standaloneDayName(6, Locale.ShortFormat));101 function _get_day(value) {
74 if (value & Alarm.Sunday) occurs.push(Qt.locale().standaloneDayName(7, Locale.ShortFormat));102 var occurs = []
103
104 if (value & Alarm.Monday) {
105 occurs.push(Qt.locale().standaloneDayName(1, Locale.LongFormat))
106 }
107
108 if (value & Alarm.Tuesday) {
109 occurs.push(Qt.locale().standaloneDayName(2, Locale.LongFormat))
110 }
111
112 if (value & Alarm.Wednesday) {
113 occurs.push(Qt.locale().standaloneDayName(3, Locale.LongFormat))
114 }
115
116 if (value & Alarm.Thursday) {
117 occurs.push(Qt.locale().standaloneDayName(4, Locale.LongFormat))
118 }
119
120 if (value & Alarm.Friday) {
121 occurs.push(Qt.locale().standaloneDayName(5, Locale.LongFormat))
122 }
123
124 if (value & Alarm.Saturday) {
125 occurs.push(Qt.locale().standaloneDayName(6, Locale.LongFormat))
126 }
127
128 if (value & Alarm.Sunday) {
129 occurs.push(Qt.locale().standaloneDayName(0, Locale.LongFormat))
130 }
131
132 occurs = occurs.join(', ');
133
75 return occurs;134 return occurs;
76 }135 }
77}136}
78137
=== added file 'app/alarm/EditAlarmPage.qml'
--- app/alarm/EditAlarmPage.qml 1970-01-01 00:00:00 +0000
+++ app/alarm/EditAlarmPage.qml 2014-07-07 08:40:55 +0000
@@ -0,0 +1,131 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import Ubuntu.Components.Pickers 1.0
20import Ubuntu.Components.ListItems 1.0 as ListItem
21import "../components"
22import "../components/Utils.js" as Utils
23
24Page {
25 id: _addAlarmPage
26
27 title: i18n.tr("New Alarm")
28 visible: false
29
30 // Function to save a new alarm
31 function saveNewAlarm() {
32 var alarmTime = new Date()
33 alarmTime.setHours(_timePicker.hours, _timePicker.minutes, 0)
34
35 _alarm.message = _alarmLabel.subText
36 _alarm.date = alarmTime
37 _alarm.type = Alarm.Repeating
38 _alarm.enabled = true
39 _alarm.save()
40 }
41
42 Alarm {
43 id: _alarm
44 onStatusChanged: {
45 if (status !== Alarm.Ready)
46 return;
47 if ((operation > Alarm.NoOperation) &&
48 (operation < Alarm.Reseting)) {
49 mainStack.pop();
50 }
51 }
52 }
53
54 AlarmUtils {
55 id: alarmUtils
56 }
57
58 Column {
59 id: _alarmColumn
60
61 anchors.fill: parent
62
63 DatePicker {
64 id: _timePicker
65
66 /*
67 #FIXME: DatePicker does not respect the user's locale. The bug
68 has been reported at http://pad.lv/1338138
69 */
70
71 anchors {
72 left: parent.left
73 right: parent.right
74 margins: units.gu(-2)
75 }
76
77 clip: true
78 mode: "Hours|Minutes"
79 }
80
81 SubtitledListItem {
82 id: _alarmRepeat
83
84 text: i18n.tr("Repeat")
85 subText: alarmUtils.format_day_string(_alarm.daysOfWeek)
86 onClicked: mainStack.push(Qt.resolvedUrl("AlarmRepeat.qml"),
87 {"alarm": _alarm})
88 }
89
90 SubtitledListItem {
91 id: _alarmLabel
92
93 text: i18n.tr("Label")
94 subText: i18n.tr("Alarm")
95 onClicked: mainStack.push(Qt.resolvedUrl("AlarmLabel.qml"),
96 {"alarmLabel": _alarmLabel})
97 }
98
99 SubtitledListItem {
100 id: _alarmSound
101 /*
102 #TODO: Add support for choosing new alarm sound when indicator-
103 datetime supports custom alarm sounds
104 */
105 text: i18n.tr("Sound (disabled)")
106 subText: "Suru arpeggio"
107 onClicked: mainStack.push(Qt.resolvedUrl("AlarmSound.qml"),
108 {"alarmSound": _alarmSound})
109 }
110 }
111
112 tools: ToolbarItems {
113 back: Button {
114 action: Action {
115 iconName: "close"
116 onTriggered: {
117 mainStack.pop()
118 }
119 }
120 }
121
122 ToolbarButton {
123 action: Action {
124 iconName: "save"
125 onTriggered: {
126 saveNewAlarm()
127 }
128 }
129 }
130 }
131}
0132
=== modified file 'app/clock/ClockPage.qml'
--- app/clock/ClockPage.qml 2014-06-21 16:42:08 +0000
+++ app/clock/ClockPage.qml 2014-07-07 08:40:55 +0000
@@ -49,12 +49,16 @@
49 contentWidth: parent.width49 contentWidth: parent.width
50 contentHeight: clock.height + date.height + locationRow.height50 contentHeight: clock.height + date.height + locationRow.height
5151
52 AddCityButton {52 PullToAdd {
53 id: addCityButton53 id: addCityButton
54
54 anchors.top: parent.top55 anchors.top: parent.top
55 anchors.topMargin: -labelHeight - units.gu(6)56 anchors.topMargin: -labelHeight - units.gu(6)
56 anchors.horizontalCenter: parent.horizontalCenter57 anchors.horizontalCenter: parent.horizontalCenter
57 maxThreshold: _maxThreshold58
59 leftLabel: i18n.tr("Add")
60 rightLabel: i18n.tr("City")
61 maxThreshold: clockPage._maxThreshold
58 }62 }
5963
60 Clock {64 Clock {
6165
=== added file 'app/components/PullToAdd.qml'
--- app/components/PullToAdd.qml 1970-01-01 00:00:00 +0000
+++ app/components/PullToAdd.qml 2014-07-07 08:40:55 +0000
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19
20Row {
21 id: _pullToAdd
22
23 // Property to get the position of the button from the top
24 property int dragPosition: 0
25
26 // Property to store the height of the label
27 property alias labelHeight: _leftLabel.height
28
29 // Property to set the label on the left side of the add button
30 property alias leftLabel: _leftLabel.text
31
32 // Property to set the label on the right side of the add button
33 property alias rightLabel: _rightLabel.text
34
35 // Property to set the maximum threshold beyond which the button shouldn't resize
36 property int maxThreshold
37
38 spacing: units.gu(1)
39
40 Label {
41 id: _leftLabel
42
43 text: "pull"
44 fontSize: "medium"
45 color: UbuntuColors.midAubergine
46 anchors.verticalCenter: parent.verticalCenter
47 }
48
49 ClockCircle {
50 id: _addButton
51
52 isOuter: true
53 width: dragPosition >= maxThreshold ? dragPosition * units.gu(6.5)/maxThreshold : units.gu(6.5)
54
55 ClockCircle {
56 width: dragPosition >= maxThreshold ? dragPosition * units.gu(4.5)/maxThreshold : units.gu(4.5)
57 anchors.centerIn: parent
58
59 Label {
60 id: plusLabel
61
62 anchors.centerIn: parent
63 font.pixelSize: dragPosition >= maxThreshold ? dragPosition * units.dp(30)/maxThreshold : units.dp(30)
64 text: "+"
65 }
66 }
67 }
68
69 Label {
70 id: _rightLabel
71
72 text: "down"
73 fontSize: "medium"
74 color: UbuntuColors.midAubergine
75 anchors.verticalCenter: parent.verticalCenter
76 }
77}
078
=== added file 'app/components/SubtitledListItem.qml'
--- app/components/SubtitledListItem.qml 1970-01-01 00:00:00 +0000
+++ app/components/SubtitledListItem.qml 2014-07-07 08:40:55 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright (C) 2014 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0 as ListItem
20
21/*
22 This component is almost an identical copy of the SDK's subtitled with the
23 exception of the font size and color required by the new clock app design.
24
25 #TODO: Revert to using the SDK Subtitled Component when they change the
26 design to match the new clock app design.
27 */
28ListItem.Base {
29 id: _subtitledContainer
30
31 // Property to set the main text label
32 property alias text: _mainText.text
33
34 // Property to set the subtitle label
35 property alias subText: _subText.text
36
37 height: units.gu(7)
38
39 Column {
40 id: _labelColumn
41
42 anchors.verticalCenter: parent.verticalCenter
43
44 Label {
45 id: _mainText
46 fontSize: "medium"
47 color: UbuntuColors.midAubergine
48 }
49
50 Label {
51 id: _subText
52 fontSize: "xx-small"
53 }
54 }
55}
056
=== modified file 'app/ubuntu-clock-app.qml'
--- app/ubuntu-clock-app.qml 2014-06-17 18:06:24 +0000
+++ app/ubuntu-clock-app.qml 2014-07-07 08:40:55 +0000
@@ -74,11 +74,6 @@
74 onTriggered: clockPage.updateTime()74 onTriggered: clockPage.updateTime()
75 }75 }
7676
77 AlarmModel {
78 id: alarmModel
79 Component.onCompleted: Utils.log(debugMode, "Alarm Database loaded")
80 }
81
82 PageStack {77 PageStack {
83 id: mainStack78 id: mainStack
8479

Subscribers

People subscribed via source and target branches