make PlayerManager a proper singleton

parent 4d044250
......@@ -57,6 +57,7 @@
#include "covermanager.h"
#include "tagtransactionmanager.h"
#include "mpris2/mpris2.h"
#include "playermanager.h"
using namespace ActionCollection;
......@@ -78,7 +79,6 @@ JuK::JuK(QWidget *parent) :
m_splitter(0),
m_statusLabel(0),
m_systemTray(0),
m_player(new PlayerManager),
m_shuttingDown(false)
{
// Expect segfaults if you change this order.
......@@ -144,11 +144,6 @@ JuK* JuK::JuKInstance()
return m_instance;
}
PlayerManager *JuK::playerManager() const
{
return m_player;
}
void JuK::coverDownloaded(const QPixmap &cover)
{
QString event(cover.isNull() ? "coverFailed" : "coverDownloaded");
......@@ -172,14 +167,14 @@ void JuK::setupLayout()
{
new TagTransactionManager(this);
m_splitter = new PlaylistSplitter(m_player, this);
m_splitter = new PlaylistSplitter(this);
setCentralWidget(m_splitter);
m_statusLabel = new StatusLabel(m_splitter->playlist(), statusBar());
connect(CollectionList::instance(), SIGNAL(signalCollectionChanged()),
m_statusLabel, SLOT(updateData()));
statusBar()->addWidget(m_statusLabel, 1);
m_player->setStatusLabel(m_statusLabel);
PlayerManager::instance()->setStatusLabel(m_statusLabel);
m_splitter->setFocus();
}
......@@ -233,25 +228,25 @@ void JuK::setupActions()
act = collection->add<KToggleAction>("crossfadeTracks");
act->setText(i18n("Crossfade Between Tracks"));
connect(act, SIGNAL(triggered(bool)), m_player, SLOT(setCrossfadeEnabled(bool)));
connect(act, SIGNAL(triggered(bool)), PlayerManager::instance(), SLOT(setCrossfadeEnabled(bool)));
act = collection->addAction("play", m_player, SLOT(play()));
act = collection->addAction("play", PlayerManager::instance(), SLOT(play()));
act->setText(i18n("&Play"));
act->setIcon(KIcon( QLatin1String( "media-playback-start" )));
act = collection->addAction("pause", m_player, SLOT(pause()));
act = collection->addAction("pause", PlayerManager::instance(), SLOT(pause()));
act->setText(i18n("P&ause"));
act->setIcon(KIcon( QLatin1String( "media-playback-pause" )));
act = collection->addAction("stop", m_player, SLOT(stop()));
act = collection->addAction("stop", PlayerManager::instance(), SLOT(stop()));
act->setText(i18n("&Stop"));
act->setIcon(KIcon( QLatin1String( "media-playback-stop" )));
act = new KToolBarPopupAction(KIcon( QLatin1String( "media-skip-backward") ), i18nc("previous track", "Previous" ), collection);
collection->addAction("back", act);
connect(act, SIGNAL(triggered(bool)), m_player, SLOT(back()));
connect(act, SIGNAL(triggered(bool)), PlayerManager::instance(), SLOT(back()));
act = collection->addAction("forward", m_player, SLOT(forward()));
act = collection->addAction("forward", PlayerManager::instance(), SLOT(forward()));
act->setText(i18nc("next track", "&Next"));
act->setIcon(KIcon( QLatin1String( "media-skip-forward" )));
......@@ -264,27 +259,27 @@ void JuK::setupActions()
// the following are not visible by default
act = collection->addAction("mute", m_player, SLOT(mute()));
act = collection->addAction("mute", PlayerManager::instance(), SLOT(mute()));
act->setText(i18nc("silence playback", "Mute"));
act->setIcon(KIcon( QLatin1String( "audio-volume-muted" )));
act = collection->addAction("volumeUp", m_player, SLOT(volumeUp()));
act = collection->addAction("volumeUp", PlayerManager::instance(), SLOT(volumeUp()));
act->setText(i18n("Volume Up"));
act->setIcon(KIcon( QLatin1String( "audio-volume-high" )));
act = collection->addAction("volumeDown", m_player, SLOT(volumeDown()));
act = collection->addAction("volumeDown", PlayerManager::instance(), SLOT(volumeDown()));
act->setText(i18n("Volume Down"));
act->setIcon(KIcon( QLatin1String( "audio-volume-low" )));
act = collection->addAction("playPause", m_player, SLOT(playPause()));
act = collection->addAction("playPause", PlayerManager::instance(), SLOT(playPause()));
act->setText(i18n("Play / Pause"));
act->setIcon(KIcon( QLatin1String( "media-playback-start" )));
act = collection->addAction("seekForward", m_player, SLOT(seekForward()));
act = collection->addAction("seekForward", PlayerManager::instance(), SLOT(seekForward()));
act->setText(i18n("Seek Forward"));
act->setIcon(KIcon( QLatin1String( "media-seek-forward" )));
act = collection->addAction("seekBack", m_player, SLOT(seekBack()));
act = collection->addAction("seekBack", PlayerManager::instance(), SLOT(seekBack()));
act->setText(i18n("Seek Back"));
act->setIcon(KIcon( QLatin1String( "media-seek-backward" )));
......@@ -337,7 +332,7 @@ void JuK::setupActions()
void JuK::slotSetupSystemTray()
{
if(m_toggleSystemTrayAction && m_toggleSystemTrayAction->isChecked()) {
m_systemTray = new SystemTray(m_player, this);
m_systemTray = new SystemTray(this);
m_systemTray->setObjectName( QLatin1String("systemTray" ));
m_toggleDockOnCloseAction->setEnabled(true);
......@@ -401,16 +396,16 @@ void JuK::readConfig()
KConfigGroup playerConfig(KGlobal::config(), "Player");
if(m_player)
if(PlayerManager::instance())
{
const int maxVolume = 100;
const int volume = playerConfig.readEntry("Volume", maxVolume);
m_player->setVolume(volume * 0.01);
PlayerManager::instance()->setVolume(volume * 0.01);
if(ActionCollection::action<VolumeAction>("volumeAction")->button())
ActionCollection::action<VolumeAction>("volumeAction")->button()->refresh();
bool enableCrossfade = playerConfig.readEntry("CrossfadeTracks", true);
m_player->setCrossfadeEnabled(enableCrossfade);
PlayerManager::instance()->setCrossfadeEnabled(enableCrossfade);
ActionCollection::action<KAction>("crossfadeTracks")->setChecked(enableCrossfade);
}
......@@ -449,9 +444,9 @@ void JuK::saveConfig()
KConfigGroup playerConfig(KGlobal::config(), "Player");
if (m_player)
if (PlayerManager::instance())
{
playerConfig.writeEntry("Volume", static_cast<int>(100.0 * m_player->volume()));
playerConfig.writeEntry("Volume", static_cast<int>(100.0 * PlayerManager::instance()->volume()));
}
playerConfig.writeEntry("RandomPlay", m_randomPlayAction->isChecked());
......@@ -490,8 +485,8 @@ bool JuK::queryExit()
// Some phonon backends will crash on shutdown unless we've stopped
// playback.
if(m_player->playing())
m_player->stop();
if(PlayerManager::instance()->playing())
PlayerManager::instance()->stop();
// Save configuration data.
m_startDocked = !isVisible();
......@@ -534,7 +529,6 @@ void JuK::slotAboutToQuit()
deleteAndClear(m_systemTray);
deleteAndClear(m_splitter);
deleteAndClear(m_player);
deleteAndClear(m_statusLabel);
// Playlists depend on CoverManager, so CoverManager should shutdown as
......@@ -596,7 +590,7 @@ void JuK::slotCheckAlbumNextAction(bool albumRandomEnabled)
// If album random play is enabled, then enable the Play Next Album action
// unless we're not playing right now.
if(albumRandomEnabled && !m_player->playing())
if(albumRandomEnabled && !PlayerManager::instance()->playing())
albumRandomEnabled = false;
action("forwardAlbum")->setEnabled(albumRandomEnabled);
......
......@@ -18,7 +18,6 @@
#include <kxmlguiwindow.h>
#include "playermanager.h"
#include <QKeyEvent>
......@@ -28,7 +27,6 @@ class KGlobalAccel;
class SliderAction;
class StatusLabel;
class SystemTray;
class PlayerManager;
class PlaylistSplitter;
class JuK : public KXmlGuiWindow
......@@ -41,7 +39,6 @@ public:
static JuK* JuKInstance();
PlayerManager *playerManager() const;
// Use a null cover for failure
void coverDownloaded(const QPixmap &cover);
......@@ -90,7 +87,6 @@ private:
KToggleAction *m_toggleSplashAction;
KToggleAction *m_loopPlaylistAction;
PlayerManager *m_player;
KGlobalAccel *m_accel;
bool m_startDocked;
......
......@@ -44,16 +44,15 @@ static QByteArray idFromPlaylistItem(const PlaylistItem *item)
MediaPlayer2Player::MediaPlayer2Player(QObject* parent)
: QDBusAbstractAdaptor(parent)
, m_player(JuK::JuKInstance()->playerManager())
{
connect(m_player, SIGNAL(signalItemChanged(FileHandle)), this, SLOT(currentSourceChanged()));
connect(m_player, SIGNAL(signalPlay()), this, SLOT(stateUpdated()));
connect(m_player, SIGNAL(signalPause()), this, SLOT(stateUpdated()));
connect(m_player, SIGNAL(signalStop()), this, SLOT(stateUpdated()));
connect(m_player, SIGNAL(totalTimeChanged(int)), this, SLOT(totalTimeChanged()));
connect(m_player, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
connect(m_player, SIGNAL(volumeChanged(float)), this, SLOT(volumeChanged(float)));
connect(m_player, SIGNAL(seeked(int)), this, SLOT(seeked(int)));
connect(PlayerManager::instance(), SIGNAL(signalItemChanged(FileHandle)), this, SLOT(currentSourceChanged()));
connect(PlayerManager::instance(), SIGNAL(signalPlay()), this, SLOT(stateUpdated()));
connect(PlayerManager::instance(), SIGNAL(signalPause()), this, SLOT(stateUpdated()));
connect(PlayerManager::instance(), SIGNAL(signalStop()), this, SLOT(stateUpdated()));
connect(PlayerManager::instance(), SIGNAL(totalTimeChanged(int)), this, SLOT(totalTimeChanged()));
connect(PlayerManager::instance(), SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
connect(PlayerManager::instance(), SIGNAL(volumeChanged(float)), this, SLOT(volumeChanged(float)));
connect(PlayerManager::instance(), SIGNAL(seeked(int)), this, SLOT(seeked(int)));
}
MediaPlayer2Player::~MediaPlayer2Player()
......@@ -67,7 +66,7 @@ bool MediaPlayer2Player::CanGoNext() const
void MediaPlayer2Player::Next() const
{
m_player->forward();
PlayerManager::instance()->forward();
}
bool MediaPlayer2Player::CanGoPrevious() const
......@@ -77,7 +76,7 @@ bool MediaPlayer2Player::CanGoPrevious() const
void MediaPlayer2Player::Previous() const
{
m_player->back();
PlayerManager::instance()->back();
}
bool MediaPlayer2Player::CanPause() const
......@@ -87,17 +86,17 @@ bool MediaPlayer2Player::CanPause() const
void MediaPlayer2Player::Pause() const
{
m_player->pause();
PlayerManager::instance()->pause();
}
void MediaPlayer2Player::PlayPause() const
{
m_player->playPause();
PlayerManager::instance()->playPause();
}
void MediaPlayer2Player::Stop() const
{
m_player->stop();
PlayerManager::instance()->stop();
}
bool MediaPlayer2Player::CanPlay() const
......@@ -107,7 +106,7 @@ bool MediaPlayer2Player::CanPlay() const
void MediaPlayer2Player::Play() const
{
m_player->play();
PlayerManager::instance()->play();
}
void MediaPlayer2Player::SetPosition(const QDBusObjectPath& TrackId, qlonglong Position) const
......@@ -122,7 +121,7 @@ void MediaPlayer2Player::SetPosition(const QDBusObjectPath& TrackId, qlonglong P
QByteArray currentTrackId = idFromPlaylistItem(playingItem);
if (TrackId.path().toLatin1() == currentTrackId) {
m_player->seek(Position / 1000);
PlayerManager::instance()->seek(Position / 1000);
}
}
......@@ -132,16 +131,16 @@ void MediaPlayer2Player::OpenUri(QString Uri) const
// JuK does not yet support KIO
if (url.isLocalFile()) {
m_player->play(url.toLocalFile());
PlayerManager::instance()->play(url.toLocalFile());
}
}
QString MediaPlayer2Player::PlaybackStatus() const
{
if (m_player->playing()) {
if (PlayerManager::instance()->playing()) {
return QLatin1String("Playing");
}
else if (m_player->paused()) {
else if (PlayerManager::instance()->paused()) {
return QLatin1String("Paused");
}
......@@ -226,7 +225,7 @@ QVariantMap MediaPlayer2Player::Metadata() const
double MediaPlayer2Player::Volume() const
{
return m_player->volume();
return PlayerManager::instance()->volume();
}
void MediaPlayer2Player::setVolume(double volume) const
......@@ -235,12 +234,12 @@ void MediaPlayer2Player::setVolume(double volume) const
volume = 0.0;
if (volume > 1.0)
volume = 1.0;
m_player->setVolume(volume);
PlayerManager::instance()->setVolume(volume);
}
qlonglong MediaPlayer2Player::Position() const
{
return m_player->currentTimeMSecs() * 1000;
return PlayerManager::instance()->currentTimeMSecs() * 1000;
}
double MediaPlayer2Player::MinimumRate() const
......@@ -255,12 +254,12 @@ double MediaPlayer2Player::MaximumRate() const
bool MediaPlayer2Player::CanSeek() const
{
return m_player->seekable();
return PlayerManager::instance()->seekable();
}
void MediaPlayer2Player::Seek(qlonglong Offset) const
{
m_player->seek(((m_player->currentTimeMSecs() * 1000) + Offset) / 1000);
PlayerManager::instance()->seek(((PlayerManager::instance()->currentTimeMSecs() * 1000) + Offset) / 1000);
}
bool MediaPlayer2Player::CanControl() const
......
......@@ -100,7 +100,6 @@ class MediaPlayer2Player : public QDBusAbstractAdaptor
void signalPropertiesChange(const QVariantMap& properties) const;
int oldPos;
QPointer<PlayerManager> m_player;
};
#endif
......@@ -53,39 +53,17 @@ using namespace ActionCollection;
enum PlayerManagerStatus { StatusStopped = -1, StatusPaused = 1, StatusPlaying = 2 };
PlayerManager *PlayerManager::s_instance = 0;
////////////////////////////////////////////////////////////////////////////////
// protected members
// public members
////////////////////////////////////////////////////////////////////////////////
PlayerManager::PlayerManager() :
QObject(),
m_playlistInterface(0),
m_statusLabel(0),
m_setup(false),
m_crossfadeTracks(true),
m_curOutputPath(0)
{
// This class is the first thing constructed during program startup, and
// therefore has no access to the widgets needed by the setup() method.
// Since the setup() method will be called indirectly by the player() method
// later, just disable it here. -- mpyne
// setup();
new PlayerAdaptor( this );
m_scrobbler = new Scrobbler(this);
connect(this, SIGNAL(signalItemChanged(FileHandle)), m_scrobbler, SLOT(nowPlaying(FileHandle)));
}
PlayerManager::~PlayerManager()
{
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
bool PlayerManager::playing() const
{
if(!m_setup)
......@@ -193,7 +171,7 @@ QPixmap PlayerManager::trackCover(const QString &size) const
return QPixmap();
}
FileHandle PlayerManager::playingFile() const
const FileHandle &PlayerManager::playingFile() const
{
return m_file;
}
......@@ -601,6 +579,34 @@ void PlayerManager::slotVolumeChanged(qreal volume)
// private members
////////////////////////////////////////////////////////////////////////////////
PlayerManager::PlayerManager() :
QObject(),
m_playlistInterface(0),
m_statusLabel(0),
m_setup(false),
m_crossfadeTracks(true),
m_curOutputPath(0)
{
// This class is the first thing constructed during program startup, and
// therefore has no access to the widgets needed by the setup() method.
// Since the setup() method will be called indirectly by the player() method
// later, just disable it here. -- mpyne
// setup();
new PlayerAdaptor( this );
m_scrobbler = new Scrobbler(this);
connect(this, SIGNAL(signalItemChanged(FileHandle)), m_scrobbler, SLOT(nowPlaying(FileHandle)));
}
PlayerManager* PlayerManager::instance()
{
if (!s_instance)
s_instance = new PlayerManager();
return s_instance;
}
void PlayerManager::setup()
{
// All of the actions required by this class should be listed here.
......
......@@ -52,7 +52,8 @@ class PlayerManager : public QObject
Q_OBJECT
public:
PlayerManager();
static PlayerManager *instance();
virtual ~PlayerManager();
bool playing() const;
......@@ -77,7 +78,7 @@ public:
QString trackProperty(const QString &property) const;
QPixmap trackCover(const QString &size) const;
FileHandle playingFile() const;
const FileHandle &playingFile() const;
QString playingString() const;
KSelectAction* outputDeviceSelectAction();
......@@ -123,6 +124,7 @@ signals:
void signalItemChanged(const FileHandle &file);
private:
PlayerManager();
void setup();
void crossfadeToFile(const FileHandle &newFile);
void stopCrossfade();
......@@ -155,6 +157,8 @@ private:
Phonon::Path m_audioPath[2];
Phonon::MediaObject *m_media[2];
Phonon::VolumeFaderEffect *m_fader[2];
static PlayerManager *s_instance;
};
#endif
......
......@@ -68,11 +68,10 @@ PlaylistCollection *PlaylistCollection::m_instance = 0;
// public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistCollection::PlaylistCollection(PlayerManager* player, PlaylistView* playlistView) :
PlaylistCollection::PlaylistCollection(PlaylistView* playlistView) :
m_playlistView(playlistView),
m_historyPlaylist(0),
m_upcomingPlaylist(0),
m_playerManager(player),
m_importPlaylists(true),
m_searchEnabled(true),
m_playing(false),
......@@ -570,7 +569,7 @@ void PlaylistCollection::setHistoryPlaylistEnabled(bool enable)
m_historyPlaylist->setName(i18n("History"));
setupPlaylist(m_historyPlaylist, "view-history");
QObject::connect(m_playerManager, SIGNAL(signalItemChanged(FileHandle)),
QObject::connect(PlayerManager::instance(), SIGNAL(signalItemChanged(FileHandle)),
historyPlaylist(), SLOT(appendProposedItem(FileHandle)));
}
else {
......
......@@ -36,7 +36,6 @@ class SearchPlaylist;
class DynamicPlaylist;
class PlaylistItem;
class Playlist;
class PlayerManager;
template<class T>
class QList;
......@@ -51,7 +50,7 @@ class PlaylistCollection : public PlaylistInterface
friend class DynamicPlaylist;
public:
PlaylistCollection(PlayerManager* player, PlaylistView* playlistView);
PlaylistCollection(PlaylistView* playlistView);
virtual ~PlaylistCollection();
static PlaylistCollection *instance() { return m_instance; }
......@@ -198,7 +197,6 @@ private:
HistoryPlaylist *m_historyPlaylist;
UpcomingPlaylist *m_upcomingPlaylist;
ActionHandler *m_actionHandler;
PlayerManager *m_playerManager;
KDirLister m_dirLister;
StringHash m_playlistNames;
......
......@@ -77,6 +77,7 @@
#include "coverdialog.h"
#include "tagtransactionmanager.h"
#include "cache.h"
#include "playermanager.h"
using namespace ActionCollection;
......@@ -933,7 +934,7 @@ QVariant Playlist::data(const QModelIndex& index, int role) const
if (column == CoverColumn &&
fileHandle.coverInfo()->coverId() != CoverManager::NoMatch) {
return *globalGenericImage;
} else if (column == 0) {
} else if (column == 0 && PlayerManager::instance()->playingFile() == fileHandle) {
return *globalPlayingImage;
}
}
......
......@@ -62,9 +62,9 @@ using namespace ActionCollection;
// PlaylistBox public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistBox::PlaylistBox(PlayerManager *player, QWidget *parent, PlaylistView *playlistStack) :
PlaylistBox::PlaylistBox(QWidget *parent, PlaylistView *playlistStack) :
K3ListView(parent),
PlaylistCollection(player, playlistStack),
PlaylistCollection(playlistStack),
m_viewModeIndex(0),
m_hasSelection(false),
m_doingMultiSelect(false),
......
......@@ -48,7 +48,7 @@ public:
friend class Item;
PlaylistBox(PlayerManager* player, QWidget* parent, PlaylistView* playlistStack);
PlaylistBox(QWidget* parent, PlaylistView* playlistStack);
virtual ~PlaylistBox();
virtual void raise(Playlist *playlist);
......
......@@ -47,7 +47,7 @@
// public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistSplitter::PlaylistSplitter(PlayerManager *player, QWidget *parent) :
PlaylistSplitter::PlaylistSplitter(QWidget *parent) :
QSplitter(Qt::Horizontal, parent),
m_newVisible(0),
m_playlistBox(0),
......@@ -55,7 +55,6 @@ PlaylistSplitter::PlaylistSplitter(PlayerManager *player, QWidget *parent) :
m_playlistView(0),
m_editor(0),
m_nowPlaying(0),
m_player(player),
m_editorSplitter(0)
{
setObjectName(QLatin1String("playlistSplitter"));
......@@ -194,7 +193,7 @@ void PlaylistSplitter::setupLayout()
// Create the PlaylistBox
m_playlistBox = new PlaylistBox(m_player, this, m_playlistView);
m_playlistBox = new PlaylistBox(this, m_playlistView);
m_playlistBox->setObjectName( QLatin1String( "playlistBox" ) );
connect(m_playlistBox->object(), SIGNAL(signalSelectedItemsChanged()),
......@@ -203,10 +202,10 @@ void PlaylistSplitter::setupLayout()
m_editor, SLOT(slotPlaylistDestroyed(Playlist*)));
connect(m_playlistBox, SIGNAL(startupComplete()), SLOT(slotEnable()));
connect(m_playlistBox, SIGNAL(startFilePlayback(FileHandle)),
m_player, SLOT(play(FileHandle)));
PlayerManager::instance(), SLOT(play(FileHandle)));
connect(m_playlistView, SIGNAL(activated(QModelIndex)), SLOT(slotPlaySong(QModelIndex)));
m_player->setPlaylistInterface(m_playlistBox);
PlayerManager::instance()->setPlaylistInterface(m_playlistBox);
// Let interested parties know we're ready
connect(m_playlistBox, SIGNAL(startupComplete()), SIGNAL(guiReady()));
......@@ -214,7 +213,7 @@ void PlaylistSplitter::setupLayout()
insertWidget(0, m_playlistBox);
m_nowPlaying = new NowPlaying(top, m_playlistBox);
connect(m_player, SIGNAL(signalItemChanged(FileHandle)),
connect(PlayerManager::instance(), SIGNAL(signalItemChanged(FileHandle)),
m_nowPlaying, SLOT(slotUpdate(FileHandle)));
// Create the search widget -- this must be done after the CollectionList is created.
......
......@@ -45,7 +45,7 @@ class PlaylistSplitter : public QSplitter
Q_OBJECT
public:
PlaylistSplitter(PlayerManager *player, QWidget *parent);
PlaylistSplitter(QWidget *parent);
virtual ~PlaylistSplitter();
PlaylistInterface *playlist() const;
......@@ -96,7 +96,6 @@ private:
PlaylistView *m_playlistView;
TagEditor *m_editor;
NowPlaying *m_nowPlaying;
PlayerManager *m_player;
QSplitter *m_editorSplitter;
};
......
......@@ -47,7 +47,7 @@ QWidget *TrackPositionAction::createWidget(QWidget *parent)
Slider *slider = new TimeSlider(parent);
slider->setObjectName(QLatin1String("timeSlider"));
PlayerManager *player = JuK::JuKInstance()->playerManager();
PlayerManager *player = PlayerManager::instance();
connect(player, SIGNAL(tick(int)), slider, SLOT(setValue(int)));
connect(player, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
......
......@@ -151,10 +151,9 @@ void PassiveInfo::positionSelf()
// public methods
////////////////////////////////////////////////////////////////////////////////
SystemTray::SystemTray(PlayerManager *player, QWidget *parent) :
SystemTray::SystemTray(QWidget *parent) :
KStatusNotifierItem(parent),
m_popup(0),
m_player(player),
m_fadeTimer(0),
m_fade(true),
m_hasCompositionManager(false)
......@@ -178,9 +177,9 @@ SystemTray::SystemTray(PlayerManager *player, QWidget *parent) :
KMenu *cm = contextMenu();
connect(m_player, SIGNAL(signalPlay()), this, SLOT(slotPlay()));
connect(m_player, SIGNAL(signalPause()), this, SLOT(slotPause()));
connect(m_player, SIGNAL(signalStop()), this, SLOT(slotStop()));
connect(PlayerManager::instance(), SIGNAL(signalPlay()), this, SLOT(slotPlay()));
connect(PlayerManager::instance(), SIGNAL(signalPause()), this, SLOT(slotPause()));
connect(PlayerManager::instance(), SIGNAL(signalStop()), this, SLOT(slotStop()));
cm->addAction( action("play") );
cm->addAction( action("pause") );
......@@ -212,9 +211,9 @@ SystemTray::SystemTray(PlayerManager *player, QWidget *parent) :
connect(this, SIGNAL(secondaryActivateRequested(QPoint)),
action("playPause"), SLOT(trigger()));
if(m_player->playing())
if(PlayerManager::instance()->playing())
slotPlay();
else if(m_player->paused())
else if(PlayerManager::instance()->paused())
slotPause();
}
......@@ -224,13 +223,13 @@ SystemTray::SystemTray(PlayerManager *player, QWidget *parent) :
void SystemTray::slotPlay()
{
if(!m_player->playing())
if(!PlayerManager::instance()->playing())
return;
QPixmap cover = m_player->playingFile().coverInfo()->pixmap(CoverInfo::FullSize);
QPixmap cover = PlayerManager::instance()->playingFile().coverInfo()->pixmap(CoverInfo::FullSize);
setOverlayIconByName("media-playback-start");
setToolTip(m_player->playingString(), cover);
setToolTip(PlayerManager::instance()->playingString(), cover);
createPopup();
}
......@@ -249,10 +248,10 @@ void SystemTray::slotTogglePopup()
void SystemTray::slotPopupLargeCover()