OTHER: Make pause button toggle play/pause
This commit is contained in:
parent
4eb7762009
commit
bece172e92
7 changed files with 60 additions and 21 deletions
|
@ -25,6 +25,22 @@
|
||||||
XPlayback::XPlayback (XClient *client)
|
XPlayback::XPlayback (XClient *client)
|
||||||
{
|
{
|
||||||
m_client = 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
|
void
|
||||||
|
@ -43,6 +59,17 @@ XPlayback::pause ()
|
||||||
m_client->playback ()->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
|
void
|
||||||
XPlayback::stop ()
|
XPlayback::stop ()
|
||||||
{
|
{
|
||||||
|
@ -87,3 +114,16 @@ XPlayback::seekMsRel (int milliseconds)
|
||||||
|
|
||||||
m_client->playback ()->seekMsRel (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
class XClient;
|
class XClient;
|
||||||
|
|
||||||
|
#include <xmmsclient/xmmsclient++.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class XPlayback
|
* @class XPlayback
|
||||||
* @brief Thin wrapper around Xmms::Playback providing QT Signals and Slots
|
* @brief Thin wrapper around Xmms::Playback providing QT Signals and Slots
|
||||||
|
@ -35,6 +37,7 @@ class XPlayback : public QObject {
|
||||||
public slots:
|
public slots:
|
||||||
void play ();
|
void play ();
|
||||||
void pause ();
|
void pause ();
|
||||||
|
void toggle_pause ();
|
||||||
void stop ();
|
void stop ();
|
||||||
void prev ();
|
void prev ();
|
||||||
void next ();
|
void next ();
|
||||||
|
@ -42,8 +45,16 @@ class XPlayback : public QObject {
|
||||||
void seekMs (uint milliseconds);
|
void seekMs (uint milliseconds);
|
||||||
void seekMsRel (int 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:
|
private:
|
||||||
XClient *m_client;
|
XClient *m_client;
|
||||||
|
Xmms::Playback::Status m_status;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -69,12 +69,6 @@ XMMSHandler::connect_handler (const char *ipcpath, const bool &sync, QWidget *pa
|
||||||
m_client->playback.broadcastCurrentID () (
|
m_client->playback.broadcastCurrentID () (
|
||||||
bind (&XMMSHandler::playback_current_id, this));
|
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 () (
|
m_client->playback.broadcastVolumeChanged () (
|
||||||
bind (&XMMSHandler::volume_changed, this));
|
bind (&XMMSHandler::volume_changed, this));
|
||||||
|
|
||||||
|
@ -117,13 +111,6 @@ XMMSHandler::requestTrackChange (int pos)
|
||||||
m_client->playback.tickle () ();
|
m_client->playback.tickle () ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
XMMSHandler::playback_status (const Xmms::Playback::Status &status)
|
|
||||||
{
|
|
||||||
emit playbackStatusChanged (status);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
XMMSHandler::playback_current_id (const unsigned int &id)
|
XMMSHandler::playback_current_id (const unsigned int &id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,6 @@ class XMMSHandler : public XClient {
|
||||||
bool playback_current_id (const unsigned int &id);
|
bool playback_current_id (const unsigned int &id);
|
||||||
bool medialib_info (const Xmms::PropDict &propdict);
|
bool medialib_info (const Xmms::PropDict &propdict);
|
||||||
bool medialib_entry_changed (const unsigned int &id);
|
bool medialib_entry_changed (const unsigned int &id);
|
||||||
bool playback_status (const Xmms::Playback::Status &status);
|
|
||||||
bool volume_changed (const Xmms::Dict &levels);
|
bool volume_changed (const Xmms::Dict &levels);
|
||||||
|
|
||||||
void requestMediainfo (uint id);
|
void requestMediainfo (uint id);
|
||||||
|
@ -71,7 +70,6 @@ class XMMSHandler : public XClient {
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void settingsSaved ();
|
void settingsSaved ();
|
||||||
void playbackStatusChanged (Xmms::Playback::Status status);
|
|
||||||
void mediainfoChanged (uint, const Xmms::PropDict &);
|
void mediainfoChanged (uint, const Xmms::PropDict &);
|
||||||
void currentSong (const Xmms::PropDict &);
|
void currentSong (const Xmms::PropDict &);
|
||||||
void playlistChanged (const Xmms::Dict &);
|
void playlistChanged (const Xmms::Dict &);
|
||||||
|
|
|
@ -60,6 +60,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
m_text->move (112, 25);
|
m_text->move (112, 25);
|
||||||
|
|
||||||
m_time = new TimeDisplay(this, 0);
|
m_time = new TimeDisplay(this, 0);
|
||||||
|
// m_time->move (36, 26);
|
||||||
connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime()));
|
connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime()));
|
||||||
|
|
||||||
m_kbps = new SmallNumberDisplay (this, 15);
|
m_kbps = new SmallNumberDisplay (this, 15);
|
||||||
|
@ -101,7 +102,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
|
|
||||||
connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)),
|
connect (&client, SIGNAL(currentSong (const Xmms::PropDict &)),
|
||||||
this, SLOT(setMediainfo (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)));
|
this, SLOT(setStatus(Xmms::Playback::Status)));
|
||||||
connect (client.cache () , SIGNAL (playtime (uint32_t)),
|
connect (client.cache () , SIGNAL (playtime (uint32_t)),
|
||||||
this, SLOT (setPlaytime (uint32_t)));
|
this, SLOT (setPlaytime (uint32_t)));
|
||||||
|
@ -303,7 +304,8 @@ MainDisplay::SetupPushButtons (void)
|
||||||
m_pause = new PixmapButton (this);
|
m_pause = new PixmapButton (this);
|
||||||
m_pause->resize (skin->getSize (Skin::BUTTON_MW_PAUSE));
|
m_pause->resize (skin->getSize (Skin::BUTTON_MW_PAUSE));
|
||||||
m_pause->move (skin->getPos (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 = new PixmapButton (this);
|
||||||
m_stop->resize (skin->getSize (Skin::BUTTON_MW_STOP));
|
m_stop->resize (skin->getSize (Skin::BUTTON_MW_STOP));
|
||||||
|
|
|
@ -59,7 +59,8 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
|
||||||
m_pause = new PixmapButton (this);
|
m_pause = new PixmapButton (this);
|
||||||
m_pause->move(187, 4);
|
m_pause->move(187, 4);
|
||||||
m_pause->resize (10, 7);
|
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 = new PixmapButton (this);
|
||||||
m_stop->move(197, 4);
|
m_stop->move(197, 4);
|
||||||
|
@ -76,7 +77,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
|
||||||
m_eject->resize (9, 7);
|
m_eject->resize (9, 7);
|
||||||
connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen()));
|
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)));
|
this, SLOT(setStatus(Xmms::Playback::Status)));
|
||||||
connect (client.cache (), SIGNAL (playtime (uint32_t)),
|
connect (client.cache (), SIGNAL (playtime (uint32_t)),
|
||||||
this, SLOT ( setPlaytime(uint32_t)));
|
this, SLOT ( setPlaytime(uint32_t)));
|
||||||
|
|
|
@ -140,7 +140,7 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent)
|
||||||
connect (&xmmsh, SIGNAL(settingsSaved()),
|
connect (&xmmsh, SIGNAL(settingsSaved()),
|
||||||
this, SLOT(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)));
|
this, SLOT(handleStatus(Xmms::Playback::Status)));
|
||||||
|
|
||||||
connect (this, SIGNAL (clicked (QModelIndex)),
|
connect (this, SIGNAL (clicked (QModelIndex)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue