summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libQtSpotify/qspotifyplayqueue.cpp59
-rw-r--r--libQtSpotify/qspotifyplayqueue.h12
-rw-r--r--libQtSpotify/qspotifysession.cpp21
-rw-r--r--libQtSpotify/qspotifysession.h8
-rw-r--r--qml/FullControls.qml14
-rw-r--r--qml/images/icon-m-toolbar-repeat-one-white-selected.pngbin0 -> 728 bytes
-rw-r--r--res.qrc1
7 files changed, 76 insertions, 39 deletions
diff --git a/libQtSpotify/qspotifyplayqueue.cpp b/libQtSpotify/qspotifyplayqueue.cpp
index ccf3b1c..46efa5e 100644
--- a/libQtSpotify/qspotifyplayqueue.cpp
+++ b/libQtSpotify/qspotifyplayqueue.cpp
@@ -5,22 +5,22 @@
** Contact: Yoann Lopes (yoann.lopes@nokia.com)
**
** This file is part of the MeeSpot project.
-**
+**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
-**
+**
** Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
-**
+**
** Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
-**
+**
** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its
** contributors may be used to endorse or promote products derived from
** this software without specific prior written permission.
-**
+**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -127,33 +127,38 @@ bool QSpotifyPlayQueue::isExplicitTrack(int index)
return index > m_currentTrackIndex && index <= m_currentTrackIndex + m_explicitTracks.count();
}
-void QSpotifyPlayQueue::playNext()
+void QSpotifyPlayQueue::playNext(bool repeat)
{
- if (m_currentExplicitTrack) {
- m_currentExplicitTrack->release();
- m_currentExplicitTrack = 0;
- }
+ if (repeat) {
+ QSpotifySession::instance()->stop(true);
+ QSpotifySession::instance()->play(m_currentExplicitTrack ? m_currentExplicitTrack : m_implicitTracks->m_currentTrack);
+ } else {
+ if (m_currentExplicitTrack) {
+ m_currentExplicitTrack->release();
+ m_currentExplicitTrack = 0;
+ }
- if (m_explicitTracks.isEmpty()) {
- if (m_implicitTracks) {
- if (!m_implicitTracks->next()) {
- if (m_repeat) {
- m_implicitTracks->play();
- } else {
- QSpotifySession::instance()->stop();
- m_implicitTracks->release();
- m_implicitTracks = 0;
+ if (m_explicitTracks.isEmpty()) {
+ if (m_implicitTracks) {
+ if (!m_implicitTracks->next()) {
+ if (m_repeat) {
+ m_implicitTracks->play();
+ } else {
+ QSpotifySession::instance()->stop();
+ m_implicitTracks->release();
+ m_implicitTracks = 0;
+ }
}
+ } else {
+ QSpotifySession::instance()->stop();
}
} else {
- QSpotifySession::instance()->stop();
+ m_currentExplicitTrack = m_explicitTracks.dequeue();
+ if (m_currentExplicitTrack->isLoaded())
+ onTrackReady();
+ else
+ connect(m_currentExplicitTrack, SIGNAL(isLoadedChanged()), this, SLOT(onTrackReady()));
}
- } else {
- m_currentExplicitTrack = m_explicitTracks.dequeue();
- if (m_currentExplicitTrack->isLoaded())
- onTrackReady();
- else
- connect(m_currentExplicitTrack, SIGNAL(isLoadedChanged()), this, SLOT(onTrackReady()));
}
emit tracksChanged();
@@ -293,6 +298,6 @@ void QSpotifyPlayQueue::tracksUpdated()
void QSpotifyPlayQueue::onOfflineModeChanged()
{
if (m_shuffle && m_implicitTracks)
- m_implicitTracks->setShuffle(true);
+ m_implicitTracks->setShuffle(true);
emit tracksChanged();
}
diff --git a/libQtSpotify/qspotifyplayqueue.h b/libQtSpotify/qspotifyplayqueue.h
index 8365b9f..2c1dca8 100644
--- a/libQtSpotify/qspotifyplayqueue.h
+++ b/libQtSpotify/qspotifyplayqueue.h
@@ -5,22 +5,22 @@
** Contact: Yoann Lopes (yoann.lopes@nokia.com)
**
** This file is part of the MeeSpot project.
-**
+**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
-**
+**
** Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
-**
+**
** Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
-**
+**
** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of its
** contributors may be used to endorse or promote products derived from
** this software without specific prior written permission.
-**
+**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -64,7 +64,7 @@ public:
Q_INVOKABLE bool isExplicitTrack(int index);
- void playNext();
+ void playNext(bool repeat);
void playPrevious();
void clear();
diff --git a/libQtSpotify/qspotifysession.cpp b/libQtSpotify/qspotifysession.cpp
index 1717e13..bee4a5c 100644
--- a/libQtSpotify/qspotifysession.cpp
+++ b/libQtSpotify/qspotifysession.cpp
@@ -463,6 +463,7 @@ QSpotifySession::QSpotifySession()
, m_currentTrackPlayedDuration(0)
, m_shuffle(false)
, m_repeat(false)
+ , m_repeatOne(false)
{
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanUp()));
@@ -555,6 +556,9 @@ void QSpotifySession::init()
bool repeat = settings.value("repeat", false).toBool();
setRepeat(repeat);
+ bool repeatOne = settings.value("repeatOne", false).toBool();
+ setRepeatOne(repeatOne);
+
connect(this, SIGNAL(offlineModeChanged()), m_playQueue, SLOT(onOfflineModeChanged()));
}
}
@@ -612,7 +616,7 @@ bool QSpotifySession::event(QEvent *e)
return true;
} else if (e->type() == QEvent::User + 4) {
// End of track event
- playNext();
+ playNext(m_repeatOne);
e->accept();
return true;
} else if (e->type() == QEvent::User + 5) {
@@ -844,6 +848,17 @@ void QSpotifySession::setRepeat(bool r)
emit repeatChanged();
}
+void QSpotifySession::setRepeatOne(bool r)
+{
+ if (m_repeatOne == r)
+ return;
+
+ QSettings s;
+ s.setValue("repeatOne", r);
+ m_repeatOne = r;
+ emit repeatOneChanged();
+}
+
void QSpotifySession::play(QSpotifyTrack *track)
{
if (track->error() != QSpotifyTrack::Ok || !track->isAvailable() || m_currentTrack == track)
@@ -936,9 +951,9 @@ void QSpotifySession::seek(int offset)
QCoreApplication::postEvent(g_audioWorker, new QEvent(QEvent::Type(QEvent::User + 9)));
}
-void QSpotifySession::playNext()
+void QSpotifySession::playNext(bool repeat)
{
- m_playQueue->playNext();
+ m_playQueue->playNext(repeat);
}
void QSpotifySession::playPrevious()
diff --git a/libQtSpotify/qspotifysession.h b/libQtSpotify/qspotifysession.h
index 0003d71..211a25d 100644
--- a/libQtSpotify/qspotifysession.h
+++ b/libQtSpotify/qspotifysession.h
@@ -72,6 +72,7 @@ class QSpotifySession : public QObject
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
Q_PROPERTY(bool shuffle READ shuffle WRITE setShuffle NOTIFY shuffleChanged)
Q_PROPERTY(bool repeat READ repeat WRITE setRepeat NOTIFY repeatChanged)
+ Q_PROPERTY(bool repeatOne READ repeatOne WRITE setRepeatOne NOTIFY repeatOneChanged)
Q_PROPERTY(bool isOnline READ isOnline NOTIFY isOnlineChanged)
Q_PROPERTY(bool isLoggedIn READ isLoggedIn NOTIFY isLoggedInChanged)
Q_PROPERTY(bool offlineMode READ offlineMode NOTIFY offlineModeChanged)
@@ -182,6 +183,9 @@ public:
bool repeat() const { return m_repeat; }
void setRepeat(bool r);
+ bool repeatOne() const { return m_repeatOne; }
+ void setRepeatOne(bool r);
+
sp_session *spsession() const { return m_sp_session; }
QSpotifyPlayQueue *playQueue() const { return m_playQueue; }
@@ -194,7 +198,7 @@ public Q_SLOTS:
void resume();
void stop(bool dontEmitSignals = false);
void seek(int offset);
- void playNext();
+ void playNext(bool repeat = false);
void playPrevious();
void enqueue(QSpotifyTrack *track);
@@ -213,6 +217,7 @@ Q_SIGNALS:
void currentTrackPositionChanged();
void shuffleChanged();
void repeatChanged();
+ void repeatOneChanged();
void isOnlineChanged();
void playTokenLost();
void connectionRulesChanged();
@@ -284,6 +289,7 @@ private:
int m_currentTrackPlayedDuration;
bool m_shuffle;
bool m_repeat;
+ bool m_repeatOne;
bool m_invertedTheme;
diff --git a/qml/FullControls.qml b/qml/FullControls.qml
index 74b623e..f6789cc 100644
--- a/qml/FullControls.qml
+++ b/qml/FullControls.qml
@@ -475,13 +475,23 @@ Column {
Image {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
- source: spotifySession.repeat ? "images/icon-m-toolbar-repeat-white-selected.png" : ("image://theme/icon-m-toolbar-repeat" + (theme.inverted ? "-white" : ""));
+ source: spotifySession.repeat ? "images/icon-m-toolbar-repeat-white-selected.png"
+ : spotifySession.repeatOne ? "images/icon-m-toolbar-repeat-one-white-selected.png" : ("image://theme/icon-m-toolbar-repeat" + (theme.inverted ? "-white" : ""));
opacity: repeatArea.pressed ? 0.4 : 1.0
MouseArea {
id: repeatArea
anchors.fill: parent
anchors.margins: -15
- onClicked: spotifySession.repeat = !spotifySession.repeat
+ onClicked: {
+ if (spotifySession.repeat) {
+ spotifySession.repeat = false;
+ spotifySession.repeatOne = true;
+ } else if (spotifySession.repeatOne) {
+ spotifySession.repeatOne = false;
+ } else {
+ spotifySession.repeat = true;
+ }
+ }
}
}
}
diff --git a/qml/images/icon-m-toolbar-repeat-one-white-selected.png b/qml/images/icon-m-toolbar-repeat-one-white-selected.png
new file mode 100644
index 0000000..226160d
--- /dev/null
+++ b/qml/images/icon-m-toolbar-repeat-one-white-selected.png
Binary files differ
diff --git a/res.qrc b/res.qrc
index bd249ff..728470b 100644
--- a/res.qrc
+++ b/res.qrc
@@ -75,5 +75,6 @@
<file>qml/images/icon-m-music-video-all-songs-black.png</file>
<file>qml/images/icon-m-toolbar-directory-move-to-black.png</file>
<file>qml/images/icon-m-toolbar-shuffle-selected.png</file>
+ <file>qml/images/icon-m-toolbar-repeat-one-white-selected.png</file>
</qresource>
</RCC>