Merge lp:~nik90/ubuntu-clock-app/add-custom-sound-backend into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan on 2014-07-07
Status: Merged
Approved by: Nekhelesh Ramananthan on 2014-08-18
Approved revision: 54
Merged at revision: 56
Proposed branch: lp:~nik90/ubuntu-clock-app/add-custom-sound-backend
Merge into: lp:ubuntu-clock-app
Prerequisite: lp:~nik90/ubuntu-clock-app/add-modify-alarm-support
Diff against target: 270 lines (+91/-45)
4 files modified
app/alarm/AlarmSound.qml (+20/-29)
app/alarm/EditAlarmPage.qml (+64/-14)
debian/changelog (+1/-0)
tests/autopilot/ubuntu_clock_app/emulators.py (+6/-2)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/add-custom-sound-backend
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2014-08-18
Riccardo Padovani Approve on 2014-08-18
Nekhelesh Ramananthan Needs Fixing on 2014-07-09
Andrew Hayzen 2014-08-15 Pending
Review via email: mp+225812@code.launchpad.net

Commit message

Add support for custom sounds

Description of the change

Add support for custom sounds

NOTE: Test with image #189 and higher

To post a comment you must log in.
Nekhelesh Ramananthan (nik90) wrote :
review: Needs Fixing
Nekhelesh Ramananthan (nik90) wrote :

#unblocked

Riccardo Padovani (rpadovani) wrote :

Code looks good to me, and the new feature works on rev 197

review: Approve
54. By Nekhelesh Ramananthan on 2014-08-18

merged trunk and fixed debian changelog conflict

Nekhelesh Ramananthan (nik90) wrote :

