on xenial help sign in
Adapt to api changes in the playlist implementation
6835e04Albert Astals Cid
plugins/Dash/AudioProgressBar.qml+1−1
@@ -24,7 +24,7 @@ Item {
24 height: progressBarImage.height
24 height: progressBarImage.height
25
25
26 property url source
26 property url source
27− readonly property double progress: DashAudioPlayer.isCurrentSource(source) ? DashAudioPlayer.progress : 0
27+ readonly property double progress: AudioUrlComparer.compare(source, DashAudioPlayer.currentSource) ? DashAudioPlayer.progress : 0
28
28
29 Image {
29 Image {
30 id: progressBarImage
30 id: progressBarImage
plugins/Dash/CardAudioProgress.qml+2−2
@@ -22,12 +22,12 @@ Item {
22 id: root
22 id: root
23
23
24 implicitHeight: positionLabel.y + positionLabel.height
24 implicitHeight: positionLabel.y + positionLabel.height
25− visible: DashAudioPlayer.isCurrentSource(source)
25+ visible: AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)
26
26
27 property int duration: 0
27 property int duration: 0
28 property url source
28 property url source
29 property color color: theme.palette.normal.baseText
29 property color color: theme.palette.normal.baseText
30− readonly property int position: DashAudioPlayer.isCurrentSource(source) ? DashAudioPlayer.position / 1000 : 0
30+ readonly property int position: root.visible ? DashAudioPlayer.position / 1000 : 0
31
31
32 AudioProgressBar {
32 AudioProgressBar {
33 id: progress
33 id: progress
plugins/Dash/CardCreator.js+2−2
@@ -147,10 +147,10 @@ var kAudioButtonCode = 'AbstractButton { \n\
147 anchors.fill: parent; \n\
147 anchors.fill: parent; \n\
148 anchors.margins: parent.height > units.gu(5) ? units.gu(2) : units.gu(0); \n\
148 anchors.margins: parent.height > units.gu(5) ? units.gu(2) : units.gu(0); \n\
149 opacity: 0.9; \n\
149 opacity: 0.9; \n\
150− name: DashAudioPlayer.isCurrentSource(parent.source) && DashAudioPlayer.playing ? "media-playback-pause" : "media-playback-start"; \n\
150+ name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start"; \n\
151 } \n\
151 } \n\
152 onClicked: { \n\
152 onClicked: { \n\
153− if (DashAudioPlayer.isCurrentSource(source)) { \n\
153+ if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) { \n\
154 if (DashAudioPlayer.playing) { \n\
154 if (DashAudioPlayer.playing) { \n\
155 DashAudioPlayer.pause(); \n\
155 DashAudioPlayer.pause(); \n\
156 } else { \n\
156 } else { \n\
plugins/Dash/DashAudioPlayer.qml+3−13
@@ -25,17 +25,7 @@ QtObject {
25 readonly property bool paused: audio.playbackState === Audio.PausedState
25 readonly property bool paused: audio.playbackState === Audio.PausedState
26 readonly property bool stopped: audio.playbackState === Audio.StoppedState
26 readonly property bool stopped: audio.playbackState === Audio.StoppedState
27 readonly property alias position: audio.position
27 readonly property alias position: audio.position
28−
28+ readonly property url currentSource: audio.playlist.currentItemSource
29− function isCurrentSource(source) {
30− if (source != "") {
31− if (audio.playlist) {
32− return AudioUrlComparer.compare(source, audio.playlist.currentSource);
33− } else {
34− return AudioUrlComparer.compare(source, audio.source);
35− }
36− }
37− return false;
38− }
39
29
40 function playSource(newSource, newPlaylist) {
30 function playSource(newSource, newPlaylist) {
41 stop();
31 stop();
@@ -58,10 +48,10 @@ QtObject {
58 for (var i in newPlaylist) {
48 for (var i in newPlaylist) {
59 urls.push(newPlaylist[i]);
49 urls.push(newPlaylist[i]);
60 }
50 }
61− audio.playlist.addSources(urls);
51+ audio.playlist.addItems(urls);
62 audio.playlist.currentIndex = sourceIndex;
52 audio.playlist.currentIndex = sourceIndex;
63 } else {
53 } else {
64− audio.playlist.addSource(newSource);
54+ audio.playlist.addItem(newSource);
65 audio.playlist.currentIndex = 0;
55 audio.playlist.currentIndex = 0;
66 }
56 }
67 play();
57 play();
qml/Dash/Previews/PreviewAudioPlayback.qml+1−1
@@ -50,7 +50,7 @@ PreviewWidget {
50 objectName: "trackItem" + index
50 objectName: "trackItem" + index
51
51
52 readonly property url sourceUrl: modelData["source"]
52 readonly property url sourceUrl: modelData["source"]
53− readonly property bool isPlayingItem: DashAudioPlayer.isCurrentSource(sourceUrl)
53+ readonly property bool isPlayingItem: AudioUrlComparer.compare(sourceUrl, DashAudioPlayer.currentSource)
54
54
55 anchors { left: parent.left; right: parent.right }
55 anchors { left: parent.left; right: parent.right }
56 height: units.gu(5)
56 height: units.gu(5)
tests/mocks/QtMultimedia/audio.cpp+1−26
@@ -34,29 +34,6 @@ Audio::Audio(QObject* parent):
34 Q_EMIT durationChanged(m_duration);
34 Q_EMIT durationChanged(m_duration);
35}
35}
36
36
37−QUrl Audio::source() const
38−{
39− return m_source;
40−}
41−
42−void Audio::setSource(const QUrl &source)
43−{
44− if (source == m_source && m_playlist == NULL)
45− return;
46−
47− m_playlist = NULL;
48− Q_EMIT playlistChanged();
49−
50− m_source = source;
51− Q_EMIT sourceChanged(source);
52−
53− m_position = 0;
54− Q_EMIT positionChanged(m_position);
55−
56− m_duration = (qrand() % 20000) + 10000;
57− Q_EMIT durationChanged(m_duration);
58−}
59−
60Audio::PlaybackState Audio::playbackState() const
37Audio::PlaybackState Audio::playbackState() const
61{
38{
62 return m_playbackState;
39 return m_playbackState;
@@ -134,11 +111,9 @@ DeclarativePlaylist *Audio::playlist() const
134
111
135void Audio::setPlaylist(DeclarativePlaylist *playlist)
112void Audio::setPlaylist(DeclarativePlaylist *playlist)
136{
113{
137− if (playlist == m_playlist && m_source.isEmpty())
114+ if (playlist == m_playlist)
138 return;
115 return;
139
116
140− m_source.clear();
141− Q_EMIT sourceChanged(m_source);
142 m_playlist = playlist;
117 m_playlist = playlist;
143 Q_EMIT playlistChanged();
118 Q_EMIT playlistChanged();
144}
119}
tests/mocks/QtMultimedia/audio.h−5
@@ -29,7 +29,6 @@ class Audio: public QObject
29 Q_OBJECT
29 Q_OBJECT
30 Q_ENUMS(PlaybackState)
30 Q_ENUMS(PlaybackState)
31 Q_ENUMS(AudioRole)
31 Q_ENUMS(AudioRole)
32− Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
33 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
32 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
34 Q_PROPERTY(int position READ position NOTIFY positionChanged)
33 Q_PROPERTY(int position READ position NOTIFY positionChanged)
35 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
34 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
@@ -52,9 +51,6 @@ public:
52
51
53 explicit Audio(QObject *parent = 0);
52 explicit Audio(QObject *parent = 0);
54
53
55− QUrl source() const;
56− void setSource(const QUrl &source);
57−
58 DeclarativePlaylist *playlist() const;
54 DeclarativePlaylist *playlist() const;
59 void setPlaylist(DeclarativePlaylist *playlist);
55 void setPlaylist(DeclarativePlaylist *playlist);
60
56
@@ -86,7 +82,6 @@ private Q_SLOTS:
86 void timerEvent();
82 void timerEvent();
87
83
88private:
84private:
89− QUrl m_source;
90 PlaybackState m_playbackState;
85 PlaybackState m_playbackState;
91 QTimer m_timer;
86 QTimer m_timer;
92 int m_position;
87 int m_position;
tests/mocks/QtMultimedia/declarativeplaylist.cpp+12−5
@@ -23,9 +23,9 @@ DeclarativePlaylist::DeclarativePlaylist(QObject *parent)
23{
23{
24}
24}
25
25
26−QUrl DeclarativePlaylist::currentSource() const
26+QUrl DeclarativePlaylist::currentItemSource() const
27{
27{
28− return source(currentIndex());
28+ return itemSource(currentIndex());
29}
29}
30
30
31int DeclarativePlaylist::currentIndex() const
31int DeclarativePlaylist::currentIndex() const
@@ -40,27 +40,34 @@ void DeclarativePlaylist::setCurrentIndex(int index)
40
40
41 m_currentIndex = index;
41 m_currentIndex = index;
42 Q_EMIT currentIndexChanged();
42 Q_EMIT currentIndexChanged();
43+ Q_EMIT currentItemSourceChanged();
43}
44}
44
45
45−QUrl DeclarativePlaylist::source(int index) const
46+QUrl DeclarativePlaylist::itemSource(int index) const
46{
47{
48+ if (index < 0 || index >= m_medias.count())
49+ return QUrl();
47 return m_medias[index];
50 return m_medias[index];
48}
51}
49
52
50−bool DeclarativePlaylist::addSource(const QUrl &source)
53+bool DeclarativePlaylist::addItem(const QUrl &source)
51{
54{
52 m_medias << source;
55 m_medias << source;
56+ setCurrentIndex(0);
53 return true;
57 return true;
54}
58}
55
59
56−bool DeclarativePlaylist::addSources(const QList<QUrl> &sources)
60+bool DeclarativePlaylist::addItems(const QList<QUrl> &sources)
57{
61{
58 m_medias << sources;
62 m_medias << sources;
63+ if (!sources.isEmpty())
64+ setCurrentIndex(0);
59 return true;
65 return true;
60}
66}
61
67
62bool DeclarativePlaylist::clear()
68bool DeclarativePlaylist::clear()
63{
69{
64 m_medias.clear();
70 m_medias.clear();
71+ setCurrentIndex(-1);
65 return true;
72 return true;
66}
73}
tests/mocks/QtMultimedia/declarativeplaylist.h+6−6
@@ -24,24 +24,24 @@
24class DeclarativePlaylist : public QObject
24class DeclarativePlaylist : public QObject
25{
25{
26 Q_OBJECT
26 Q_OBJECT
27− Q_PROPERTY(QUrl currentSource READ currentSource NOTIFY currentSourceChanged)
27+ Q_PROPERTY(QUrl currentItemSource READ currentItemSource NOTIFY currentItemSourceChanged)
28 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
28 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
29
29
30public:
30public:
31 DeclarativePlaylist(QObject *parent = 0);
31 DeclarativePlaylist(QObject *parent = 0);
32
32
33− QUrl currentSource() const;
33+ QUrl currentItemSource() const;
34 int currentIndex() const;
34 int currentIndex() const;
35 void setCurrentIndex(int currentIndex);
35 void setCurrentIndex(int currentIndex);
36
36
37public Q_SLOTS:
37public Q_SLOTS:
38− QUrl source(int index) const;
38+ QUrl itemSource(int index) const;
39− bool addSource(const QUrl &source);
39+ bool addItem(const QUrl &source);
40− bool addSources(const QList<QUrl> &sources);
40+ bool addItems(const QList<QUrl> &sources);
41 bool clear();
41 bool clear();
42
42
43Q_SIGNALS:
43Q_SIGNALS:
44− void currentSourceChanged();
44+ void currentItemSourceChanged();
45 void currentIndexChanged();
45 void currentIndexChanged();
46
46
47private:
47private:
tests/plugins/Dash/cardcreator/9.res+8−8
@@ -2,7 +2,7 @@ AbstractButton {
2 id: root;
2 id: root;
3 property var components;
3 property var components;
4 property var cardData;
4 property var cardData;
5− property var artShapeBorderSource: undefined;
5+ property string artShapeStyle: "inset";
6 property real fontScale: 1.0;
6 property real fontScale: 1.0;
7 property var scopeStyle: null;
7 property var scopeStyle: null;
8 property int titleAlignment: Text.AlignLeft;
8 property int titleAlignment: Text.AlignLeft;
@@ -31,7 +31,7 @@ top: parent.top;
31 wrapMode: Text.Wrap;
31 wrapMode: Text.Wrap;
32 maximumLineCount: 2;
32 maximumLineCount: 2;
33 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
33 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
34− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
34+ color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
35 visible: showHeader ;
35 visible: showHeader ;
36 width: undefined;
36 width: undefined;
37 text: root.title;
37 text: root.title;
@@ -52,7 +52,7 @@ top: titleLabel.bottom;
52 maximumLineCount: 1;
52 maximumLineCount: 1;
53 fontSize: "x-small";
53 fontSize: "x-small";
54 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
54 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
55− color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText;
55+ color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
56 visible: titleLabel.visible && titleLabel.text;
56 visible: titleLabel.visible && titleLabel.text;
57 text: cardData && cardData["subtitle"] || "";
57 text: cardData && cardData["subtitle"] || "";
58 font.weight: Font.Light;
58 font.weight: Font.Light;
@@ -74,7 +74,7 @@ CardAudioProgress {
74 width: height;
74 width: height;
75 height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1);
75 height: (root.fixedHeaderHeight > 0 ? root.fixedHeaderHeight : headerHeight) + 2 * units.gu(1);
76 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
76 readonly property url source: (cardData["quickPreviewData"] && cardData["quickPreviewData"]["uri"]) || "";
77− UbuntuShape {
77+ UbuntuShape {
78 anchors.fill: parent;
78 anchors.fill: parent;
79 visible: parent.pressed;
79 visible: parent.pressed;
80 radius: "medium";
80 radius: "medium";
@@ -84,17 +84,17 @@ CardAudioProgress {
84 anchors.fill: parent;
84 anchors.fill: parent;
85 anchors.margins: parent.height > units.gu(5) ? units.gu(2) : units.gu(0);
85 anchors.margins: parent.height > units.gu(5) ? units.gu(2) : units.gu(0);
86 opacity: 0.9;
86 opacity: 0.9;
87− name: DashAudioPlayer.isCurrentSource(parent.source) && DashAudioPlayer.playing ? "media-playback-pause" : "media-playback-start";
87+ name: DashAudioPlayer.playing && AudioUrlComparer.compare(parent.source, DashAudioPlayer.currentSource) ? "media-playback-pause" : "media-playback-start";
88 }
88 }
89 onClicked: {
89 onClicked: {
90− if (DashAudioPlayer.isCurrentSource(source)) {
90+ if (AudioUrlComparer.compare(source, DashAudioPlayer.currentSource)) {
91 if (DashAudioPlayer.playing) {
91 if (DashAudioPlayer.playing) {
92 DashAudioPlayer.pause();
92 DashAudioPlayer.pause();
93 } else {
93 } else {
94 DashAudioPlayer.play();
94 DashAudioPlayer.play();
95 }
95 }
96 } else {
96 } else {
97− var playlist = (cardData["quickPreviewData"] && cardData["quickPreviewData"]["playlist"]) || null;
97+ var playlist = (cardData["quickPreviewData"] && cardData["quickPreviewData"]["playlist"]) || null;
98 DashAudioPlayer.playSource(source, playlist);
98 DashAudioPlayer.playSource(source, playlist);
99 }
99 }
100 }
100 }
@@ -105,7 +105,7 @@ CardAudioProgress {
105 id: touchdown;
105 id: touchdown;
106 objectName: "touchdown";
106 objectName: "touchdown";
107 anchors { fill: root }
107 anchors { fill: root }
108− visible: root.pressed;
108+ visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed;
109 radius: "medium";
109 radius: "medium";
110 borderSource: "radius_pressed.sci"
110 borderSource: "radius_pressed.sci"
111 }
111 }
tests/qmltests/Dash/Previews/tst_PreviewAudioPlayback.qml+2−2
@@ -102,7 +102,7 @@ Rectangle {
102
102
103 function checkPlayerSource(index) {
103 function checkPlayerSource(index) {
104 var modelFilename = previewAudioPlayback.widgetData["tracks"][index]["source"].replace(/^.*[\\\/]/, '');
104 var modelFilename = previewAudioPlayback.widgetData["tracks"][index]["source"].replace(/^.*[\\\/]/, '');
105− var playerFilename = DashAudioPlayer.d.source.toString().replace(/^.*[\\\/]/, '');
105+ var playerFilename = DashAudioPlayer.currentSource.toString().replace(/^.*[\\\/]/, '');
106
106
107 compare(modelFilename, playerFilename, "Player source is not set correctly.");
107 compare(modelFilename, playerFilename, "Player source is not set correctly.");
108 }
108 }
@@ -123,7 +123,7 @@ Rectangle {
123 var track1PlayButton = findChild(track1Item, "playButton");
123 var track1PlayButton = findChild(track1Item, "playButton");
124 var track2PlayButton = findChild(track2Item, "playButton");
124 var track2PlayButton = findChild(track2Item, "playButton");
125
125
126− var audio = DashAudioPlayer.d;
126+ var audio = DashAudioPlayer.audio;
127
127
128 // All progress bars must be hidden in the beginning
128 // All progress bars must be hidden in the beginning
129 compare(track0ProgressBar.visible, false);
129 compare(track0ProgressBar.visible, false);