Commit 3a7cc4fb authored by Michael Pyne's avatar Michael Pyne

DCOP improvements.

* Access the track cover from DCOP (with a shortcut for the currently playing
  file). You can grab both the large and small size covers.
* Provide a currentFile() shortcut accessor.
* Get/set the random play mode.
* The track properties for the currently playing item now are returned when
  the player is merely paused as well.

FEATURE:97264
FEATURE:99903

svn path=/trunk/kdemultimedia/juk/; revision=408270
parent b4ee0a29
......@@ -3,6 +3,7 @@
#include <dcopobject.h>
#include <qstringlist.h>
#include <qpixmap.h>
class CollectionIface : public DCOPObject
{
......@@ -27,6 +28,8 @@ k_dcop:
virtual QStringList playlistTracks(const QString &playlist) const = 0;
virtual QString trackProperty(const QString &file, const QString &property) const = 0;
virtual QPixmap trackCover(const QString &file, const QString &size = "Small") const = 0;
protected:
CollectionIface() : DCOPObject("Collection") {}
virtual void open(const QStringList &files) = 0;
......@@ -44,6 +47,12 @@ k_dcop:
virtual QStringList trackProperties() = 0;
virtual QString trackProperty(const QString &property) const = 0;
virtual QPixmap trackCover(const QString &size = "Small") const = 0;
virtual QString currentFile() const
{
return trackProperty("Path");
}
virtual void play() = 0;
virtual void play(const QString &file) = 0;
......@@ -66,6 +75,21 @@ k_dcop:
virtual int currentTime() const = 0;
virtual int totalTime() const = 0;
/**
* @return The current player mode.
* @see setRandomPlayMode()
*/
virtual QString randomPlayMode() const = 0;
/**
* Sets the player mode to one of normal, random play, or album
* random play, depending on @p randomMode.
* "NoRandom" -> Normal
* "Random" -> Random
* "AlbumRandom" -> Album Random
*/
virtual void setRandomPlayMode(const QString &randomMode) = 0;
protected:
PlayerIface() : DCOPObject("Player") {}
};
......
......@@ -30,6 +30,7 @@
#include "statuslabel.h"
#include "actioncollection.h"
#include "collectionlist.h"
#include "coverinfo.h"
#include "tag.h"
#include "config.h"
......@@ -183,12 +184,25 @@ QStringList PlayerManager::trackProperties()
QString PlayerManager::trackProperty(const QString &property) const
{
if(!playing())
if(!playing() && !paused())
return QString::null;
return m_file.property(property);
}
QPixmap PlayerManager::trackCover(const QString &size) const
{
if(!playing() && !paused())
return QPixmap();
if(size.lower() == "small")
return m_file.coverInfo()->pixmap(CoverInfo::Thumbnail);
if(size.lower() == "large")
return m_file.coverInfo()->pixmap(CoverInfo::FullSize);
return QPixmap();
}
FileHandle PlayerManager::playingFile() const
{
return m_file;
......@@ -625,6 +639,25 @@ void PlayerManager::setup()
connect(m_timer, SIGNAL(timeout()), this, SLOT(slotPollPlay()));
}
QString PlayerManager::randomPlayMode() const
{
if(action<KToggleAction>("randomPlay")->isChecked())
return "Random";
if(action<KToggleAction>("albumRandomPlay")->isChecked())
return "AlbumRandom";
return "NoRandom";
}
void PlayerManager::setRandomPlayMode(const QString &randomMode)
{
if(randomMode.lower() == "random")
action<KToggleAction>("randomPlay")->setChecked(true);
if(randomMode.lower() == "albumrandom")
action<KToggleAction>("albumRandomPlay")->setChecked(true);
if(randomMode.lower() == "norandom")
action<KToggleAction>("disableRandomPlay")->setChecked(true);
}
#include "playermanager.moc"
// vim: set et ts=4 sw=4:
......@@ -51,6 +51,7 @@ public:
QStringList trackProperties();
QString trackProperty(const QString &property) const;
QPixmap trackCover(const QString &size) const;
FileHandle playingFile() const;
QString playingString() const;
......@@ -58,6 +59,8 @@ public:
void setPlaylistInterface(PlaylistInterface *interface);
void setStatusLabel(StatusLabel *label);
QString randomPlayMode() const;
static KSelectAction *playerSelectAction(QObject *parent);
public slots:
......@@ -79,6 +82,8 @@ public slots:
void volumeDown();
void mute();
void setRandomPlayMode(const QString &randomMode);
signals:
void signalPlay();
void signalPause();
......
......@@ -24,6 +24,7 @@
#include "playlistcollection.h"
#include "actioncollection.h"
#include "advancedsearchdialog.h"
#include "coverinfo.h"
#include "searchplaylist.h"
#include "folderplaylist.h"
#include "historyplaylist.h"
......@@ -265,6 +266,23 @@ QString PlaylistCollection::trackProperty(const QString &file, const QString &pr
return item ? item->file().property(property) : QString::null;
}
QPixmap PlaylistCollection::trackCover(const QString &file, const QString &size) const
{
if(size.lower() != "small" && size.lower() != "large")
return QPixmap();
CollectionList *l = CollectionList::instance();
CollectionListItem *item = l->lookup(file);
if(!item)
return QPixmap();
if(size.lower() == "small")
return item->file().coverInfo()->pixmap(CoverInfo::Thumbnail);
else
return item->file().coverInfo()->pixmap(CoverInfo::FullSize);
}
void PlaylistCollection::open(const QStringList &l)
{
QStringList files = l;
......
......@@ -71,6 +71,7 @@ public:
virtual QStringList playlistTracks(const QString &playlist) const;
virtual QString trackProperty(const QString &file, const QString &property) const;
virtual QPixmap trackCover(const QString &file, const QString &size = "Small") const;
virtual void open(const QStringList &files = QStringList());
virtual void open(const QString &playlist, const QStringList &files);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment