diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-24 21:54:59 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-24 21:54:59 +0000 |
| commit | a9946929bc45b96acd171a8137600277d122ccd9 (patch) | |
| tree | 5e675c6dbc697ac80ed3920c768c7fd6c328df0f | |
| parent | 52cdbf3b10333908693f21a7c04ff7983baf923e (diff) | |
| download | qmmp-a9946929bc45b96acd171a8137600277d122ccd9.tar.gz qmmp-a9946929bc45b96acd171a8137600277d122ccd9.tar.bz2 qmmp-a9946929bc45b96acd171a8137600277d122ccd9.zip | |
general api cleanup
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@631 90c681e8-e032-0410-971d-27865f9a5e38
39 files changed, 236 insertions, 473 deletions
diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp index 367a050aa..2b095c386 100644 --- a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp +++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp @@ -46,9 +46,9 @@ const QString IncDecVolumeCommandLineOption::helpString() const } -void IncDecVolumeCommandLineOption::executeCommand(const QString& opt_str, CommandLineManager* clm, Control* ctrl) +void IncDecVolumeCommandLineOption::executeCommand(const QString& opt_str, CommandLineManager* clm) { - int volume = qMax(clm->leftVolume(), clm->rightVolume()); + /*int volume = qMax(clm->leftVolume(), clm->rightVolume()); int balance = 0; int left = clm->leftVolume(); int right = clm->rightVolume(); @@ -62,9 +62,9 @@ void IncDecVolumeCommandLineOption::executeCommand(const QString& opt_str, Comma else if (opt_str == "--volume-dec") { volume = qMax (0, volume - 5); - } - ctrl->setVolume(volume-qMax(balance,0)*volume/100, - volume+qMin(balance,0)*volume/100); + }*/ + /*ctrl->setVolume(volume-qMax(balance,0)*volume/100, + volume+qMin(balance,0)*volume/100);*/ } const QString IncDecVolumeCommandLineOption::name() const diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h index 4a320fc23..8d6b10f7e 100644 --- a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h +++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h @@ -25,7 +25,6 @@ #include <QObject> #include <qmmpui/commandlineoption.h> -#include <qmmpui/control.h> #include <qmmpui/commandlinemanager.h> @@ -37,7 +36,7 @@ public: virtual bool identify(const QString& opt_str)const; virtual const QString name()const; virtual const QString helpString()const; - virtual void executeCommand(const QString& opt_str, CommandLineManager* clm, Control* ctrl); + virtual void executeCommand(const QString& opt_str, CommandLineManager* clm); virtual QTranslator *createTranslator(QObject *parent); }; diff --git a/src/plugins/General/dbuscontrol/CMakeLists.txt b/src/plugins/General/dbuscontrol/CMakeLists.txt index 9126a7964..b646cee80 100644 --- a/src/plugins/General/dbuscontrol/CMakeLists.txt +++ b/src/plugins/General/dbuscontrol/CMakeLists.txt @@ -24,9 +24,10 @@ ADD_DEFINITIONS(-DQT_THREAD) include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# libqmmpui +# libqmmpui & libqmmp include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) SET(libdbuscontrol_SRCS dbuscontrol.cpp @@ -55,6 +56,6 @@ QT4_WRAP_CPP(libdbuscontrol_MOC_SRCS ${libdbuscontrol_MOC_HDRS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ADD_LIBRARY(dbuscontrol SHARED ${libdbuscontrol_SRCS} ${libdbuscontrol_MOC_SRCS} ${libdbuscontrol_RCC_SRCS}) -add_dependencies(dbuscontrol qmmpui) -target_link_libraries(dbuscontrol ${QT_LIBRARIES} -lqmmpui) +add_dependencies(dbuscontrol qmmpui libqmmp) +target_link_libraries(dbuscontrol ${QT_LIBRARIES} -lqmmpui -lqmmp) install(TARGETS dbuscontrol DESTINATION ${LIB_DIR}/qmmp/General) diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.cpp b/src/plugins/General/dbuscontrol/dbusadaptor.cpp index 86a5115ac..415ec35dc 100644 --- a/src/plugins/General/dbuscontrol/dbusadaptor.cpp +++ b/src/plugins/General/dbuscontrol/dbusadaptor.cpp @@ -18,15 +18,12 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <qmmpui/control.h> - #include "dbuscontrol.h" #include "dbusadaptor.h" -DBUSAdaptor::DBUSAdaptor(Control *ctrl, QObject *parent) +DBUSAdaptor::DBUSAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { - m_control = ctrl; setAutoRelaySignals(TRUE); connect(parent, SIGNAL(stateChanged()), SLOT (processState())); connect(parent, SIGNAL(volumeChanged()), SLOT (processVolume())); @@ -52,7 +49,7 @@ void DBUSAdaptor::setVolume(int volume) int bal = balance(); int left = volume-qMax(bal,0)*volume/100; int right = volume+qMin(bal,0)*volume/100; - QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right)); + //QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right)); } int DBUSAdaptor::balance() @@ -72,120 +69,124 @@ void DBUSAdaptor::setBalance(int bal) bal = qMax(bal,-100); int left = volume()-qMax(bal,0)*volume()/100; int right = volume()+qMin(bal,0)*volume()/100; - QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right)); + //QMetaObject::invokeMethod(m_control, "setVolume", Q_ARG(int, left), Q_ARG(int, right)); } int DBUSAdaptor::length() { - return qobject_cast<DBUSControl *>(parent())->info()->length(); + return 0;//qobject_cast<DBUSControl *>(parent())->info()->length(); } int DBUSAdaptor::year() { - return qobject_cast<DBUSControl *>(parent())->info()->year(); + return 0;//qobject_cast<DBUSControl *>(parent())->info()->year(); } QString DBUSAdaptor::title() { - return qobject_cast<DBUSControl *>(parent())->info()->title(); + return QString();//qobject_cast<DBUSControl *>(parent())->info()->title(); } QString DBUSAdaptor::artist() { - return qobject_cast<DBUSControl *>(parent())->info()->artist(); + return QString();//qobject_cast<DBUSControl *>(parent())->info()->artist(); } QString DBUSAdaptor::album() { - return qobject_cast<DBUSControl *>(parent())->info()->album(); + return QString();//qobject_cast<DBUSControl *>(parent())->info()->album(); } QString DBUSAdaptor::comment() { - return qobject_cast<DBUSControl *>(parent())->info()->comment(); + return QString();//qobject_cast<DBUSControl *>(parent())->info()->comment(); } QString DBUSAdaptor::genre() { - return qobject_cast<DBUSControl *>(parent())->info()->genre(); + return QString();//qobject_cast<DBUSControl *>(parent())->info()->genre(); } QString DBUSAdaptor::path() { - return qobject_cast<DBUSControl *>(parent())->info()->path(); + return QString();//qobject_cast<DBUSControl *>(parent())->info()->path(); } bool DBUSAdaptor::isPlaying() { - return qobject_cast<DBUSControl *>(parent())->state() == General::Playing; + //return qobject_cast<DBUSControl *>(parent())->state() == General::Playing; + return FALSE; } bool DBUSAdaptor::isPaused() { - return qobject_cast<DBUSControl *>(parent())->state() == General::Paused; + //return qobject_cast<DBUSControl *>(parent())->state() == General::Paused; + return FALSE; } bool DBUSAdaptor::isStopped() { - return qobject_cast<DBUSControl *>(parent())->state() == General::Stopped; + //return qobject_cast<DBUSControl *>(parent())->state() == General::Stopped; + return FALSE; } int DBUSAdaptor::elapsedTime() { - return qobject_cast<DBUSControl *>(parent())->elapsedTime(); + //return qobject_cast<DBUSControl *>(parent())->elapsedTime(); + return 0; } void DBUSAdaptor::play() { - QMetaObject::invokeMethod(m_control, "play"); + //QMetaObject::invokeMethod(m_control, "play"); } void DBUSAdaptor::stop() { - QMetaObject::invokeMethod(m_control, "stop"); + //QMetaObject::invokeMethod(m_control, "stop"); } void DBUSAdaptor::next() { - QMetaObject::invokeMethod(m_control, "next"); + //QMetaObject::invokeMethod(m_control, "next"); } void DBUSAdaptor::previous() { - QMetaObject::invokeMethod(m_control, "previous"); + //QMetaObject::invokeMethod(m_control, "previous"); } void DBUSAdaptor::pause() { - QMetaObject::invokeMethod(m_control, "pause"); + //QMetaObject::invokeMethod(m_control, "pause"); } void DBUSAdaptor::toggleVisibility() { - QMetaObject::invokeMethod(m_control, "toggleVisibility"); + //QMetaObject::invokeMethod(m_control, "toggleVisibility"); } void DBUSAdaptor::exit() { - QMetaObject::invokeMethod(m_control, "exit"); + //QMetaObject::invokeMethod(m_control, "exit"); } void DBUSAdaptor::seek(int time) { if ((time < 0) || (time > length())) return; - QMetaObject::invokeMethod(m_control, "seek", Q_ARG(int, time)); + //QMetaObject::invokeMethod(m_control, "seek", Q_ARG(int, time)); } void DBUSAdaptor::processState() { - uint state = qobject_cast<DBUSControl *>(parent())->state(); + /*uint state = qobject_cast<DBUSControl *>(parent())->state(); if(state == General::Playing) emit started(); else if(state == General::Stopped) emit stopped(); else if(state == General::Paused) - emit paused(); + emit paused();*/ } void DBUSAdaptor::processVolume() diff --git a/src/plugins/General/dbuscontrol/dbusadaptor.h b/src/plugins/General/dbuscontrol/dbusadaptor.h index a78c78008..5d82db044 100644 --- a/src/plugins/General/dbuscontrol/dbusadaptor.h +++ b/src/plugins/General/dbuscontrol/dbusadaptor.h @@ -48,7 +48,7 @@ Q_PROPERTY(int elapsedTime READ elapsedTime) public: - DBUSAdaptor(Control *ctrl, QObject *parent = 0); + DBUSAdaptor(QObject *parent = 0); ~DBUSAdaptor(); diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.cpp b/src/plugins/General/dbuscontrol/dbuscontrol.cpp index 7a72fff51..bc734ab35 100644 --- a/src/plugins/General/dbuscontrol/dbuscontrol.cpp +++ b/src/plugins/General/dbuscontrol/dbuscontrol.cpp @@ -18,22 +18,20 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <qmmpui/control.h> - #include "dbusadaptor.h" #include "dbuscontrol.h" -DBUSControl::DBUSControl(Control *control, QObject *parent) +DBUSControl::DBUSControl(QObject *parent) : General(parent) { - new DBUSAdaptor(control, this); + new DBUSAdaptor(this); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/Qmmp", this); connection.registerService("org.qmmp.dbus"); m_left = 0; m_right = 0; m_time = 0; - m_state = General::Stopped; + //m_state = General::Stopped; } @@ -41,63 +39,6 @@ DBUSControl::~DBUSControl() { } -void DBUSControl::setState(const uint &state) -{ - m_state = state; - emit stateChanged(); - switch ((uint) state) - { - case General::Playing: - { - break; - } - case General::Paused: - { - break; - } - case General::Stopped: - { - m_song.clear(); - m_time = 0; - break; - } - } -} - -void DBUSControl::setSongInfo(const SongInfo &song) -{ - m_song = song; - emit songChanged(); -} - -void DBUSControl::setVolume(int left, int right) -{ - m_left = left; - m_right = right; - emit volumeChanged(); -} - -void DBUSControl::setTime(int time) -{ - m_time = time; - emit timeChanged(); -} - -SongInfo *DBUSControl::info() -{ - return &m_song; -} - -uint DBUSControl::state() -{ - return m_state; -} - -int DBUSControl::elapsedTime() -{ - return m_time; -} - int DBUSControl::leftVolume() { return m_left; diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.h b/src/plugins/General/dbuscontrol/dbuscontrol.h index 61f369bb7..9079f3e27 100644 --- a/src/plugins/General/dbuscontrol/dbuscontrol.h +++ b/src/plugins/General/dbuscontrol/dbuscontrol.h @@ -34,20 +34,10 @@ class DBUSControl : public General { Q_OBJECT public: - DBUSControl(Control *control, QObject *parent = 0); + DBUSControl(QObject *parent = 0); ~DBUSControl(); - //general api - void setState(const uint& state); - void setSongInfo(const SongInfo &song); - void setVolume(int left, int right); - void setTime(int time); - //helper functions - SongInfo *info(); - uint state(); - int elapsedTime(); - signals: void stateChanged(); void timeChanged(); @@ -61,7 +51,6 @@ public slots: private: DBUSAdaptor *m_adaptor; int m_left, m_right; - SongInfo m_song; uint m_state; int m_time; }; diff --git a/src/plugins/General/dbuscontrol/dbuscontrol.pro b/src/plugins/General/dbuscontrol/dbuscontrol.pro index ec97a6b23..ca13031f8 100644 --- a/src/plugins/General/dbuscontrol/dbuscontrol.pro +++ b/src/plugins/General/dbuscontrol/dbuscontrol.pro @@ -40,5 +40,5 @@ SOURCES += dbuscontrolfactory.cpp \ INCLUDEPATH += ../../../../src -LIBS += -lqmmpui +LIBS += -lqmmpui -lqmmp diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp b/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp index f3ad105b7..88c071d05 100644 --- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp +++ b/src/plugins/General/dbuscontrol/dbuscontrolfactory.cpp @@ -33,9 +33,9 @@ const GeneralProperties DBUSControlFactory::properties() const return properties; } -General *DBUSControlFactory::create(Control *control, QObject *parent) +General *DBUSControlFactory::create(QObject *parent) { - return new DBUSControl(control, parent); + return new DBUSControl(parent); } QDialog *DBUSControlFactory::createConfigDialog(QWidget *) diff --git a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h b/src/plugins/General/dbuscontrol/dbuscontrolfactory.h index bdd53feb1..af06b30bc 100644 --- a/src/plugins/General/dbuscontrol/dbuscontrolfactory.h +++ b/src/plugins/General/dbuscontrol/dbuscontrolfactory.h @@ -27,7 +27,6 @@ #include <QTranslator> #include <qmmpui/general.h> -#include <qmmpui/control.h> #include <qmmpui/generalfactory.h> class DBUSControlFactory : public QObject, public GeneralFactory @@ -36,7 +35,7 @@ Q_OBJECT Q_INTERFACES(GeneralFactory); public: const GeneralProperties properties() const; - General *create(Control *control, QObject *parent); + General *create(QObject *parent); QDialog *createConfigDialog(QWidget *parent); void showAbout(QWidget *parent); QTranslator *createTranslator(QObject *parent); diff --git a/src/plugins/General/notifier/CMakeLists.txt b/src/plugins/General/notifier/CMakeLists.txt index 38f93319c..0b67fd457 100644 --- a/src/plugins/General/notifier/CMakeLists.txt +++ b/src/plugins/General/notifier/CMakeLists.txt @@ -22,9 +22,10 @@ SET(QT_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../../../ ) -# libqmmpui +# libqmmpui & libqmmp include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) SET(libnotifier_SRCS settingsdialog.cpp @@ -61,6 +62,6 @@ QT4_WRAP_UI(libnotifier_UIS_H ${libnotifier_UIS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ADD_LIBRARY(notifier SHARED ${libnotifier_SRCS} ${libnotifier_MOC_SRCS} ${libnotifier_UIS_H} ${libnotifier_RCC_SRCS}) -add_dependencies(notifier qmmpui) +add_dependencies(notifier qmmpui libqmmp) target_link_libraries(notifier ${QT_LIBRARIES} -lqmmpui) install(TARGETS notifier DESTINATION ${LIB_DIR}/qmmp/General) diff --git a/src/plugins/General/notifier/notifier.cpp b/src/plugins/General/notifier/notifier.cpp index 9f6006366..2d4f0e951 100644 --- a/src/plugins/General/notifier/notifier.cpp +++ b/src/plugins/General/notifier/notifier.cpp @@ -22,6 +22,7 @@ #include <QFile> #include <QDir> #include <QSettings> +#include <qmmp/soundcore.h> #include "popupwidget.h" #include "notifier.h" @@ -36,24 +37,27 @@ Notifier::Notifier(QObject *parent) m_desktop = settings.value("desktop_notification", TRUE).toBool(); m_psi = settings.value("psi_notification", FALSE).toBool(); settings.endGroup(); + m_core = SoundCore::instance(); + connect (m_core, SIGNAL(metaDataChanged ()), SLOT(showMetaData())); + connect (m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State))); } Notifier::~Notifier() {} -void Notifier::setState(const uint &state) +void Notifier::setState(Qmmp::State state) { - switch ((uint) state) + switch ((uint) state) { - case General::Playing: + case Qmmp::Playing: { break; } - case General::Paused: + case Qmmp::Paused: { break; } - case General::Stopped: + case Qmmp::Stopped: { QFile::remove(QDir::homePath()+"/.psi/tune"); break; @@ -61,20 +65,20 @@ void Notifier::setState(const uint &state) } } -void Notifier::setSongInfo(const SongInfo &song) +void Notifier::showMetaData() { if (m_popupWidget) delete m_popupWidget; if(m_desktop) - m_popupWidget = new PopupWidget(song); + m_popupWidget = new PopupWidget(); if(!m_psi) return; QFile file(QDir::homePath()+"/.psi/tune"); //psi file file.open(QIODevice::WriteOnly | QIODevice::Text); - file.write(song.title().toUtf8()+"\n"); - file.write(song.artist().toUtf8()+"\n"); - file.write(song.album().toUtf8()+"\n"); - file.write(QString("%1").arg(song.track()).toUtf8()+"\n"); - file.write(QString("%1").arg(song.length()).toUtf8()+"\n"); + file.write(m_core->metaData(Qmmp::TITLE).toUtf8()+"\n"); + file.write(m_core->metaData(Qmmp::ARTIST).toUtf8()+"\n"); + file.write(m_core->metaData(Qmmp::ALBUM).toUtf8()+"\n"); + file.write(m_core->metaData(Qmmp::TRACK).toUtf8()+"\n"); + file.write(QString("%1").arg(m_core->length()).toUtf8()+"\n"); file.close(); } diff --git a/src/plugins/General/notifier/notifier.h b/src/plugins/General/notifier/notifier.h index cc93b2ea5..a6702a26a 100644 --- a/src/plugins/General/notifier/notifier.h +++ b/src/plugins/General/notifier/notifier.h @@ -23,8 +23,10 @@ #include <QPointer> #include <qmmpui/general.h> +#include <qmmp/qmmp.h> class PopupWidget; +class SoundCore; /** @author Ilya Kotov <forkotov02@hotmail.ru> @@ -38,13 +40,15 @@ public: ~Notifier(); - void setState(const uint& state); - void setSongInfo(const SongInfo &song); +private slots: + void showMetaData(); + void setState(Qmmp::State state); private: QPointer<PopupWidget> m_popupWidget; bool m_desktop; bool m_psi; + SoundCore *m_core; }; diff --git a/src/plugins/General/notifier/notifier.pro b/src/plugins/General/notifier/notifier.pro index 5654af7f6..825dc536a 100644 --- a/src/plugins/General/notifier/notifier.pro +++ b/src/plugins/General/notifier/notifier.pro @@ -11,7 +11,7 @@ QMAKE_CLEAN =$$PLUGINS_PREFIX/General/libnotifier.so TEMPLATE = lib QMAKE_LIBDIR += ../../../../lib -LIBS += -lqmmpui +LIBS += -lqmmpui -lqmmp TRANSLATIONS = translations/notifier_plugin_cs.ts \ translations/notifier_plugin_de.ts \ diff --git a/src/plugins/General/notifier/notifierfactory.cpp b/src/plugins/General/notifier/notifierfactory.cpp index 5ef3ac325..fdb9b4463 100644 --- a/src/plugins/General/notifier/notifierfactory.cpp +++ b/src/plugins/General/notifier/notifierfactory.cpp @@ -34,7 +34,7 @@ const GeneralProperties NotifierFactory::properties() const return properties; } -General *NotifierFactory::create(Control*, QObject *parent) +General *NotifierFactory::create(QObject *parent) { return new Notifier(parent); } diff --git a/src/plugins/General/notifier/notifierfactory.h b/src/plugins/General/notifier/notifierfactory.h index 84039ede6..68c22bbde 100644 --- a/src/plugins/General/notifier/notifierfactory.h +++ b/src/plugins/General/notifier/notifierfactory.h @@ -28,7 +28,6 @@ #include <QDialog> #include <qmmpui/general.h> -#include <qmmpui/control.h> #include <qmmpui/generalfactory.h> class NotifierFactory : public QObject, public GeneralFactory @@ -37,7 +36,7 @@ Q_OBJECT Q_INTERFACES(GeneralFactory); public: const GeneralProperties properties() const; - General *create(Control*, QObject *parent); + General *create(QObject *parent); QDialog *createConfigDialog(QWidget *parent); void showAbout(QWidget *parent); QTranslator *createTranslator(QObject *parent); diff --git a/src/plugins/General/notifier/popupwidget.cpp b/src/plugins/General/notifier/popupwidget.cpp index c6ac1fc7a..8e640abdf 100644 --- a/src/plugins/General/notifier/popupwidget.cpp +++ b/src/plugins/General/notifier/popupwidget.cpp @@ -26,21 +26,25 @@ #include <QPalette> #include <QSettings> #include <QDir> +#include <qmmp/soundcore.h> #include "popupwidget.h" -PopupWidget::PopupWidget(const SongInfo &song, QWidget *parent) +PopupWidget::PopupWidget(QWidget *parent) : QFrame(parent) { setWindowFlags(Qt::X11BypassWindowManagerHint | - Qt::WindowStaysOnTopHint); + Qt::WindowStaysOnTopHint | Qt::Window); setFrameStyle(QFrame::Box | QFrame::Plain); - QString title = song.title(); - if(title.isEmpty()) - title = song.path().section('/',-1); - title.append(" "); - if (song.length() > 0) - title.append(QString("(%1:%2)").arg(song.length()/60).arg(song.length()%60, 2, 10, QChar('0'))); + SoundCore *core = SoundCore::instance(); + QString title = core->metaData(Qmmp::TITLE); + if (title.isEmpty()) + title = core->metaData(Qmmp::URL).section('/',-1); + if (core->length() > 0) + { + title.append(" "); + title.append(QString("(%1:%2)").arg(core->length()/60).arg(core->length()%60, 2, 10, QChar('0'))); + } QHBoxLayout *hlayout = new QHBoxLayout(this); QLabel *pixlabel = new QLabel(this); @@ -52,9 +56,9 @@ PopupWidget::PopupWidget(const SongInfo &song, QWidget *parent) QLabel *label1 = new QLabel("<b>"+title+"</b>", this); vlayout->addWidget(label1); - QString info = song.artist(); - if (!info.isEmpty() && !song.album().isEmpty()) - info.append(" - " + song.album()); + QString info = core->metaData(Qmmp::ARTIST); + if (!info.isEmpty() && !core->metaData(Qmmp::ALBUM).isEmpty()) + info.append(" - " + core->metaData(Qmmp::ALBUM)); if (!info.isEmpty()) { QLabel *label2 = new QLabel(info, this); diff --git a/src/plugins/General/notifier/popupwidget.h b/src/plugins/General/notifier/popupwidget.h index 62fd93cec..cfda202a5 100644 --- a/src/plugins/General/notifier/popupwidget.h +++ b/src/plugins/General/notifier/popupwidget.h @@ -23,8 +23,6 @@ #include <QWidget> #include <QFrame> -#include <qmmpui/songinfo.h> - /** @author Ilya Kotov <forkotov02@hotmail.ru> */ @@ -32,7 +30,7 @@ class PopupWidget : public QFrame { Q_OBJECT public: - PopupWidget(const SongInfo &song, QWidget *parent = 0); + PopupWidget(QWidget *parent = 0); ~PopupWidget(); diff --git a/src/plugins/General/statusicon/CMakeLists.txt b/src/plugins/General/statusicon/CMakeLists.txt index 62f49700a..cbaa6b3f2 100644 --- a/src/plugins/General/statusicon/CMakeLists.txt +++ b/src/plugins/General/statusicon/CMakeLists.txt @@ -22,9 +22,10 @@ SET(QT_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../../../ ) -# libqmmpui +# libqmmpui & libqmmp include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) SET(libstatusicon_SRCS settingsdialog.cpp @@ -59,6 +60,6 @@ QT4_WRAP_UI(libstatusicon_UIS_H ${libstatusicon_UIS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ADD_LIBRARY(statusicon SHARED ${libstatusicon_SRCS} ${libstatusicon_MOC_SRCS} ${libstatusicon_UIS_H} ${libstatusicon_RCC_SRCS}) -add_dependencies(statusicon qmmpui) -target_link_libraries(statusicon ${QT_LIBRARIES} -lqmmpui) +add_dependencies(statusicon qmmpui libqmmp) +target_link_libraries(statusicon ${QT_LIBRARIES} -lqmmpui -lqmmp) install(TARGETS statusicon DESTINATION ${LIB_DIR}/qmmp/General) diff --git a/src/plugins/General/statusicon/statusicon.cpp b/src/plugins/General/statusicon/statusicon.cpp index 4946a4ba2..b3e49f2cb 100644 --- a/src/plugins/General/statusicon/statusicon.cpp +++ b/src/plugins/General/statusicon/statusicon.cpp @@ -23,26 +23,27 @@ #include <QDir> #include <QTimer> #include <QCoreApplication> -#include <qmmpui/control.h> + +#include <qmmp/soundcore.h> #include "statusicon.h" -StatusIcon::StatusIcon(Control *control, QObject *parent) +StatusIcon::StatusIcon(QObject *parent) : General(parent) { - m_control = control; m_tray = new QSystemTrayIcon(this); connect(m_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); m_tray->setIcon ( QIcon(":/tray_stop.png")); m_tray->show(); + m_core = SoundCore::instance(); QMenu *menu = new QMenu(qobject_cast<QWidget *>(parent)); - menu->addAction(tr("Play"), control, SLOT(play())); - menu->addAction(tr("Pause"), control, SLOT(pause())); - menu->addAction(tr("Stop"), control, SLOT(stop())); - menu->addAction(tr("Next"), control, SLOT(next())); - menu->addAction(tr("Previous"), control, SLOT(previous())); + menu->addAction(tr("Play"), this, SLOT(play())); + menu->addAction(tr("Pause"), m_core, SLOT(pause())); + menu->addAction(tr("Stop"), m_core, SLOT(stop())); + /*menu->addAction(tr("Next"), control, SLOT(next())); + menu->addAction(tr("Previous"), control, SLOT(previous()));*/ menu->addSeparator(); - menu->addAction(tr("Exit"), control, SLOT(exit())); + menu->addAction(tr("Exit"), this, SLOT(exit())); m_tray->setContextMenu(menu); QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat); @@ -53,30 +54,30 @@ StatusIcon::StatusIcon(Control *control, QObject *parent) m_hideToTray = settings.value("hide_on_close", FALSE).toBool(); settings.endGroup(); m_enabled = FALSE; + connect (m_core, SIGNAL(metaDataChanged ()), SLOT(showMetaData())); + connect (m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State))); QTimer::singleShot(200, this, SLOT(enable())); - m_state = General::Stopped; } StatusIcon::~StatusIcon() {} -void StatusIcon::setState(const uint &state) +void StatusIcon::setState(Qmmp::State state) { - m_state = state; switch ((uint) state) { - case General::Playing: + case Qmmp::Playing: { m_tray->setIcon(QIcon(":/tray_play.png")); break; } - case General::Paused: + case Qmmp::Paused: { m_tray->setIcon(QIcon(":/tray_pause.png")); break; } - case General::Stopped: + case Qmmp::Stopped: { m_tray->setIcon(QIcon(":/tray_stop.png")); break; @@ -84,17 +85,16 @@ void StatusIcon::setState(const uint &state) } } -void StatusIcon::setSongInfo(const SongInfo &song) +void StatusIcon::showMetaData() { - if(!m_enabled) + if (!m_enabled) return; - QString message = song.artist() + " - " +song.title(); - if (song.artist().isEmpty()) - message = song.title(); - if (song.title().isEmpty()) - message = song.artist(); - if (song.artist().isEmpty() && song.title().isEmpty()) - message = song.path().section('/',-1); + QString message = m_core->metaData(Qmmp::ARTIST) + " - " + m_core->metaData(Qmmp::TITLE); + if (message.startsWith (" - ") || message.endsWith (" - ")) + message.remove(" - "); + if (message.isEmpty()) + message = m_core->metaData(Qmmp::URL).section('/',-1); + if (m_showMessage) m_tray->showMessage (tr("Now Playing"), message, QSystemTrayIcon::Information, m_messageDelay); @@ -105,13 +105,13 @@ void StatusIcon::setSongInfo(const SongInfo &song) void StatusIcon::trayActivated(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::Trigger) - m_control->toggleVisibility(); + toggleVisibility(); else if (reason == QSystemTrayIcon::MiddleClick) { - if(m_state == General::Stopped) - m_control->play(); + if (SoundCore::instance()->state() == Qmmp::Stopped) + play(); else - m_control->pause(); + m_core->pause(); } } diff --git a/src/plugins/General/statusicon/statusicon.h b/src/plugins/General/statusicon/statusicon.h index b6d8a3e04..be65500f4 100644 --- a/src/plugins/General/statusicon/statusicon.h +++ b/src/plugins/General/statusicon/statusicon.h @@ -21,10 +21,12 @@ #define STATUSICON_H #include <QSystemTrayIcon> +#include <QMap> #include <qmmpui/general.h> +#include <qmmp/qmmp.h> -class Control; +class SoundCore; /** @author Ilya Kotov <forkotov02@hotmail.ru> @@ -34,14 +36,13 @@ class StatusIcon : public General { Q_OBJECT public: - StatusIcon(Control *control, QObject *parent = 0); + StatusIcon(QObject *parent = 0); ~StatusIcon(); - void setState(const uint& state); - void setSongInfo(const SongInfo &song); - private slots: + void showMetaData(); + void setState(Qmmp::State state); void trayActivated(QSystemTrayIcon::ActivationReason); void enable(); @@ -52,9 +53,7 @@ private: bool m_hideToTray; bool m_enabled; int m_messageDelay; - Control *m_control; - uint m_state; - + SoundCore *m_core; }; #endif diff --git a/src/plugins/General/statusicon/statusicon.pro b/src/plugins/General/statusicon/statusicon.pro index bad3ba7e0..8def7d140 100644 --- a/src/plugins/General/statusicon/statusicon.pro +++ b/src/plugins/General/statusicon/statusicon.pro @@ -11,7 +11,7 @@ QMAKE_CLEAN =$$PLUGINS_PREFIX/General/libstatusicon.so TEMPLATE = lib QMAKE_LIBDIR += ../../../../lib -LIBS += -lqmmpui +LIBS += -lqmmpui -lqmmp TRANSLATIONS = translations/statusicon_plugin_cs.ts \ translations/statusicon_plugin_de.ts \ diff --git a/src/plugins/General/statusicon/statusiconfactory.cpp b/src/plugins/General/statusicon/statusiconfactory.cpp index b25d03ceb..2b56d7c82 100644 --- a/src/plugins/General/statusicon/statusiconfactory.cpp +++ b/src/plugins/General/statusicon/statusiconfactory.cpp @@ -34,9 +34,9 @@ const GeneralProperties StatusIconFactory::properties() const return properties; } -General *StatusIconFactory::create(Control *control, QObject *parent) +General *StatusIconFactory::create(QObject *parent) { - return new StatusIcon(control, parent); + return new StatusIcon(parent); } QDialog *StatusIconFactory::createConfigDialog(QWidget *parent) diff --git a/src/plugins/General/statusicon/statusiconfactory.h b/src/plugins/General/statusicon/statusiconfactory.h index bb75f8843..c2dc76bc5 100644 --- a/src/plugins/General/statusicon/statusiconfactory.h +++ b/src/plugins/General/statusicon/statusiconfactory.h @@ -28,7 +28,6 @@ #include <QDialog> #include <qmmpui/general.h> -#include <qmmpui/control.h> #include <qmmpui/generalfactory.h> class StatusIconFactory : public QObject, public GeneralFactory @@ -37,7 +36,7 @@ Q_OBJECT Q_INTERFACES(GeneralFactory); public: const GeneralProperties properties() const; - General *create(Control *control, QObject *parent); + General *create(QObject *parent); QDialog *createConfigDialog(QWidget *parent); void showAbout(QWidget *parent); QTranslator *createTranslator(QObject *parent); diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt index 10ee1147a..c98b4ee8d 100644 --- a/src/qmmpui/CMakeLists.txt +++ b/src/qmmpui/CMakeLists.txt @@ -25,20 +25,17 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) SET(libqmmpui_SRCS general.cpp generalhandler.cpp - songinfo.cpp - control.cpp playlistparser.cpp commandlinemanager.cpp filedialog.cpp qtfiledialog.cpp + songinfo.cpp ) SET(libqmmpui_MOC_HDRS generalfactory.h general.h generalhandler.h - songinfo.h - control.h playlistparser.h playlistformat.h commandlinemanager.h @@ -46,14 +43,13 @@ SET(libqmmpui_MOC_HDRS filedialog.h filedialogfactory.h qtfiledialog.h + songinfo.h ) SET(libqmmpui_DEVEL_HDRS generalfactory.h general.h generalhandler.h - songinfo.h - control.h playlistparser.h playlistformat.h commandlinemanager.h @@ -71,6 +67,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) ADD_LIBRARY(qmmpui SHARED ${libqmmpui_SRCS} ${libqmmpui_MOC_SRCS} ${libqmmpui_RCC_SRCS}) target_link_libraries(qmmpui ${QT_LIBRARIES}) +add_dependencies(qmmpui libqmmp) SET_TARGET_PROPERTIES(qmmpui PROPERTIES VERSION ${QMMP_VERSION} SOVERSION ${QMMP_SOVERSION}) install(TARGETS qmmpui LIBRARY DESTINATION ${LIB_DIR}) install(FILES ${libqmmpui_DEVEL_HDRS} DESTINATION include/qmmpui) diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp index 5bc7b6d90..9320064f1 100644 --- a/src/qmmpui/commandlinemanager.cpp +++ b/src/qmmpui/commandlinemanager.cpp @@ -26,8 +26,6 @@ #include <cstdlib> #include <iostream> -#include "control.h" - #include "commandlinemanager.h" using namespace std; @@ -71,7 +69,7 @@ static void checkOptions() CommandLineManager::CommandLineManager(QObject *parent) : General(parent) { - m_state = General::Stopped; + //m_state = General::Stopped; m_left = 0; m_right = 0; m_time = 0; @@ -82,62 +80,14 @@ CommandLineManager::~CommandLineManager() { } -void CommandLineManager::setState(const uint& state) -{ - if (state == General::Stopped) - m_time = 0; - m_state = state; -} - -void CommandLineManager::setSongInfo(const SongInfo &song) -{ - m_song = song; -} - -void CommandLineManager::setTime(int time) -{ - m_time = time; -} - -void CommandLineManager::setVolume(int left, int right) -{ - m_left = left; - m_right = right; -} - -uint CommandLineManager::state() -{ - return m_state; -} - -SongInfo *CommandLineManager::info() -{ - return &m_song; -} - -int CommandLineManager::elapsed() -{ - return m_time; -} - -int CommandLineManager::leftVolume() -{ - return m_left; -} - -int CommandLineManager::rightVolume() -{ - return m_right; -} - -void CommandLineManager::executeCommand(const QString& opt_str, Control* ctrl) +void CommandLineManager::executeCommand(const QString& opt_str) { checkOptions(); foreach(CommandLineOption *opt, *options) { if (opt->identify(opt_str)) { - opt->executeCommand(opt_str, this, ctrl); + opt->executeCommand(opt_str, this); return; } } diff --git a/src/qmmpui/commandlinemanager.h b/src/qmmpui/commandlinemanager.h index 4e99ba35d..a6039c7c3 100644 --- a/src/qmmpui/commandlinemanager.h +++ b/src/qmmpui/commandlinemanager.h @@ -36,20 +36,11 @@ public: ~CommandLineManager(); //general - void setState(const uint &state); - void setSongInfo(const SongInfo &song); - void setVolume(int left, int right); - void setTime(int time); //properties - uint state(); - SongInfo *info(); - int elapsed(); - int leftVolume(); - int rightVolume(); //command line - void executeCommand(const QString& opt_str, Control* ctrl); + void executeCommand(const QString& opt_str); //static methods static bool hasOption(const QString &opt_str); @@ -57,7 +48,6 @@ public: private: uint m_state; - SongInfo m_song; int m_left, m_right; int m_time; }; diff --git a/src/qmmpui/commandlineoption.h b/src/qmmpui/commandlineoption.h index bea806bb6..0ea172547 100644 --- a/src/qmmpui/commandlineoption.h +++ b/src/qmmpui/commandlineoption.h @@ -22,7 +22,6 @@ class CommandLineManager; -class Control; class QTranslator; class QString; class QObject; @@ -52,7 +51,7 @@ public: /*! * Parses \b opt_str args(if needed), executes command. */ - virtual void executeCommand(const QString& opt_str, CommandLineManager* clm, Control* ctrl) = 0; + virtual void executeCommand(const QString& opt_str, CommandLineManager* clm) = 0; /*! * Creates translator with parent object \b parent */ diff --git a/src/qmmpui/control.cpp b/src/qmmpui/control.cpp deleted file mode 100644 index 161d23a6c..000000000 --- a/src/qmmpui/control.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Control Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Control Public License for more details. * - * * - * You should have received a copy of the GNU Control Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#include "control.h" - -Control::Control(QObject *parent) - : QObject(parent) -{ -} - - -Control::~Control() -{ -} - -void Control::play() -{ - emit commandCalled(Play); -} - -void Control::pause() -{ - emit commandCalled(Pause); -} - -void Control::stop() -{ - emit commandCalled(Stop); -} - -void Control::next() -{ - emit commandCalled(Next); -} - -void Control::previous() -{ - emit commandCalled(Previous); -} - -void Control::seek(int pos) -{ - emit seekCalled(pos); -} - -void Control::exit() -{ - emit commandCalled(Exit); -} - -void Control::toggleVisibility() -{ - emit commandCalled(ToggleVisibility); -} - -void Control::setVolume(int left, int right) -{ - emit volumeChanged(left, right); -} - diff --git a/src/qmmpui/control.h b/src/qmmpui/control.h deleted file mode 100644 index 14171c84e..000000000 --- a/src/qmmpui/control.h +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef CONTROL_H -#define CONTROL_H - -#include <QObject> - -/** - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ -class Control : public QObject -{ -Q_OBJECT -public: - Control(QObject *parent = 0); - - ~Control(); - - enum Command - { - Play = 0, - Stop, - Pause, - Previous, - Next, - Exit, - ToggleVisibility - }; - -signals: - void commandCalled(uint command); - void seekCalled(int pos); - void volumeChanged(int left, int right); - -public slots: - void play(); - void pause(); - void stop(); - void next(); - void previous(); - void seek(int pos); - void exit(); - void toggleVisibility(); - void setVolume(int left, int right); - -}; - -#endif diff --git a/src/qmmpui/general.cpp b/src/qmmpui/general.cpp index 2347939bf..d0ebe2632 100644 --- a/src/qmmpui/general.cpp +++ b/src/qmmpui/general.cpp @@ -72,15 +72,30 @@ General::General(QObject *parent) General::~General() {} -void General::setState(const uint&) +/*void General::setState(const uint&) {} void General::setSongInfo(const SongInfo &song) {} void General::setTime(int) -{} +{}*/ + +void General::play() +{ + //TODO use AbstractPlayList and SoundCore + emit playCalled(); +} + +void General::exit() +{ + emit exitCalled(); +} +void General::toggleVisibility() +{ + emit toggleVisibilityCalled(); +} QList<GeneralFactory*> *General::generalFactories() { @@ -88,11 +103,11 @@ QList<GeneralFactory*> *General::generalFactories() return factories; } -void General::setVolume(int left, int right) +/*void General::setVolume(int left, int right) { Q_UNUSED(left); Q_UNUSED(right); -} +}*/ QStringList General::generalFiles() { diff --git a/src/qmmpui/general.h b/src/qmmpui/general.h index f35686903..981d32585 100644 --- a/src/qmmpui/general.h +++ b/src/qmmpui/general.h @@ -24,7 +24,6 @@ #include <QStringList> #include <QMap> -#include "songinfo.h" #include "generalfactory.h" class Control; @@ -40,7 +39,7 @@ public: ~General(); - enum State + /*enum State { Playing = 0, Paused, @@ -50,7 +49,7 @@ public: virtual void setState(const uint &state); virtual void setSongInfo(const SongInfo &song); virtual void setVolume(int left, int right); - virtual void setTime(int time); + virtual void setTime(int time);*/ //static methods static QList<GeneralFactory*> *generalFactories(); @@ -58,6 +57,16 @@ public: static void setEnabled(GeneralFactory* factory, bool enable = TRUE); static bool isEnabled(GeneralFactory* factory); +public slots: + void play(); + void exit(); + void toggleVisibility(); + +signals: + void playCalled(); + void exitCalled(); + void toggleVisibilityCalled(); + private: QMap <uint, QString> m_strValues; QMap <uint, uint> m_numValues; diff --git a/src/qmmpui/generalfactory.h b/src/qmmpui/generalfactory.h index 7bcb31520..00acbc2ce 100644 --- a/src/qmmpui/generalfactory.h +++ b/src/qmmpui/generalfactory.h @@ -43,7 +43,7 @@ class GeneralFactory public: virtual ~GeneralFactory() {} virtual const GeneralProperties properties() const = 0; - virtual General *create(Control *control, QObject *parent) = 0; + virtual General *create(QObject *parent) = 0; virtual QDialog *createConfigDialog(QWidget *parent) = 0; virtual void showAbout(QWidget *parent) = 0; virtual QTranslator *createTranslator(QObject *parent) = 0; diff --git a/src/qmmpui/generalhandler.cpp b/src/qmmpui/generalhandler.cpp index 152a310ec..0ad27f914 100644 --- a/src/qmmpui/generalhandler.cpp +++ b/src/qmmpui/generalhandler.cpp @@ -21,7 +21,6 @@ #include <QDialog> #include "general.h" #include "generalfactory.h" -#include "control.h" #include "commandlinemanager.h" #include "generalhandler.h" @@ -32,20 +31,22 @@ GeneralHandler::GeneralHandler(QObject *parent) : QObject(parent) { m_instance = this; - m_left = 0; + /*m_left = 0; m_right = 0; m_time = 0; - m_state = General::Stopped; + m_state = General::Stopped;*/ GeneralFactory* factory; - m_control = new Control(this); - connect(m_control, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint))); + //m_control = new Control(this); + /*connect(m_control, SIGNAL(commandCalled(uint)), SLOT(processCommand(uint))); connect(m_control, SIGNAL(seekCalled(int)), SIGNAL(seekCalled(int))); - connect(m_control, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int))); + connect(m_control, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int)));*/ foreach(factory, *General::generalFactories()) { if (General::isEnabled(factory)) { - General *general = factory->create(m_control, parent); + General *general = factory->create(parent); + connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); + connect (general, SIGNAL(playCalled()), SIGNAL(playCalled())); m_generals.insert(factory, general); } } @@ -56,7 +57,7 @@ GeneralHandler::GeneralHandler(QObject *parent) GeneralHandler::~GeneralHandler() {} -void GeneralHandler::setState(uint state) +/*void GeneralHandler::setState(uint state) { if (state == m_state) return; @@ -72,9 +73,9 @@ void GeneralHandler::setState(uint state) { general->setState(state); } -} +}*/ -void GeneralHandler::setSongInfo(const SongInfo &info) +/*void GeneralHandler::setSongInfo(const SongInfo &info) { if (m_state == General::Stopped) return; @@ -110,7 +111,7 @@ void GeneralHandler::setTime(int time) { general->setTime(time); } -} +}*/ void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable) { @@ -118,15 +119,17 @@ void GeneralHandler::setEnabled(GeneralFactory* factory, bool enable) return; if (enable) { - General *general = factory->create(m_control, parent()); + General *general = factory->create(parent()); + connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); + connect (general, SIGNAL(playCalled()), SIGNAL(playCalled())); m_generals.insert(factory, general); - general->setVolume(m_left, m_right); - if (m_state != General::Stopped) + //general->setVolume(m_left, m_right); + /*if (m_state != General::Stopped) { general->setState(m_state); general->setSongInfo(m_songInfo); general->setTime(m_time); - } + }*/ } else { @@ -145,14 +148,16 @@ void GeneralHandler::showSettings(GeneralFactory* factory, QWidget* parentWidget if (dialog->exec() == QDialog::Accepted && m_generals.keys().contains(factory)) { delete m_generals.value(factory); - General *general = factory->create(m_control, parent()); + General *general = factory->create(parent()); + connect (general, SIGNAL(toggleVisibilityCalled()), SIGNAL(toggleVisibilityCalled())); + connect (general, SIGNAL(playCalled()), SIGNAL(playCalled())); m_generals[factory] = general; - general->setVolume(m_left, m_right); + /*general->setVolume(m_left, m_right); if (m_state != General::Stopped) { general->setState(m_state); general->setSongInfo(m_songInfo); - } + }*/ } dialog->deleteLater(); } @@ -171,7 +176,7 @@ bool GeneralHandler::visibilityControl() void GeneralHandler::executeCommand(const QString &opt_str) { if(CommandLineManager::hasOption(opt_str)) - m_commandLineManager->executeCommand(opt_str, m_control); + m_commandLineManager->executeCommand(opt_str); } GeneralHandler* GeneralHandler::instance() @@ -179,7 +184,7 @@ GeneralHandler* GeneralHandler::instance() return m_instance; } -void GeneralHandler::processCommand(uint command) +/*void GeneralHandler::processCommand(uint command) { switch ((uint) command) { @@ -219,4 +224,4 @@ void GeneralHandler::processCommand(uint command) break; } } -} +}*/ diff --git a/src/qmmpui/generalhandler.h b/src/qmmpui/generalhandler.h index a238e639c..710e817a1 100644 --- a/src/qmmpui/generalhandler.h +++ b/src/qmmpui/generalhandler.h @@ -21,8 +21,7 @@ #define GENERALHANDLER_H #include <QObject> - -#include "songinfo.h" +#include <QMap> class General; class Control; @@ -40,9 +39,9 @@ public: ~GeneralHandler(); - void setSongInfo(const SongInfo &info); + /*void setSongInfo(const SongInfo &info); void setVolume(int left, int right); - void setTime(int time); + void setTime(int time);*/ void setEnabled(GeneralFactory* factory, bool enable); void showSettings(GeneralFactory* factory, QWidget* parentWidget); @@ -52,29 +51,29 @@ public: signals: void playCalled(); - void pauseCalled(); + /*void pauseCalled(); void stopCalled(); void nextCalled(); void previousCalled(); - void seekCalled(int); + void seekCalled(int);*/ void exitCalled(); void toggleVisibilityCalled(); - void volumeChanged(int left, int right); + //void volumeChanged(int left, int right); -public slots: - void setState(uint state); +/*public slots: + void setState(uint state);*/ -private slots: - void processCommand(uint command); +/*private slots: + void processCommand(uint command);*/ private: void connectSignals(General*); QMap <GeneralFactory*, General*> m_generals; - SongInfo m_songInfo; - Control* m_control; - int m_time; - uint m_state; - int m_left, m_right; + //SongInfo m_songInfo; + //Control* m_control; + //int m_time; + //uint m_state; + //int m_left, m_right; CommandLineManager *m_commandLineManager; static GeneralHandler* m_instance; }; diff --git a/src/qmmpui/playlistparser.cpp b/src/qmmpui/playlistparser.cpp index 45f14595d..673abcb0f 100644 --- a/src/qmmpui/playlistparser.cpp +++ b/src/qmmpui/playlistparser.cpp @@ -24,7 +24,6 @@ #include <QApplication> #include "playlistformat.h" -#include "songinfo.h" #include "playlistparser.h" PlaylistParser *PlaylistParser::m_instance = 0; diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index adb97de3e..0f0f40f28 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -6,6 +6,11 @@ warn_on \ qt \ thread +QMAKE_LIBDIR += ../../lib qmmpui +LIBS += -Wl,-rpath,./ +LIBS += -L../../lib -lqmmp +INCLUDEPATH += ../ + TEMPLATE = lib unix : isEmpty(LIB_DIR){ @@ -28,23 +33,21 @@ target.path = $$LIB_DIR HEADERS += general.h \ generalfactory.h \ generalhandler.h \ - songinfo.h \ - control.h \ playlistformat.h \ playlistparser.h \ commandlinemanager.h \ commandlineoption.h \ filedialog.h \ filedialogfactory.h \ - qtfiledialog.h + qtfiledialog.h \ + songinfo.h SOURCES += general.cpp \ generalhandler.cpp \ - songinfo.cpp \ - control.cpp \ playlistparser.cpp \ commandlinemanager.cpp \ filedialog.cpp \ - qtfiledialog.cpp + qtfiledialog.cpp \ + songinfo.cpp DESTDIR = . @@ -62,8 +65,6 @@ TRANSLATIONS = translations/libqmmpui_ru.ts \ devel.files += general.h \ generalfactory.h \ generalhandler.h \ - songinfo.h \ - control.h \ playlistformat.h \ playlistparser.h \ commandlinemanager.h \ diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 80bcea56d..998129114 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -167,6 +167,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) ADD_EXECUTABLE(qmmp ${ui_SRCS} ${ui_MOC_SRCS} ${ui_UIS_H} ${ui_RCC_SRCS}) target_link_libraries(qmmp ${QT_LIBRARIES} libqmmp qmmpui) +add_dependencies(qmmp qmmpui libqmmp) install(TARGETS qmmp DESTINATION bin) install(FILES qmmp.desktop DESTINATION share/applications) install(FILES images/16x16/qmmp.png DESTINATION share/icons/hicolor/16x16/apps) diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index a0d7ac854..a13005ae2 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -142,15 +142,15 @@ MainWindow::MainWindow(const QStringList& args, BuiltinCommandLineOption* option m_generalHandler = new GeneralHandler(this); connect(m_generalHandler, SIGNAL(playCalled()), SLOT(play())); - connect(m_generalHandler, SIGNAL(nextCalled()), SLOT(next())); + /*connect(m_generalHandler, SIGNAL(nextCalled()), SLOT(next())); connect(m_generalHandler, SIGNAL(previousCalled()), SLOT(previous())); connect(m_generalHandler, SIGNAL(stopCalled()), SLOT(stop())); connect(m_generalHandler, SIGNAL(pauseCalled()), SLOT(pause())); - connect(m_generalHandler, SIGNAL(seekCalled(int)), SLOT(seek(int))); + connect(m_generalHandler, SIGNAL(seekCalled(int)), SLOT(seek(int)));*/ connect(m_generalHandler, SIGNAL(toggleVisibilityCalled()), SLOT(toggleVisibility())); connect(m_generalHandler, SIGNAL(exitCalled()), SLOT(close())); - connect(m_generalHandler, SIGNAL(volumeChanged(int, int)), - m_core, SLOT(setVolume(int, int))); + /*connect(m_generalHandler, SIGNAL(volumeChanged(int, int)), + m_core, SLOT(setVolume(int, int)));*/ m_playListModel->readSettings(); char buf[PATH_MAX + 1]; @@ -187,7 +187,7 @@ void MainWindow::play() if (s.isEmpty()) return; if (m_core->play(s)) - m_generalHandler->setTime(0); + /*m_generalHandler->setTime(0)*/; else { //find out the reason why playback failed @@ -316,7 +316,7 @@ void MainWindow::showState(Qmmp::State state) { case Qmmp::Playing: { - m_generalHandler->setState(General::Playing); + //m_generalHandler->setState(General::Playing); /*if (m_playListModel->currentItem()) { SongInfo info = *m_playListModel->currentItem(); @@ -330,12 +330,12 @@ void MainWindow::showState(Qmmp::State state) } case Qmmp::Paused: { - m_generalHandler->setState(General::Paused); + //m_generalHandler->setState(General::Paused); break; } case Qmmp::Stopped: { - m_generalHandler->setState(General::Stopped); + //m_generalHandler->setState(General::Stopped); m_playlist->setTime(-1); m_titlebar->setTime(-1); break; @@ -367,7 +367,7 @@ void MainWindow::showMetaData() info.setValue(SongInfo::STREAM, !QFile::exists(m_playlist->currentItem()->path())); info.setValue(SongInfo::PATH, m_playlist->currentItem()->path()); info.setValue(SongInfo::LENGTH, m_playlist->currentItem()->length()); - m_generalHandler->setSongInfo(info); + //m_generalHandler->setSongInfo(info); m_playlist->currentItem()->updateMetaData(m_core->metaData()); m_playlist->listWidget()->updateList(); } @@ -381,7 +381,7 @@ void MainWindow::changeTitle(const QString &title) SongInfo info; info.setValue(SongInfo::TITLE, title); info.setValue(SongInfo::STREAM, TRUE); - m_generalHandler->setSongInfo(info); + //m_generalHandler->setSongInfo(info); } void MainWindow::closeEvent ( QCloseEvent *) |
