Merge lp:~seb128/ubuntu-system-settings/sound-custom-ringtones into lp:ubuntu-system-settings

Proposed by Sebastien Bacher
Status: Merged
Approved by: Iain Lane
Approved revision: 1134
Merged at revision: 1136
Proposed branch: lp:~seb128/ubuntu-system-settings/sound-custom-ringtones
Merge into: lp:ubuntu-system-settings
Diff against target: 63 lines (+31/-7)
2 files modified
plugins/sound/SoundsList.qml (+1/-4)
plugins/sound/sound.cpp (+30/-3)
To merge this branch: bzr merge lp:~seb128/ubuntu-system-settings/sound-custom-ringtones
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Iain Lane Approve
Review via email: mp+238595@code.launchpad.net

Commit message

[sound] list custom ringtones as well

Description of the change

[sound] list custom ringtones as well

To post a comment you must log in.
1134. By Sebastien Bacher

typo fix

Revision history for this message
Iain Lane (laney) wrote :

Ok, I did my suggested fix which I'll propose as a branch on top and you can take or not

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/sound/SoundsList.qml'
2--- plugins/sound/SoundsList.qml 2014-09-05 20:17:34 +0000
3+++ plugins/sound/SoundsList.qml 2014-10-16 16:55:16 +0000
4@@ -11,10 +11,7 @@
5 ItemPage {
6 property variant soundDisplayNames:
7 Utilities.buildSoundValues(soundFileNames)
8- property variant soundFileNames:
9- backendInfo.listSounds(soundsDir).map(function (sound) {
10- return soundsDir+sound
11- })
12+ property variant soundFileNames: backendInfo.listSounds(soundsDir)
13 property bool showStopButton: false
14 property int soundType // 0: ringtone, 1: message
15 property string soundsDir
16
17=== modified file 'plugins/sound/sound.cpp'
18--- plugins/sound/sound.cpp 2014-08-28 17:33:40 +0000
19+++ plugins/sound/sound.cpp 2014-10-16 16:55:16 +0000
20@@ -210,13 +210,40 @@
21 Q_EMIT(dialpadSoundsEnabledChanged());
22 }
23
24+QStringList soundsListFromDir(const QString &dirString)
25+{
26+ QDir soundsDir(dirString);
27+
28+ if (soundsDir.exists())
29+ {
30+ QStringList soundsList;
31+
32+ soundsDir.setFilter(QDir::Files | QDir::NoSymLinks);
33+
34+ for (uint i=0; i < soundsDir.count(); i++)
35+ soundsList.append(soundsDir.absoluteFilePath(soundsDir[i])) ;
36+ return soundsList;
37+ }
38+ return QStringList();
39+}
40+
41+bool sortSoundsList(const QString &s1, const QString &s2)
42+ {
43+ return QFileInfo(s1).fileName() < QFileInfo(s2).fileName();
44+}
45+
46+/* List soundfiles in a directory and the corresponding /custom one,
47+ * which is what is used for oem customization, return a list of
48+ * the fullpaths to those sounds, sorted by name */
49 QStringList Sound::listSounds(const QString &dirString)
50 {
51 if (m_soundsList.isEmpty())
52 {
53- QDir soundsDir(dirString);
54- soundsDir.setFilter(QDir::Files | QDir::NoSymLinks);
55- m_soundsList = soundsDir.entryList();
56+ m_soundsList = soundsListFromDir(dirString);
57+ m_soundsList.append(soundsListFromDir("/custom" + dirString));
58+
59+ qSort(m_soundsList.begin(), m_soundsList.end(), sortSoundsList);
60 }
61+
62 return m_soundsList;
63 }

Subscribers

People subscribed via source and target branches