13
14
property variant soundDisplayNames:
14
15
Utilities.buildSoundValues(soundFileNames)
15
property variant soundFileNames: backendInfo.listSounds(
16
[soundsDir, "/custom" + soundsDir])
16
property variant soundFileNames: refreshSoundFileNames()
17
17
property bool showStopButton: false
18
18
property int soundType // 0: ringtone, 1: message
19
19
property string soundsDir
20
property var activeTransfer
22
onSoundFileNamesChanged: {
23
soundDisplayNames = Utilities.buildSoundValues(soundFileNames)
28
flickable: scrollWidget
30
function refreshSoundFileNames() {
32
return backendInfo.listSounds([soundsDir, "/custom" + soundsDir, backendInfo.customRingtonePath])
33
return backendInfo.listSounds([soundsDir, "/custom" + soundsDir])
55
68
audioRole: MediaPlayer.alert
60
anchors.left: parent.left
61
anchors.right: parent.right
63
ListItem.SingleControl {
66
text: i18n.tr("Stop playing")
67
width: parent.width - units.gu(4)
71
function setRingtone(path) {
73
soundSettings.incomingCallSound = path
74
backendInfo.incomingCallSound = path
75
} else if (soundType == 1) {
76
soundSettings.incomingMessageSound = path
77
backendInfo.incomingMessageSound = path
79
soundFileNames = refreshSoundFileNames()
80
soundEffect.source = path
84
function updateSelectedIndex() {
86
soundSelector.selectedIndex =
87
Utilities.indexSelectedFile(soundFileNames,
88
backendInfo.incomingCallSound)
89
else if (soundType == 1)
90
soundSelector.selectedIndex =
91
Utilities.indexSelectedFile(soundFileNames,
92
backendInfo.incomingMessageSound)
98
contentWidth: parent.width
99
contentHeight: selectorColumn.height + stopItem.height
100
boundsBehavior: (contentHeight > height) ?
101
Flickable.DragAndOvershootBounds :
102
Flickable.StopAtBounds
103
/* Set the direction to workaround https://bugreports.qt-project.org/browse/QTBUG-31905
104
otherwise the UI might end up in a situation where scrolling doesn't work */
105
flickableDirection: Flickable.VerticalFlick
109
anchors.left: parent.left
110
anchors.right: parent.right
112
ListItem.ItemSelector {
115
model: soundDisplayNames
117
updateSelectedIndex()
120
setRingtone(soundFileNames[index])
126
text: i18n.tr("Custom Ringtone")
127
visible: soundType === 0
130
pageStack.push(picker);
136
ListItem.SingleControl {
138
anchors.bottom: parent.bottom
139
control: AbstractButton {
141
anchors.verticalCenter: parent.verticalCenter
142
anchors.horizontalCenter: parent.horizontalCenter
71
146
enabled: soundEffect.playbackState == Audio.PlayingState
72
visible: showStopButton
76
ListItem.ItemSelector {
78
anchors.top: columnId.bottom
79
anchors.bottom: soundsPage.bottom
80
containerHeight: height
83
model: soundDisplayNames
86
soundSelector.selectedIndex =
87
Utilities.indexSelectedFile(soundFileNames,
88
backendInfo.incomingCallSound)
89
else if (soundType == 1)
90
soundSelector.selectedIndex =
91
Utilities.indexSelectedFile(soundFileNames,
92
backendInfo.incomingMessageSound)
96
soundSettings.incomingCallSound = soundFileNames[index]
97
backendInfo.incomingCallSound = soundFileNames[index]
98
} else if (soundType == 1) {
99
soundSettings.incomingMessageSound = soundFileNames[index]
100
backendInfo.incomingMessageSound = soundFileNames[index]
102
soundEffect.source = soundFileNames[index]
149
onClicked: soundEffect.stop()
154
border.color: UbuntuColors.warmGrey
159
width: parent.height * 0.4
163
verticalCenter: parent.verticalCenter
164
horizontalCenter: parent.horizontalCenter
166
color: UbuntuColors.warmGrey
172
visible: stopButton.visible
173
color: Theme.palette.normal.background
178
id: contentHubConnection
179
property var ringtoneCallback
180
target: activeTransfer ? activeTransfer : null
182
if (activeTransfer.state === ContentTransfer.Charged) {
183
if (activeTransfer.items.length > 0) {
184
var toneUri = activeTransfer.items[0].url;
185
ringtoneCallback(toneUri);
197
scope: ContentScope.App
202
visible: parent.visible
203
handler: ContentHandler.Source
204
contentType: ContentType.Music
209
// requests an active transfer from peer
210
function startContentTransfer(callback) {
212
contentHubConnection.ringtoneCallback = callback
213
var transfer = peer.request(appStore);
214
if (transfer !== null) {
215
soundsPage.activeTransfer = transfer;
218
peer.selectionType = ContentTransfer.Single;
219
startContentTransfer(function(uri) {
220
setRingtone(uri.toString().replace("file:///", "/"));
224
onCancelPressed: pageStack.pop();
228
ContentTransferHint {
230
activeTransfer: soundsPage.activeTransfer