Merge lp:~seb128/ubuntu-system-settings/sound-display-names into lp:ubuntu-system-settings

Proposed by Sebastien Bacher
Status: Merged
Approved by: Iain Lane
Approved revision: 153
Merged at revision: 152
Proposed branch: lp:~seb128/ubuntu-system-settings/sound-display-names
Merge into: lp:ubuntu-system-settings
Diff against target: 40 lines (+19/-3)
1 file modified
plugins/sound/SoundsList.qml (+19/-3)
To merge this branch: bzr merge lp:~seb128/ubuntu-system-settings/sound-display-names
Reviewer Review Type Date Requested Status
Iain Lane Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+175250@code.launchpad.net

Commit message

sound: display the sounds names in a nicer way

Description of the change

sound: display the sounds names in a nicer way

Review comments:

That feels a bit hackish but I didn't find a better way, if somebody knows how to do that better please let me know ;-)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

Thanks, to summarise

  - It's not ideal that we have to use C++ here - there's a Qt/QML module Qt.labs.folderlistmodel which we could use, but ...
  - ValueSelector doesn't take a model and there's no good way to convert one to a list of strings
  - ValueSelector is going away to be replaced with OptionSelector

I shortened the JS here a bit in a branch: lp:~laney/ubuntu-system-settings/sound-display-names - could you take a look and review/merge? I'd have preferred to use a map but QML's support there doesn't seem very good.

review: Needs Fixing
153. By Sebastien Bacher

simplify and clean the code a bit, thanks Laney

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the improvements, I merged your changes (just reverted the .slice().join()-> .push() since we want to truncate before the last dot not the first one), verified that it still works as it should ;-)

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

Cheers, lgtm

review: Approve

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 2013-07-16 17:04:35 +0000
3+++ plugins/sound/SoundsList.qml 2013-07-17 13:22:30 +0000
4@@ -5,17 +5,33 @@
5 import Ubuntu.SystemSettings.Sound 1.0
6
7 ItemPage {
8- property string title;
9+ property string title
10+ property variant soundDisplayNames
11+ property variant soundFileNames
12
13+ id: soundsPage
14 title: title
15
16 UbuntuSoundPanel {
17 id: backendInfo
18- }
19+ Component.onCompleted:
20+ buildSoundValues(listSounds("/usr/share/sounds/ubuntu/stereo"))
21+ }
22+
23+ function buildSoundValues(sounds)
24+ {
25+ soundDisplayNames = sounds.map(function (sound) {
26+ return sound.split('/').pop().split('.').slice(0,-1).join(" ");
27+ })
28+ soundFileNames = sounds
29+ }
30+
31 ListItem.ValueSelector {
32 expanded: true
33 // TODO: There is no way to have a ValueSelector always expanded
34 onExpandedChanged: expanded = true
35- values: backendInfo.listSounds("/usr/share/sounds/ubuntu/stereo")
36+ values: soundDisplayNames
37+ onSelectedIndexChanged:
38+ print(soundFileNames[selectedIndex]) // TODO: write configuration
39 }
40 }

Subscribers

People subscribed via source and target branches