There was a conflict in the debian/changelog file while merging the latest trunk. I fixed that and reapproved.

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/AlarmSound.qml'
2--- app/alarm/AlarmSound.qml 2014-07-30 20:16:06 +0000
3+++ app/alarm/AlarmSound.qml 2014-08-18 11:06:04 +0000
4@@ -18,7 +18,6 @@
5
6 import QtQuick 2.0
7 import Ubuntu.Components 1.1
8-import Qt.labs.folderlistmodel 2.1
9 import Ubuntu.Components.ListItems 1.0 as ListItem
10
11 Page {
12@@ -31,11 +30,17 @@
13 // Property to set the alarm sound in the edit alarm page
14 property var alarmSound
15
16- FolderListModel {
17- id: _soundModel
18- showDirs: false
19- nameFilters: [ "*.ogg", "*.mp3" ]
20- folder: "/usr/share/sounds/ubuntu/ringtones"
21+ // Property to store the alarm object
22+ property var alarm
23+
24+ // Property to set the alarm sound model in the edit alarm page
25+ property var soundModel
26+
27+ head.backAction: Action {
28+ iconName: "back"
29+ onTriggered: {
30+ pop()
31+ }
32 }
33
34 Flickable {
35@@ -43,7 +48,7 @@
36
37 clip: true
38 anchors.fill: parent
39- contentHeight: _soundModel.count * units.gu(7)
40+ contentHeight: soundModel.count * units.gu(7)
41
42 Column {
43 id: _alarmSoundColumn
44@@ -54,9 +59,9 @@
45 id: _alarmSounds
46 objectName: "alarmSounds"
47
48- model: _soundModel
49+ model: soundModel
50
51- ListItem.Base {
52+ ListItem.Standard {
53 id: _alarmSoundDelegate
54
55 property alias isChecked: _soundStatus.checked
56@@ -69,6 +74,7 @@
57
58 anchors {
59 left: parent.left
60+ leftMargin: units.gu(2)
61 verticalCenter: parent.verticalCenter
62 }
63
64@@ -77,23 +83,19 @@
65 text: fileBaseName
66 }
67
68- CheckBox {
69+ control: CheckBox {
70 id: _soundStatus
71 objectName: "soundStatus" + index
72
73- anchors {
74- right: parent.right
75- verticalCenter: parent.verticalCenter
76- }
77-
78- checked: alarmSound.subText === _soundName.text ? true :
79- false
80+ checked: alarmSound.subText === _soundName.text ? true
81+ : false
82 onClicked: {
83 if (checked) {
84 alarmSound.subText = _soundName.text
85+ alarm.sound = fileURL
86
87 // Ensures only one alarm sound is selected
88- for(var i=0; i<_soundModel.count; i++) {
89+ for(var i=0; i<soundModel.count; i++) {
90 if(_alarmSounds.itemAt(i).isChecked &&
91 i !== index) {
92 _alarmSounds.itemAt(i).isChecked = false
93@@ -106,15 +108,4 @@
94 }
95 }
96 }
97-
98- tools: ToolbarItems {
99- back: Button {
100- action: Action {
101- iconName: "back"
102- onTriggered: {
103- mainStack.pop()
104- }
105- }
106- }
107- }
108 }
109
110=== modified file 'app/alarm/EditAlarmPage.qml'
111--- app/alarm/EditAlarmPage.qml 2014-08-11 22:04:27 +0000
112+++ app/alarm/EditAlarmPage.qml 2014-08-18 11:06:04 +0000
113@@ -19,6 +19,7 @@
114 import QtQuick 2.0
115 import DateTime 1.0
116 import Ubuntu.Components 1.1
117+import Qt.labs.folderlistmodel 2.1
118 import Ubuntu.Components.Pickers 1.0
119 import Ubuntu.Components.ListItems 1.0 as ListItem
120 import "../components"
121@@ -73,7 +74,10 @@
122 var alarmTime = new Date()
123 alarmTime.setHours(_timePicker.hours, _timePicker.minutes, 0)
124
125- _alarm.message = _alarmLabel.subText
126+ /*
127+ _alarm.sound, _alarm.message and _alarm.daysOfWeek have been set in
128+ the respective individual pages already.
129+ */
130 _alarm.date = alarmTime
131 _alarm.type = Alarm.Repeating
132 _alarm.enabled = true
133@@ -89,6 +93,7 @@
134 _alarm.daysOfWeek = tempAlarm.daysOfWeek
135 _alarm.enabled = tempAlarm.enabled
136 _alarm.date = tempAlarm.date
137+ _alarm.sound = tempAlarm.sound
138 }
139
140 // Function to delete a saved alarm
141@@ -112,11 +117,7 @@
142 tempAlarm.date = alarmTime
143 tempAlarm.type = Alarm.Repeating
144 tempAlarm.enabled = _alarm.enabled
145-
146- /*
147- #FIXME: Sometimes the clock app crashes due to this code. Cause not
148- known yet! This has been reported at http://pad.lv/1337405.
149- */
150+ tempAlarm.sound = _alarm.sound
151 tempAlarm.daysOfWeek = _alarm.daysOfWeek
152
153 tempAlarm.save()
154@@ -137,6 +138,22 @@
155 }
156 }
157
158+ function getSoundName(chosenSoundPath) {
159+ for(var i=0; i<soundModel.count; i++) {
160+ if(chosenSoundPath === Qt.resolvedUrl(soundModel.get(i, "filePath"))) {
161+ return soundModel.get(i, "fileBaseName")
162+ }
163+ }
164+ }
165+
166+ function getSoundPath(chosenSoundName) {
167+ for(var i=0; i<soundModel.count; i++) {
168+ if(chosenSoundName === soundModel.get(i, "fileBaseName")) {
169+ return soundModel.get(i, "filePath")
170+ }
171+ }
172+ }
173+
174 Alarm {
175 id: _alarm
176 onStatusChanged: {
177@@ -155,6 +172,37 @@
178 }
179 }
180
181+ FolderListModel {
182+ id: soundModel
183+
184+ showDirs: false
185+ nameFilters: [ "*.ogg", "*.mp3" ]
186+ folder: "/usr/share/sounds/ubuntu/ringtones"
187+
188+ onCountChanged: {
189+ if(count > 0) {
190+ /*
191+ When folder model is completely loaded, proceed to perform
192+ the following operations,
193+
194+ if new alarm, then set the sound name as "Suru arpeggio" and
195+ retrieve the sound path from the folder model to assign to
196+ the alarm model sound property.
197+
198+ If it is a saved alarm, get the sound path from the alarm
199+ object and retrieve the sound name from the folder model.
200+ */
201+ if(isNewAlarm) {
202+ _alarm.sound = getSoundPath(_alarmSound._soundName)
203+ _alarmSound.subText = _alarmSound._soundName
204+ }
205+ else {
206+ _alarmSound.subText = getSoundName(_alarm.sound.toString())
207+ }
208+ }
209+ }
210+ }
211+
212 AlarmUtils {
213 id: alarmUtils
214 }
215@@ -226,14 +274,16 @@
216 SubtitledListItem {
217 id: _alarmSound
218 objectName: "alarmSound"
219- /*
220- #TODO: Add support for choosing new alarm sound when indicator-
221- datetime supports custom alarm sounds
222- */
223- text: i18n.tr("Sound (disabled)")
224- subText: "Suru arpeggio"
225- onClicked: mainStack.push(Qt.resolvedUrl("AlarmSound.qml"),
226- {"alarmSound": _alarmSound})
227+
228+ // Default Alarm Sound for new alarms
229+ property string _soundName: "Suru arpeggio"
230+
231+ text: i18n.tr("Sound")
232+ onClicked: mainStack.push(Qt.resolvedUrl("AlarmSound.qml"), {
233+ "alarmSound": _alarmSound,
234+ "alarm": _alarm,
235+ "soundModel": soundModel
236+ })
237 }
238 }
239
240
241=== modified file 'debian/changelog'
242--- debian/changelog 2014-08-16 08:40:21 +0000
243+++ debian/changelog 2014-08-18 11:06:04 +0000
244@@ -5,6 +5,7 @@
245 strings. (LP: #1355414)
246 * Synced the fast scroll component with upstream changes
247 * Updated inner clock texture as requested by design
248+ * Added support for custom alarm sounds as per the design spec.
249
250 [David Planella]
251 * Added internationalization support (LP: #1354522)
252
253=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
254--- tests/autopilot/ubuntu_clock_app/emulators.py 2014-08-12 20:41:45 +0000
255+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-08-18 11:06:04 +0000
256@@ -228,8 +228,12 @@
257 :param test_sound_name = new sound name
258
259 """
260- self.wait_select_single("SubtitledListItem", objectName="alarmSound")\
261- .subText == test_sound_name
262+ try:
263+ self.wait_select_single(
264+ "SubtitledListItem", objectName="alarmSound").subText.wait_for(
265+ test_sound_name)
266+ except AssertionError:
267+ raise ClockEmulatorException('Error! Incorrect alarm sound')
268
269
270 class AlarmRepeat(Page):

Subscribers

People subscribed via source and target branches