on xenial help sign in
NotificationAudio: We don't need weird "ifdef" for multimedia 5.6 vs 5.0 roles anymore
9b0e967Albert Astals Cid
qml/Components/NotificationAudio.qml+4−7
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.4
17import QtQuick 2.4
18+import QtMultimedia 5.6
18
19
19Item {
20Item {
20 id: root
21 id: root
@@ -30,13 +31,9 @@ Item {
30
31
31 QtObject {
32 QtObject {
32 id: priv
33 id: priv
33− property var audio: {
34+ property var audio: Audio {
34− try {
35+ source: root.source
35− return Qt.createQmlObject("import QtMultimedia 5.6; Audio { source: root.source; audioRole: MediaPlayer.NotificationRole }", priv)
36+ audioRole: MediaPlayer.NotificationRole
36− } catch(err) {
37− console.log("Upstream audioRole enum not available, falling back to old role name.");
38− return Qt.createQmlObject("import QtMultimedia 5.0; Audio { source: root.source; audioRole: MediaPlayer.alert }", priv)
39− }
40 }
37 }
41 }
38 }
42}
39}
tests/mocks/QtMultimedia/audio.cpp+13
@@ -34,6 +34,19 @@ 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 (m_source != source) {
45+ m_source = source;
46+ Q_EMIT sourceChanged(source);
47+ }
48+}
49+
37Audio::PlaybackState Audio::playbackState() const
50Audio::PlaybackState Audio::playbackState() const
38{
51{
39 return m_playbackState;
52 return m_playbackState;
tests/mocks/QtMultimedia/audio.h+5
@@ -29,6 +29,7 @@ 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)
32 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
33 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
33 Q_PROPERTY(int position READ position NOTIFY positionChanged)
34 Q_PROPERTY(int position READ position NOTIFY positionChanged)
34 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
35 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
@@ -51,6 +52,9 @@ public:
51
52
52 explicit Audio(QObject *parent = 0);
53 explicit Audio(QObject *parent = 0);
53
54
55+ QUrl source() const;
56+ void setSource(const QUrl &source);
57+
54 DeclarativePlaylist *playlist() const;
58 DeclarativePlaylist *playlist() const;
55 void setPlaylist(DeclarativePlaylist *playlist);
59 void setPlaylist(DeclarativePlaylist *playlist);
56
60
@@ -82,6 +86,7 @@ private Q_SLOTS:
82 void timerEvent();
86 void timerEvent();
83
87
84private:
88private:
89+ QUrl m_source;
85 PlaybackState m_playbackState;
90 PlaybackState m_playbackState;
86 QTimer m_timer;
91 QTimer m_timer;
87 int m_position;
92 int m_position;