OTHER: Make pause button toggle play/pause

This commit is contained in:
Thomas Frauendorfer 2008-05-17 04:48:48 +02:00
parent 4eb7762009
commit bece172e92
7 changed files with 60 additions and 21 deletions

View file

@ -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;
}

View file

@ -19,8 +19,10 @@
class XClient;
#include <xmmsclient/xmmsclient++.h>
#include <QObject>
/**
* @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