diff options
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | src/qmmpui/commandlinemanager.cpp | 56 | ||||
| -rw-r--r-- | src/qmmpui/commandlinemanager.h | 12 | ||||
| -rw-r--r-- | src/qmmpui/commandlineoption.h | 3 | ||||
| -rw-r--r-- | src/qmmpui/control.cpp | 76 | ||||
| -rw-r--r-- | src/qmmpui/control.h | 65 | ||||
| -rw-r--r-- | src/qmmpui/general.cpp | 23 | ||||
| -rw-r--r-- | src/qmmpui/general.h | 15 | ||||
| -rw-r--r-- | src/qmmpui/generalfactory.h | 2 | ||||
| -rw-r--r-- | src/qmmpui/generalhandler.cpp | 47 | ||||
| -rw-r--r-- | src/qmmpui/generalhandler.h | 31 | ||||
| -rw-r--r-- | src/qmmpui/playlistparser.cpp | 1 | ||||
| -rw-r--r-- | src/qmmpui/qmmpui.pro | 17 |
13 files changed, 90 insertions, 267 deletions
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 \ |
