~ubuntu-branches/ubuntu/vivid/gpodder/vivid

« back to all changes in this revision

Viewing changes to share/gpodder/ui/qml/MediaPlayer.qml

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-04-12 22:07:02 UTC
  • mfrom: (5.2.27 sid)
  • Revision ID: package-import@ubuntu.com-20130412220702-mux8v9r8zt2jin0x
Tags: 3.5.1-1
* New upstream release.
* d/control: declare versioned dependency on python-gtk2 (>= 2.16)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
import QtQuick 1.1
3
3
import QtMultimediaKit 1.1
 
4
 
 
5
import org.gpodder.qmlui 1.0
4
6
import com.nokia.meego 1.0
5
7
 
6
8
import 'config.js' as Config
17
19
    property variant playQueue: []
18
20
    property int startedFrom: 0
19
21
 
 
22
    property bool hasQueue: playQueue.length > 0
 
23
 
 
24
    function showQueue() {
 
25
        playQueueDialog.showQueue();
 
26
    }
 
27
 
20
28
    onStartedFromChanged: {
21
29
        console.log('started from: ' + startedFrom)
22
30
    }
107
115
    }
108
116
 
109
117
    function removeQueuedEpisodesForPodcast(podcast) {
 
118
        if (mediaPlayer.episode !== undefined && podcast.equals(mediaPlayer.episode.qpodcast)) {
 
119
            // Stop playback if currently playing an episode in the podcast
 
120
            togglePlayback(undefined);
 
121
        }
 
122
 
110
123
        var newQueue = [];
111
124
 
112
125
        for (var i in playQueue) {
121
134
    }
122
135
 
123
136
    function removeQueuedEpisode(episode) {
 
137
        if (mediaPlayer.episode !== undefined && episode.equals(mediaPlayer.episode)) {
 
138
            // Stop playback if the deleted epiosde is currently played
 
139
            togglePlayback(undefined);
 
140
        }
 
141
 
124
142
        var newQueue = [];
125
143
 
126
144
        for (var i in playQueue) {
135
153
    }
136
154
 
137
155
    function togglePlayback(episode) {
138
 
        controller.currentEpisodeChanging();
 
156
        controller.currentEpisodeChanging(episode);
139
157
 
140
158
        if (mediaPlayer.episode == episode && audioPlayer.status !== 7) {
141
159
            if (audioPlayer.paused) {
177
195
        audioPlayer.source = ''
178
196
    }
179
197
 
180
 
    Rectangle {
181
 
        visible: playQueue.length > 0
182
 
        color: 'black'
183
 
        anchors {
184
 
            top: mediaPlayerMain.bottom
185
 
            left: parent.left
186
 
            right: parent.right
187
 
        }
188
 
        height: playQueueButton.height + Config.smallSpacing
189
 
 
190
 
        Button {
191
 
            id: playQueueButton
192
 
            anchors.horizontalCenter: parent.horizontalCenter
193
 
            text: _('Play queue') + ' (' + playQueue.length + ')'
194
 
            onClicked: playQueueDialog.showQueue();
195
 
        }
196
 
 
197
 
        MultiSelectionDialog {
198
 
            id: playQueueDialog
199
 
 
200
 
            function showQueue() {
201
 
                selectedIndexes = [];
202
 
                model.clear();
203
 
                for (var index in playQueue) {
204
 
                    var episode = playQueue[index];
205
 
                    model.append({'name': episode.qtitle, 'position': index});
206
 
                }
207
 
                open();
208
 
            }
209
 
 
210
 
            onAccepted: {
211
 
                /**
212
 
                 * FIXME: If things have been removed from the play queue while
213
 
                 * the dialog was open, we have to subtract the values in
214
 
                 * selectedIndexes by the amount of played episodes to get the
215
 
                 * right episodes to delete. This is not yet done here.
216
 
                 * We can know from the nextInQueue() function (hint, hint)
217
 
                 **/
218
 
                var newQueue = [];
219
 
                for (var queueIndex in playQueue) {
220
 
                    var episode = playQueue[queueIndex];
221
 
                    var shouldRemove = false;
222
 
 
223
 
                    for (var index in selectedIndexes) {
224
 
                        var pos = model.get(selectedIndexes[index]).position;
225
 
                        if (queueIndex === pos) {
226
 
                            shouldRemove = true;
227
 
                            break;
228
 
                        }
229
 
                    }
230
 
 
231
 
                    if (shouldRemove) {
232
 
                        controller.releaseEpisode(episode);
233
 
                        /* Implicit removal by absence of newQueue.push() */
234
 
                    } else {
235
 
                        newQueue.push(episode);
236
 
                    }
237
 
                }
238
 
                playQueue = newQueue;
239
 
            }
240
 
 
241
 
            titleText: _('Play queue')
242
 
            acceptButtonText: _('Remove')
243
 
            model: ListModel { }
244
 
        }
 
198
    MultiSelectionDialog {
 
199
        id: playQueueDialog
 
200
 
 
201
        function showQueue() {
 
202
            selectedIndexes = [];
 
203
            model.clear();
 
204
            for (var index in playQueue) {
 
205
                var episode = playQueue[index];
 
206
                model.append({'name': episode.qtitle, 'position': index});
 
207
            }
 
208
            open();
 
209
        }
 
210
 
 
211
        onAccepted: {
 
212
            /**
 
213
             * FIXME: If things have been removed from the play queue while
 
214
             * the dialog was open, we have to subtract the values in
 
215
             * selectedIndexes by the amount of played episodes to get the
 
216
             * right episodes to delete. This is not yet done here.
 
217
             * We can know from the nextInQueue() function (hint, hint)
 
218
             **/
 
219
            var newQueue = [];
 
220
            for (var queueIndex in playQueue) {
 
221
                var episode = playQueue[queueIndex];
 
222
                var shouldRemove = false;
 
223
 
 
224
                for (var index in selectedIndexes) {
 
225
                    var pos = model.get(selectedIndexes[index]).position;
 
226
                    if (queueIndex === pos) {
 
227
                        shouldRemove = true;
 
228
                        break;
 
229
                    }
 
230
                }
 
231
 
 
232
                if (shouldRemove) {
 
233
                    controller.releaseEpisode(episode);
 
234
                    /* Implicit removal by absence of newQueue.push() */
 
235
                } else {
 
236
                    newQueue.push(episode);
 
237
                }
 
238
            }
 
239
            playQueue = newQueue;
 
240
        }
 
241
 
 
242
        titleText: _('Play queue')
 
243
        acceptButtonText: _('Remove')
 
244
        model: ListModel { }
245
245
    }
246
246
 
247
247
    Rectangle {
248
248
        id: mediaPlayerMain
249
249
        anchors.fill: mediaPlayer
250
 
        color: 'black'
 
250
        color: Config.mediaPlayerColorBg
251
251
 
252
252
        Column {
253
253
            spacing: Config.smallSpacing
262
262
                text: (episode!=undefined)?episode.qtitle:''
263
263
                color: 'white'
264
264
                font.pixelSize: 30 * Config.scale
265
 
                elide: Text.ElideRight
266
265
                width: parent.width
267
266
            }
268
267
 
271
270
                text: (episode!=undefined)?episode.qpodcast.qtitle:''
272
271
                color: '#aaa'
273
272
                font.pixelSize: 20 * Config.scale
274
 
                elide: Text.ElideRight
275
273
                width: parent.width
276
274
            }
277
275
 
363
361
        }
364
362
 
365
363
        Label {
 
364
            y: progressBar.y - height - Config.smallSpacing
366
365
            anchors {
367
 
                bottom: parent.bottom
368
366
                right: parent.right
369
 
                bottomMargin: progressBar.height
370
367
                rightMargin: Config.largeSpacing
371
368
            }
372
369
            color: '#aaa'