Merge lp:~nik90/ubuntu-clock-app/alarm-sounds into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan on 2014-05-22
Status: Rejected
Rejected by: Nekhelesh Ramananthan on 2014-08-08
Proposed branch: lp:~nik90/ubuntu-clock-app/alarm-sounds
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 76 lines (+43/-1)
1 file modified
alarm/AddAlarmPage.qml (+43/-1)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/alarm-sounds
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Disapprove on 2014-08-08
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing on 2014-05-22
Review via email: mp+220687@code.launchpad.net

Commit message

Added support to change alarm sounds from the UI

Description of the change

Adds the ability to change the alarm sounds from the Add Alarm dialog

To post a comment you must log in.
411. By Nekhelesh Ramananthan on 2014-05-22

merge trunk

#blocked on indicator-datetime

Nekhelesh Ramananthan (nik90) wrote :

#blocked on pending work in indicator-datetime

Nekhelesh Ramananthan (nik90) wrote :

#unblocked

As this is unblocked does that mean it's ready to land?

Nekhelesh Ramananthan (nik90) wrote :

#blocked due to upstream bug in the SDK which does not show the chosen alarm sound when editing an alarm. https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1338697

review: Needs Fixing
Nekhelesh Ramananthan (nik90) wrote :

#unblocked I am rejecting this branch since it requires further rework before getting it to work with the old clock app. However all my attention is now directed at the clock reboot where this bug will be fixed.

review: Disapprove

Unmerged revisions

411. By Nekhelesh Ramananthan on 2014-05-22

merge trunk

410. By Nekhelesh Ramananthan on 2014-05-21

Added ability to choose alarm sounds

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'alarm/AddAlarmPage.qml'
2--- alarm/AddAlarmPage.qml 2014-05-22 15:45:45 +0000
3+++ alarm/AddAlarmPage.qml 2014-05-22 20:29:40 +0000
4@@ -19,8 +19,8 @@
5 import QtQuick 2.0
6 import Ubuntu.Layouts 0.1
7 import Ubuntu.Components 0.1
8+import Qt.labs.folderlistmodel 2.1
9 import Ubuntu.Components.Popups 0.1
10-import Ubuntu.Components.Themes.Ambiance 0.1
11 import Ubuntu.Components.ListItems 0.1 as ListItem
12 import "../common/ClockUtils.js" as Utils
13 import "../common"
14@@ -166,6 +166,7 @@
15 alarm.daysOfWeek = temp_alarm.daysOfWeek
16 alarm.enabled = temp_alarm.enabled
17 alarm.date = temp_alarm.date
18+ alarm.sound = temp_alarm.sound
19
20 // Determining if the alarm read is set to trigger in the morning or evening
21 isPm = Qt.formatTime(alarm.date, "AP") === "PM"
22@@ -185,6 +186,7 @@
23 temp_alarm.type = alarm.type
24 temp_alarm.daysOfWeek = alarm.daysOfWeek
25 temp_alarm.date = alarmTime
26+ temp_alarm.sound = alarm.sound
27 temp_alarm.save()
28
29 if(validateAlarm(temp_alarm))
30@@ -652,6 +654,46 @@
31 return occurs;
32 }
33 }
34+
35+ OptionSelector {
36+ id: soundSelector
37+ objectName: "soundSelector"
38+ text: i18n.tr("Ringtone")
39+ containerHeight: itemHeight * 7
40+
41+ // Function to retrieve the alarm sound index after comparing the sound filenames
42+ function getSoundIndex(chosenSoundPath) {
43+ console.log(folderModel.count + "|" + chosenSoundPath)
44+ for(var i=0; i<folderModel.count; i++) {
45+ // Goes through every sound file in the folder and compares their file path with
46+ // the alarm sound path returned by the Alarm Model
47+ if(chosenSoundPath === folderModel.get(i, "filePath"))
48+ return i
49+ }
50+ // If no matching alarm sound is found, return the first on the list to avoid invalid results
51+ return 0
52+ }
53+
54+ onSelectedIndexChanged: alarm.sound = folderModel.get(selectedIndex, "filePath")
55+
56+ FolderListModel {
57+ id: folderModel
58+ folder: "/usr/share/sounds/ubuntu/ringtones"
59+ onCountChanged: {
60+ if(count > 0 && !isNewAlarm) {
61+ soundSelector.selectedIndex = soundSelector.getSoundIndex(alarm.sound)
62+ }
63+ }
64+ }
65+
66+ Component {
67+ id: fileDelegate
68+ OptionSelectorDelegate { text: fileBaseName }
69+ }
70+
71+ model: folderModel
72+ delegate: fileDelegate
73+ }
74 }
75 }
76 }

Subscribers

People subscribed via source and target branches