From 625b2712c1c9fa46ba43684a24a477aa60d88089 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 18 Mar 2008 11:17:32 +0000 Subject: dbus plugin: more properties and signals git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@277 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/dbuscontrol/dbusadaptor.cpp | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'src/plugins/General/dbuscontrol/dbusadaptor.cpp') diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.cpp b/src/plugins/General/dbuscontrol/dbusadaptor.cpp index 730ab5ee3..7b02caa5d 100644 --- a/src/plugins/General/dbuscontrol/dbusadaptor.cpp +++ b/src/plugins/General/dbuscontrol/dbusadaptor.cpp @@ -20,6 +20,7 @@ #include +#include "dbuscontrol.h" #include "dbusadaptor.h" DBUSAdaptor::DBUSAdaptor(Control *ctrl, QObject *parent) @@ -27,6 +28,7 @@ DBUSAdaptor::DBUSAdaptor(Control *ctrl, QObject *parent) { m_control = ctrl; setAutoRelaySignals(TRUE); + connect(parent, SIGNAL(stateChanged()), SLOT (processState())); } DBUSAdaptor::~DBUSAdaptor() @@ -67,6 +69,56 @@ void DBUSAdaptor::setBalance(int bal) QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right)); } +int DBUSAdaptor::length() +{ + return qobject_cast(parent())->info()->length(); +} + +int DBUSAdaptor::year() +{ + return qobject_cast(parent())->info()->year(); +} + +QString DBUSAdaptor::title() +{ + return qobject_cast(parent())->info()->title(); +} + +QString DBUSAdaptor::artist() +{ + return qobject_cast(parent())->info()->artist(); +} + +QString DBUSAdaptor::album() +{ + return qobject_cast(parent())->info()->album(); +} + +QString DBUSAdaptor::comment() +{ + return qobject_cast(parent())->info()->comment(); +} + +QString DBUSAdaptor::genre() +{ + return qobject_cast(parent())->info()->genre(); +} + +bool DBUSAdaptor::isPlaying() +{ + return qobject_cast(parent())->state() == General::Playing; +} + +bool DBUSAdaptor::isPaused() +{ + return qobject_cast(parent())->state() == General::Paused; +} + +bool DBUSAdaptor::isStopped() +{ + return qobject_cast(parent())->state() == General::Stopped; +} + void DBUSAdaptor::play() { QMetaObject::invokeMethod(m_control, "play"); @@ -92,8 +144,24 @@ void DBUSAdaptor::pause() QMetaObject::invokeMethod(m_control, "pause"); } +void DBUSAdaptor::toggleVisibility() +{ + QMetaObject::invokeMethod(m_control, "toggleVisibility"); +} + void DBUSAdaptor::exit() { QMetaObject::invokeMethod(m_control, "exit"); } +void DBUSAdaptor::processState() +{ + uint state = qobject_cast(parent())->state(); + if(state == General::Playing) + emit started(); + else if(state == General::Stopped) + emit stopped(); + else if(state == General::Paused) + emit paused(); +} + -- cgit v1.2.3-13-gbd6f