diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-09-18 16:50:38 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-09-18 16:50:38 +0000 |
| commit | 5717444b38b4f45ad185bbc6ea81cdb141befb8c (patch) | |
| tree | 9ab1fdb4070f7dab49ce5da8b8cf07b79c508eb4 /src/qmmpui | |
| parent | 42aa3971c31736f04f668f84884c05f4dad793bd (diff) | |
| download | qmmp-5717444b38b4f45ad185bbc6ea81cdb141befb8c.tar.gz qmmp-5717444b38b4f45ad185bbc6ea81cdb141befb8c.tar.bz2 qmmp-5717444b38b4f45ad185bbc6ea81cdb141befb8c.zip | |
added --status and --nowplaying command line option (Closes issue 266)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1893 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/commandlinemanager.cpp | 31 | ||||
| -rw-r--r-- | src/qmmpui/commandlinemanager.h | 18 | ||||
| -rw-r--r-- | src/qmmpui/commandlineoption.h | 3 | ||||
| -rw-r--r-- | src/qmmpui/generalhandler.cpp | 8 | ||||
| -rw-r--r-- | src/qmmpui/generalhandler.h | 8 |
5 files changed, 17 insertions, 51 deletions
diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp index 85d822b1e..fde1da6d4 100644 --- a/src/qmmpui/commandlinemanager.cpp +++ b/src/qmmpui/commandlinemanager.cpp @@ -22,10 +22,12 @@ #include <QObject> #include <QList> #include <QApplication> - #include <cstdlib> #include <iostream> #include <qmmp/qmmp.h> +#include <qmmp/soundcore.h> +#include <qmmpui/generalhandler.h> +#include <qmmpui/mediaplayer.h> #include "commandlinemanager.h" using namespace std; @@ -65,31 +67,22 @@ void CommandLineManager::checkOptions() } } -CommandLineManager::CommandLineManager(QObject *parent) - : General(parent) -{ - //m_state = General::Stopped; - m_left = 0; - m_right = 0; - m_time = 0; -} - - -CommandLineManager::~CommandLineManager() -{ -} - -void CommandLineManager::executeCommand(const QString& opt_str, const QStringList &args) +QString CommandLineManager::executeCommand(const QString& opt_str, const QStringList &args) { checkOptions(); + if(!GeneralHandler::instance() || !SoundCore::instance() || !MediaPlayer::instance()) + { + qWarning("CommandLineManager: player objects are not created"); + return QString(); + } foreach(CommandLineOption *opt, *m_options) { if (opt->identify(opt_str)) { - opt->executeCommand(opt_str, args); - return; + return opt->executeCommand(opt_str, args); } } + return QString(); } bool CommandLineManager::hasOption(const QString &opt_str) @@ -107,5 +100,5 @@ void CommandLineManager::printUsage() { checkOptions(); foreach(CommandLineOption *opt, *m_options) - cout << qPrintable(opt->helpString()); + cout << qPrintable(opt->helpString()); } diff --git a/src/qmmpui/commandlinemanager.h b/src/qmmpui/commandlinemanager.h index aa393ac42..eab7c46e1 100644 --- a/src/qmmpui/commandlinemanager.h +++ b/src/qmmpui/commandlinemanager.h @@ -27,25 +27,16 @@ /*! @brief Helper class used for handle command line plugins * @author Ilya Kotov <forkotov02@hotmail.ru> */ -class CommandLineManager : public General +class CommandLineManager { - Q_OBJECT public: /*! - * Constructs a command line manager. - * @param parent QObject parent - */ - CommandLineManager(QObject *parent = 0); - /*! - * Object destructor. - */ - ~CommandLineManager(); - /*! * Executes command \b opt_str * @param opt_str Command line option string * @param args Command arguments + * @return Command output result */ - void executeCommand(const QString& opt_str, const QStringList &args = QStringList()); + static QString executeCommand(const QString& opt_str, const QStringList &args = QStringList()); /*! * Return \b true if command \b opt_str is supported, otherwise returns \b false */ @@ -57,9 +48,6 @@ public: private: static void checkOptions(); - uint m_state; - int m_left, m_right; - int m_time; static QList<CommandLineOption *> *m_options; static QStringList m_files; }; diff --git a/src/qmmpui/commandlineoption.h b/src/qmmpui/commandlineoption.h index edbd40a5c..bd06cf0ee 100644 --- a/src/qmmpui/commandlineoption.h +++ b/src/qmmpui/commandlineoption.h @@ -50,8 +50,9 @@ public: * Parses \b opt_str args(if needed), executes command. * @param opt_str Command to execute * @param args Command arguments + * @return Command output */ - virtual void executeCommand(const QString &opt_str, const QStringList &args) = 0; + virtual QString executeCommand(const QString &opt_str, const QStringList &args) = 0; /*! * Creates translator with parent object \b parent */ diff --git a/src/qmmpui/generalhandler.cpp b/src/qmmpui/generalhandler.cpp index 794156e08..2a163b0c1 100644 --- a/src/qmmpui/generalhandler.cpp +++ b/src/qmmpui/generalhandler.cpp @@ -48,8 +48,6 @@ GeneralHandler::GeneralHandler(QObject *parent) m_generals.insert(factory, general); } } - m_commandLineManager = new CommandLineManager(this); - m_generals.insert(0, m_commandLineManager); } GeneralHandler::~GeneralHandler() @@ -102,12 +100,6 @@ bool GeneralHandler::visibilityControl() return false; } -void GeneralHandler::executeCommand(const QString &opt_str, const QStringList &args) -{ - if (CommandLineManager::hasOption(opt_str)) - m_commandLineManager->executeCommand(opt_str, args); -} - void GeneralHandler::addAction(QAction *action, MenuType type) { connect(action, SIGNAL(destroyed (QObject *)), SLOT(removeAction(QObject*))); diff --git a/src/qmmpui/generalhandler.h b/src/qmmpui/generalhandler.h index 5d2e9cef0..f7dcff968 100644 --- a/src/qmmpui/generalhandler.h +++ b/src/qmmpui/generalhandler.h @@ -32,7 +32,6 @@ class QWidget; class General; class Control; class GeneralFactory; -class CommandLineManager; /*! @brief The GeneralHandler class provides simple api to access general and command line plugins. * @author Ilya Kotov <forkotov02@hotmail.ru> @@ -75,12 +74,6 @@ public: */ bool visibilityControl(); /*! - * Executes command by command line plugins - * @param opt_str Command line option string - * @param args Command arguments - */ - void executeCommand(const QString &opt_str, const QStringList &args = QStringList()); - /*! * Adds the newly created action to the menu with type \b type. * Menu with type \b type should be created first. * @param action Pointer of action. @@ -124,7 +117,6 @@ private slots: private: QMap <GeneralFactory*, General*> m_generals; - CommandLineManager *m_commandLineManager; QList <QAction*> m_toolsActions; QList <QAction*> m_playlistActions; QPointer<QMenu> m_toolsMenu; |
