aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/CommandLineOptions/CommandLineOptions.pro8
-rw-r--r--src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp39
-rw-r--r--src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h25
-rw-r--r--src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp74
-rw-r--r--src/plugins/CommandLineOptions/PlayListOption/playlistoption.h30
-rw-r--r--src/plugins/CommandLineOptions/SeekOption/seekoption.cpp58
-rw-r--r--src/plugins/CommandLineOptions/SeekOption/seekoption.h31
-rw-r--r--src/plugins/CommandLineOptions/StatusOption/statusoption.cpp49
-rw-r--r--src/plugins/CommandLineOptions/StatusOption/statusoption.h25
-rw-r--r--src/qmmpui/commandlinehandler.cpp6
-rw-r--r--src/qmmpui/commandlinehandler.h4
11 files changed, 199 insertions, 150 deletions
diff --git a/src/plugins/CommandLineOptions/CommandLineOptions.pro b/src/plugins/CommandLineOptions/CommandLineOptions.pro
index 805b93744..04abf9c37 100644
--- a/src/plugins/CommandLineOptions/CommandLineOptions.pro
+++ b/src/plugins/CommandLineOptions/CommandLineOptions.pro
@@ -1,7 +1,7 @@
TEMPLATE = subdirs
-#unix:SUBDIRS = IncDecVolumeOption \
-# SeekOption \
-# StatusOption \
-# PlayListOption
+unix:SUBDIRS = IncDecVolumeOption \
+ SeekOption \
+ StatusOption \
+ PlayListOption
#
#win32:SUBDIRS += UninstallOption
diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp
index d901458ca..86997ee6a 100644
--- a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp
+++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2018 by Ilya Kotov *
+ * Copyright (C) 2008-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,36 +24,37 @@
#include <qmmp/soundcore.h>
#include "incdecvolumeoption.h"
-CommandLineProperties IncDecVolumeCommandLineOption::properties() const
+IncDecVolumeCommandLineOption::IncDecVolumeCommandLineOption()
{
- CommandLineProperties properties;
- properties.shortName = "IncDecVolumeCommandLineOption";
- properties.helpString << QString("--volume-inc") + "||" + tr("Increase volume by 5 steps")
- << QString("--volume-dec") + "||" + tr("Decrease volume by 5 steps");
- return properties;
+ registerOption(VOLUME_UP, "--volume-inc", tr("Increase volume by 5 steps"));
+ registerOption(VOLUME_DOWN, "--volume-dec", tr("Decrease volume by 5 steps"));
}
-bool IncDecVolumeCommandLineOption::identify(const QString & str) const
+QString IncDecVolumeCommandLineOption::shortName() const
{
- if(str == QString("--volume-inc") || str == QString("--volume-dec"))
- return true;
+ return "IncDecVolumeCommandLineOption";
+}
- return false;
+QString IncDecVolumeCommandLineOption::translation() const
+{
+ return QLatin1String(":/incdecvolume_plugin_");
}
-QString IncDecVolumeCommandLineOption::executeCommand(const QString& opt_str, const QStringList &args)
+QString IncDecVolumeCommandLineOption::executeCommand(int id, const QStringList &args)
{
Q_UNUSED(args);
- if (opt_str == "--volume-inc")
+ switch (id)
+ {
+ case VOLUME_UP:
SoundCore::instance()->volumeUp();
- else if (opt_str == "--volume-dec")
+ break;
+ case VOLUME_DOWN:
SoundCore::instance()->volumeDown();
+ break;
+ default:
+ break;
+ }
return QString();
}
-
-QString IncDecVolumeCommandLineOption::translation() const
-{
- return QLatin1String(":/incdecvolume_plugin_");
-}
diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h
index 95196944c..172e9b5c6 100644
--- a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h
+++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2018 by Ilya Kotov *
+ * Copyright (C) 2008-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,20 +24,27 @@
#include <QString>
#include <QObject>
#include <QStringList>
-#include <qmmpui/commandlineoption.h>
+#include <qmmpui/commandlinehandler.h>
#include <qmmpui/commandlinemanager.h>
-class IncDecVolumeCommandLineOption : public QObject, public CommandLineOption
+class IncDecVolumeCommandLineOption : public QObject, public CommandLineHandler
{
Q_OBJECT
-Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineOptionInterface.1.0")
-Q_INTERFACES(CommandLineOption)
+Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineHandlerInterface.1.0")
+Q_INTERFACES(CommandLineHandler)
public:
- virtual CommandLineProperties properties() const;
- virtual bool identify(const QString& opt_str) const;
- virtual QString executeCommand(const QString& opt_str, const QStringList &args);
- virtual QString translation() const;
+ IncDecVolumeCommandLineOption();
+ QString shortName() const;
+ QString translation() const;
+ QString executeCommand(int id, const QStringList &args);
+
+private:
+ enum Command
+ {
+ VOLUME_UP = 0,
+ VOLUME_DOWN = 1
+ };
};
#endif
diff --git a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
index cc0ff7cf0..8906e7ea2 100644
--- a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
+++ b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011-2017 by Ilya Kotov *
+ * Copyright (C) 2011-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -28,35 +28,39 @@
#include <qmmpui/commandlinemanager.h>
#include "playlistoption.h"
-CommandLineProperties PlayListOption::properties() const
+PlayListOption::PlayListOption()
{
- CommandLineProperties properties;
- properties.shortName = "PlayListOption";
- properties.helpString << QString("--pl-help") + "||" + tr("Show playlist manipulation commands");
- return properties;
+ registerOption(PL_HELP, "--pl-help", tr("Show playlist manipulation commands"));
+ registerOption(PL_LIST, "--pl-list", tr("List all available playlists"));
+ registerOption(PL_DUMP, "--pl-dump", tr("Show playlist content"), QStringList() << "id");
+ registerOption(PL_PLAY, "--pl-play", tr("Play track <track> in playlist <id>"), QStringList() << "id" << "track");
+ registerOption(PL_CLEAR, "--pl-clear", tr("Clear playlist"), QStringList() << "id");
+ registerOption(PL_REPEATE_TOGGLE, "--pl-repeat-toggle", tr("Toggle playlist repeat"));
+ registerOption(PL_SHUFFLE_TOGGLE, "--pl-shuffle-toggle", tr("Toggle playlist shuffle"));
+ registerOption(PL_STATE, "--pl-state", tr("Show playlist options"));
}
-bool PlayListOption::identify(const QString & str) const
+QString PlayListOption::shortName() const
{
- return str == QString("--pl-help") ||
- str == QString("--pl-list") ||
- str == QString("--pl-dump") ||
- str == QString("--pl-play") ||
- str == QString("--pl-clear") ||
- str == QString("--pl-repeat-toggle") ||
- str == QString("--pl-shuffle-toggle") ||
- str == QString("--pl-state");
+ return QLatin1String("PlayListOption");
}
-QString PlayListOption::executeCommand(const QString& opt_str, const QStringList &args)
+QString PlayListOption::translation() const
+{
+ return QLatin1String(":/playlist_plugin_");
+}
+
+QString PlayListOption::executeCommand(int id, const QStringList &args)
{
- Q_UNUSED(args);
QString out;
PlayListManager *pl_manager = PlayListManager::instance();
MediaPlayer *player = MediaPlayer::instance();
QmmpUiSettings *ui_settings = QmmpUiSettings::instance();
- if(opt_str == "--pl-help")
+
+ switch (id)
+ {
+ case PL_HELP:
{
QStringList list = QStringList()
<< QString("--pl-list") + "||" + tr("List all available playlists")
@@ -70,7 +74,8 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
foreach (QString line, list)
out += CommandLineManager::formatHelpString(line) + "\n";
}
- else if(opt_str == "--pl-list")
+ break;
+ case PL_LIST:
{
QStringList names = pl_manager->playListNames();
for(int i = 0; i < names.count(); ++i)
@@ -81,7 +86,8 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
out += QString("%1. %2\n").arg(i+1).arg(names.at(i));
}
}
- else if(opt_str == "--pl-dump")
+ break;
+ case PL_DUMP:
{
MetaDataFormatter formatter("%p%if(%p&%t, - ,)%t%if(%p,,%if(%t,,%f))%if(%l, - %l,)");
int id = args.isEmpty() ? pl_manager->currentPlayListIndex() : args.at(0).toInt() - 1;
@@ -99,7 +105,8 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
out += "\n";
}
}
- else if(opt_str == "--pl-play")
+ break;
+ case PL_PLAY:
{
if(args.count() > 2 || args.isEmpty())
return tr("Invalid number of arguments") + "\n";
@@ -119,7 +126,8 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
model->setCurrent(track);
player->play();
}
- else if(opt_str == "--pl-clear")
+ break;
+ case PL_CLEAR:
{
int id = args.isEmpty() ? pl_manager->currentPlayListIndex() : args.at(0).toInt() - 1;
PlayListModel *model = pl_manager->playListAt(id);
@@ -127,29 +135,25 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
return tr("Invalid playlist ID") + "\n";
model->clear();
}
- else if(opt_str == "--pl-repeat-toggle")
- {
+ break;
+ case PL_REPEATE_TOGGLE:
ui_settings->setRepeatableList(!ui_settings->isRepeatableList());
- }
- else if(opt_str == "--pl-shuffle-toggle")
- {
+ break;
+ case PL_SHUFFLE_TOGGLE:
ui_settings->setShuffle(!ui_settings->isShuffle());
- }
- else if(opt_str == "--pl-state")
- {
+ break;
+ case PL_STATE:
out += "SHUFFLE: " + boolToText(ui_settings->isShuffle()) + "\n";
out += "REPEAT PLAYLIST: " + boolToText(ui_settings->isRepeatableList()) + "\n";
out += "REPEAT TRACK: " + boolToText(ui_settings->isRepeatableTrack()) + "\n";
out += "NO PLAYLIST ADVANCE: " + boolToText(ui_settings->isNoPlayListAdvance()) + "\n";
+ break;
+ default:
+ ;
}
return out;
}
-QString PlayListOption::translation() const
-{
- return QLatin1String(":/playlist_plugin_");
-}
-
QString PlayListOption::boolToText(bool enabled)
{
return QString(enabled ? "[+]" : "[-]");
diff --git a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h
index 22d67d048..de6d35ae4 100644
--- a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h
+++ b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011-2017 by Ilya Kotov *
+ * Copyright (C) 2011-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,24 +24,36 @@
#include <QString>
#include <QObject>
#include <QStringList>
-#include <qmmpui/commandlineoption.h>
+#include <qmmpui/commandlinehandler.h>
#include <qmmpui/commandlinemanager.h>
/**
@author Ilya Kotov <forkotov02@ya.ru>
*/
-class PlayListOption : public QObject, public CommandLineOption
+class PlayListOption : public QObject, public CommandLineHandler
{
Q_OBJECT
-Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineOptionInterface.1.0")
-Q_INTERFACES(CommandLineOption)
+Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineHandlerInterface.1.0")
+Q_INTERFACES(CommandLineHandler)
public:
- virtual CommandLineProperties properties() const;
- virtual bool identify(const QString& opt_str) const;
- virtual QString executeCommand(const QString& opt_str, const QStringList &args);
- virtual QString translation() const;
+ PlayListOption();
+ QString shortName() const;
+ QString translation() const;
+ QString executeCommand(int id, const QStringList &args);
private:
+ enum Command
+ {
+ PL_HELP = 0,
+ PL_LIST,
+ PL_DUMP,
+ PL_PLAY,
+ PL_CLEAR,
+ PL_REPEATE_TOGGLE,
+ PL_SHUFFLE_TOGGLE,
+ PL_STATE
+ };
+
QString boolToText(bool enabled);
};
diff --git a/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp b/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp
index 7072e6e60..89296c2ea 100644
--- a/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp
+++ b/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2017 by Ilya Kotov *
+ * Copyright (C) 2010-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,24 +24,24 @@
#include <qmmp/soundcore.h>
#include "seekoption.h"
-CommandLineProperties SeekOption::properties() const
+SeekOption::SeekOption()
{
- CommandLineProperties properties;
- properties.shortName = "SeekOption";
- properties.helpString << QString("--seek <time>") + "||" + tr("Seek to position in the current track")
- << QString("--seek-fwd <time>") + "||" + tr("Seek forward")
- << QString("--seek-bwd <time>") + "||" + tr("Seek backwards");
- return properties;
+ registerOption(SEEK, "--seek", tr("Seek to position in the current track"), QStringList() << "time");
+ registerOption(SEEK_FWD, "--seek-fwd", tr("Seek forward"), QStringList() << "time");
+ registerOption(SEEK_BWD, "--seek-bwd", tr("Seek backwards"), QStringList() << "time");
}
-bool SeekOption::identify(const QString &str) const
+QString SeekOption::shortName() const
{
- QStringList opts;
- opts << "--seek" << "--seek-fwd" << "--seek-bwd";
- return opts.contains(str);
+ return QLatin1String("SeekOption");
}
-QString SeekOption::executeCommand(const QString &opt_str, const QStringList &args)
+QString SeekOption::translation() const
+{
+ return QLatin1String(":/seek_plugin_");
+}
+
+QString SeekOption::executeCommand(int id, const QStringList &args)
{
SoundCore *core = SoundCore::instance();
if(core->state() != Qmmp::Playing && core->duration())
@@ -50,33 +50,33 @@ QString SeekOption::executeCommand(const QString &opt_str, const QStringList &ar
return QString();
int seek_pos = -1;
- int elapsed = core->elapsed()/1000;
+ int elapsed = core->elapsed() / 1000;
QRegExp seek_regexp1 ("^([0-9]{1,4})$");
QRegExp seek_regexp2 ("^([0-9]{1,2}):([0-9]{1,2})$");
- if(seek_regexp1.indexIn(args.at(0)) != -1)
+ if(seek_regexp1.indexIn(args.first()) != -1)
seek_pos = seek_regexp1.cap(1).toInt();
- else if(seek_regexp2.indexIn(args.at(0)) != -1)
+ else if(seek_regexp2.indexIn(args.first()) != -1)
seek_pos = seek_regexp2.cap(1).toInt()*60 + seek_regexp2.cap(2).toInt();
- //seek absolute
- if(opt_str == "--seek")
- ;
- else if(opt_str == "--seek-fwd")
- seek_pos += elapsed;
- else if(opt_str == "--seek-bwd")
+ switch (id) {
+ case SEEK: //seek absolute
+ break;
+ case SEEK_FWD:
+ seek_pos += elapsed;
+ break;
+ case SEEK_BWD:
seek_pos = elapsed - seek_pos;
+ break;
+ default:
+ break;
+ }
+
qDebug("SeekOption: position = %d", seek_pos);
if(seek_pos >= 0 && seek_pos < core->duration())
core->seek(seek_pos * 1000);
- else
- return QString();
- return QString();
-}
-QString SeekOption::translation() const
-{
- return QLatin1String(":/seek_plugin_");
+ return QString();
}
diff --git a/src/plugins/CommandLineOptions/SeekOption/seekoption.h b/src/plugins/CommandLineOptions/SeekOption/seekoption.h
index c4bcafaae..104f1b146 100644
--- a/src/plugins/CommandLineOptions/SeekOption/seekoption.h
+++ b/src/plugins/CommandLineOptions/SeekOption/seekoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2017 by Ilya Kotov *
+ * Copyright (C) 2010-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,20 +24,33 @@
#include <QString>
#include <QObject>
#include <QStringList>
-#include <qmmpui/commandlineoption.h>
+#include <qmmpui/commandlinehandler.h>
#include <qmmpui/commandlinemanager.h>
-class SeekOption : public QObject, public CommandLineOption
+class SeekOption : public QObject, public CommandLineHandler
{
Q_OBJECT
-Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineOptionInterface.1.0")
-Q_INTERFACES(CommandLineOption)
+Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineHandlerInterface.1.0")
+Q_INTERFACES(CommandLineHandler)
public:
- virtual CommandLineProperties properties() const;
- virtual bool identify(const QString &opt_str) const;
- virtual QString executeCommand(const QString& opt_str, const QStringList &args);
- virtual QString translation() const;
+ SeekOption();
+ QString shortName() const;
+ QString translation() const;
+ QString executeCommand(int id, const QStringList &args);
+
+ //virtual CommandLineProperties properties() const;
+ //virtual bool identify(const QString &opt_str) const;
+ //virtual QString executeCommand(const QString& opt_str, const QStringList &args);
+ //virtual QString translation() const;
+
+private:
+ enum Command
+ {
+ SEEK = 0,
+ SEEK_FWD,
+ SEEK_BWD
+ };
};
#endif
diff --git a/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp b/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp
index 9bc6d72ec..8c729c5d3 100644
--- a/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp
+++ b/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2017 by Ilya Kotov *
+ * Copyright (C) 2010-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -25,29 +25,32 @@
#include <qmmpui/metadataformatter.h>
#include "statusoption.h"
-CommandLineProperties StatusOption::properties() const
+
+StatusOption::StatusOption()
{
- CommandLineProperties properties;
- properties.shortName = "StatusOption";
- properties.helpString << QString("--status") + "||" + tr("Print playback status")
- << QString("--nowplaying <fmt>") + "||"
- + tr("Print formatted track name (example: qmmp --nowplaying \"%t - %a\")")
- << QString("--nowplaying-syntax") + "||" + tr("Print --nowplaying syntax");
- return properties;
+ registerOption(STATUS, "--status", tr("Print playback status"));
+ registerOption(NOW_PLAYING, "--nowplaying", tr("Print formatted track name (example: qmmp --nowplaying \"%t - %a\")"),
+ QStringList() << "fmt");
+ registerOption(NOW_PLAYING_SYNTAX, "--nowplaying-syntax", tr("Print --nowplaying syntax"));
}
-bool StatusOption::identify(const QString &str) const
+QString StatusOption::shortName() const
{
- QStringList opts;
- opts << "--status" << "--nowplaying" << "--nowplaying-syntax";
- return opts.contains(str);
+ return QLatin1String("StatusOption");
}
-QString StatusOption::executeCommand(const QString &opt_str, const QStringList &args)
+QString StatusOption::translation() const
+{
+ return QLatin1String(":/status_plugin_");
+}
+
+QString StatusOption::executeCommand(int id, const QStringList &args)
{
SoundCore *core = SoundCore::instance();
QString out;
- if(opt_str == "--status")
+ switch (id)
+ {
+ case STATUS:
{
QMap<int, QString> state_names;
state_names.insert(Qmmp::Playing, "[playing]");
@@ -76,14 +79,16 @@ QString StatusOption::executeCommand(const QString &opt_str, const QStringList &
}
out += "\n";
}
- else if(opt_str == "--nowplaying")
+ break;
+ case NOW_PLAYING:
{
QString t = args.join(" ");
MetaDataFormatter formatter(t);
out = formatter.format(core->trackInfo());
out += "\n";
}
- else if(opt_str == "--nowplaying-syntax")
+ break;
+ case NOW_PLAYING_SYNTAX:
{
out += tr("Syntax:") + "\n";
out += tr("%p - artist") + "\n";
@@ -110,12 +115,12 @@ QString StatusOption::executeCommand(const QString &opt_str, const QStringList &
out += tr("%if(A&B&C,D,E) - condition") + "\n";
out += tr("%dir(n) - directory name located on n levels above");
}
- return out;
-}
+ break;
+ default:
+ ;
+ }
-QString StatusOption::translation() const
-{
- return QLatin1String(":/status_plugin_");
+ return out;
}
QString StatusOption::genProgressBar()
diff --git a/src/plugins/CommandLineOptions/StatusOption/statusoption.h b/src/plugins/CommandLineOptions/StatusOption/statusoption.h
index 0dd83c919..85171de3e 100644
--- a/src/plugins/CommandLineOptions/StatusOption/statusoption.h
+++ b/src/plugins/CommandLineOptions/StatusOption/statusoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011-2017 by Ilya Kotov *
+ * Copyright (C) 2011-2019 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,24 +24,31 @@
#include <QString>
#include <QObject>
#include <QStringList>
-#include <qmmpui/commandlineoption.h>
+#include <qmmpui/commandlinehandler.h>
#include <qmmpui/commandlinemanager.h>
/**
@author Ilya Kotov <forkotov02@ya.ru>
*/
-class StatusOption : public QObject, public CommandLineOption
+class StatusOption : public QObject, public CommandLineHandler
{
Q_OBJECT
-Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineOptionInterface.1.0")
-Q_INTERFACES(CommandLineOption)
+Q_PLUGIN_METADATA(IID "org.qmmp.qmmpui.CommandLineHandlerInterface.1.0")
+Q_INTERFACES(CommandLineHandler)
public:
- virtual CommandLineProperties properties() const;
- virtual bool identify(const QString& opt_str) const;
- virtual QString executeCommand(const QString& opt_str, const QStringList &args);
- virtual QString translation() const;
+ StatusOption();
+ QString shortName() const;
+ QString translation() const;
+ QString executeCommand(int id, const QStringList &args);
private:
+ enum Commamnd
+ {
+ STATUS = 0,
+ NOW_PLAYING,
+ NOW_PLAYING_SYNTAX
+ };
+
QString genProgressBar();
};
diff --git a/src/qmmpui/commandlinehandler.cpp b/src/qmmpui/commandlinehandler.cpp
index 05dda3c73..7bf98f069 100644
--- a/src/qmmpui/commandlinehandler.cpp
+++ b/src/qmmpui/commandlinehandler.cpp
@@ -43,12 +43,12 @@ int CommandLineHandler::identify(const QString &name) const
return -1;
}
-void CommandLineHandler::registerOption(int id, const QStringList &names, const QString &helpString)
+void CommandLineHandler::registerOption(int id, const QString &name, const QString &helpString, const QStringList &values)
{
- registerOption(id, names, QStringList(), helpString);
+ registerOption(id, QStringList() << name, helpString, values);
}
-void CommandLineHandler::registerOption(int id, const QStringList &names, const QStringList &values, const QString &helpString)
+void CommandLineHandler::registerOption(int id, const QStringList &names, const QString &helpString, const QStringList &values)
{
CommandLineOption opt;
opt.names = names;
diff --git a/src/qmmpui/commandlinehandler.h b/src/qmmpui/commandlinehandler.h
index 82769a678..238f65afe 100644
--- a/src/qmmpui/commandlinehandler.h
+++ b/src/qmmpui/commandlinehandler.h
@@ -66,8 +66,8 @@ public:
int identify(const QString &name) const;
protected:
- void registerOption(int id, const QStringList &names, const QString &helpString);
- void registerOption(int id, const QStringList &names, const QStringList &values, const QString &helpString);
+ void registerOption(int id, const QString &name, const QString &helpString, const QStringList &values = QStringList());
+ void registerOption(int id, const QStringList &names, const QString &helpString, const QStringList &values = QStringList());
private:
struct CommandLineOption