diff --git a/lib/xplayback.cpp b/lib/xplayback.cpp index 0344750..7c902e4 100644 --- a/lib/xplayback.cpp +++ b/lib/xplayback.cpp @@ -25,6 +25,22 @@ XPlayback::XPlayback (XClient *client) { m_client = client; + + connect (client, SIGNAL (gotConnection (XClient *)), + this, SLOT (on_connect (XClient *))); + + if (client->isConnected ()) { + on_connect (client); + } +} + +void +XPlayback::on_connect (XClient *client) +{ + client->playback ()->getStatus () + (Xmms::bind (&XPlayback::playback_status, this)); + client->playback ()->broadcastStatus () + (Xmms::bind (&XPlayback::playback_status, this)); } void @@ -43,6 +59,17 @@ XPlayback::pause () m_client->playback ()->pause (); } +void +XPlayback::toggle_pause () +{ + if (m_status == XMMS_PLAYBACK_STATUS_PLAY) { + pause (); + } else if (m_status == XMMS_PLAYBACK_STATUS_PAUSE) { + play (); + } + +} + void XPlayback::stop () { @@ -87,3 +114,16 @@ XPlayback::seekMsRel (int milliseconds) m_client->playback ()->seekMsRel (milliseconds); } + +/* + * Status signals + */ +bool +XPlayback::playback_status (const Xmms::Playback::Status &status) +{ + m_status = status; + + emit playbackStatusChanged (status); + return true; +} + diff --git a/lib/xplayback.h b/lib/xplayback.h index 89ec9db..757b576 100644 --- a/lib/xplayback.h +++ b/lib/xplayback.h @@ -19,8 +19,10 @@ class XClient; +#include #include + /** * @class XPlayback * @brief Thin wrapper around Xmms::Playback providing QT Signals and Slots @@ -35,6 +37,7 @@ class XPlayback : public QObject { public slots: void play (); void pause (); + void toggle_pause (); void stop (); void prev (); void next (); @@ -42,8 +45,16 @@ class XPlayback : public QObject { void seekMs (uint milliseconds); void seekMsRel (int milliseconds); + bool playback_status (const Xmms::Playback::Status &status); + + void on_connect (XClient *); + + signals: + void playbackStatusChanged (Xmms::Playback::Status status); + private: XClient *m_client; + Xmms::Playback::Status m_status; }; #endif diff --git a/src/XMMSHandler.cpp b/src/XMMSHandler.cpp index c0cb1f8..3024b3b 100644 --- a/src/XMMSHandler.cpp +++ b/src/XMMSHandler.cpp @@ -69,12 +69,6 @@ XMMSHandler::connect_handler (const char *ipcpath, const bool &sync, QWidget *pa m_client->playback.broadcastCurrentID () ( bind (&XMMSHandler::playback_current_id, this)); - - m_client->playback.getStatus () ( - bind (&XMMSHandler::playback_status, this)); - m_client->playback.broadcastStatus () ( - bind (&XMMSHandler::playback_status, this)); - m_client->playback.broadcastVolumeChanged () ( bind (&XMMSHandler::volume_changed, this)); @@ -117,13 +111,6 @@ XMMSHandler::requestTrackChange (int pos) m_client->playback.tickle () (); } -bool -XMMSHandler::playback_status (const Xmms::Playback::Status &status) -{ - emit playbackStatusChanged (status); - return true; -} - bool XMMSHandler::playback_current_id (const unsigned int &id) { diff --git a/src/XMMSHandler.h b/src/XMMSHandler.h index 891a214..cd87b4a 100644 --- a/src/XMMSHandler.h +++ b/src/XMMSHandler.h @@ -39,7 +39,6 @@ class XMMSHandler : public XClient { bool playback_current_id (const unsigned int &id); bool medialib_info (const Xmms::PropDict &propdict); bool medialib_entry_changed (const unsigned int &id); - bool playback_status (const Xmms::Playback::Status &status); bool volume_changed (const Xmms::Dict &levels); void requestMediainfo (uint id); @@ -71,7 +70,6 @@ class XMMSHandler : public XClient { signals: void settingsSaved (); - void playbackStatusChanged (Xmms::Playback::Status status); void mediainfoChanged (uint, const Xmms::PropDict &); void currentSong (const Xmms::PropDict &); void playlistChanged (const Xmms::Dict &); diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index be7b075..708e846 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -60,6 +60,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) m_text->move (112, 25); m_time = new TimeDisplay(this, 0); +// m_time->move (36, 26); connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime())); m_kbps = new SmallNumberDisplay (this, 15); @@ -101,7 +102,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent) connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)), this, SLOT(setMediainfo (const Xmms::PropDict &))); - connect (&client, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), + connect (client.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), this, SLOT(setStatus(Xmms::Playback::Status))); connect (client.cache () , SIGNAL (playtime (uint32_t)), this, SLOT (setPlaytime (uint32_t))); @@ -177,7 +178,7 @@ MainDisplay::setPlaytime (uint32_t time) uint32_t showtime; if (m_mw->isTimemodeReverse()) { uint maxtime = m_posbar->maximum (); - showtime = -(maxtime - time); + showtime = -(maxtime - time); } else { showtime = time; } @@ -303,7 +304,8 @@ MainDisplay::SetupPushButtons (void) m_pause = new PixmapButton (this); m_pause->resize (skin->getSize (Skin::BUTTON_MW_PAUSE)); m_pause->move (skin->getPos (Skin::BUTTON_MW_PAUSE)); - connect (m_pause, SIGNAL(clicked()), client.xplayback (), SLOT(pause ())); + connect (m_pause, SIGNAL(clicked()), + client.xplayback (), SLOT(toggle_pause ())); m_stop = new PixmapButton (this); m_stop->resize (skin->getSize (Skin::BUTTON_MW_STOP)); diff --git a/src/mainwindow/shadeddisplay.cpp b/src/mainwindow/shadeddisplay.cpp index 5ebabe8..0cbf30f 100644 --- a/src/mainwindow/shadeddisplay.cpp +++ b/src/mainwindow/shadeddisplay.cpp @@ -59,7 +59,8 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent) m_pause = new PixmapButton (this); m_pause->move(187, 4); m_pause->resize (10, 7); - connect (m_pause, SIGNAL(clicked()), client.xplayback (), SLOT(pause ())); + connect (m_pause, SIGNAL(clicked()), + client.xplayback (), SLOT(toggle_pause ())); m_stop = new PixmapButton (this); m_stop->move(197, 4); @@ -76,7 +77,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent) m_eject->resize (9, 7); connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen())); - connect (&client, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), + connect (client.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), this, SLOT(setStatus(Xmms::Playback::Status))); connect (client.cache (), SIGNAL (playtime (uint32_t)), this, SLOT ( setPlaytime(uint32_t))); diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 8653490..7fc99cf 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -140,7 +140,7 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent) connect (&xmmsh, SIGNAL(settingsSaved()), this, SLOT(settingsSaved())); - connect (&xmmsh, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), + connect (xmmsh.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), this, SLOT(handleStatus(Xmms::Playback::Status))); connect (this, SIGNAL (clicked (QModelIndex)),