aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-12-29 21:07:21 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-12-29 21:07:21 +0000
commit3e2d3721988640845beeba150e01ff7f516f60b3 (patch)
tree64cb42329070a9d52c4ff04cc3013fc1171a74f7 /src/qmmpui
parenta13a898395740f6663dcba0ba24ff4e46d42d29c (diff)
downloadqmmp-3e2d3721988640845beeba150e01ff7f516f60b3.tar.gz
qmmp-3e2d3721988640845beeba150e01ff7f516f60b3.tar.bz2
qmmp-3e2d3721988640845beeba150e01ff7f516f60b3.zip
fixed --pl-help processing
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8535 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
-rw-r--r--src/qmmpui/commandlinemanager.cpp34
-rw-r--r--src/qmmpui/commandlinemanager.h2
2 files changed, 23 insertions, 13 deletions
diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp
index d1f28b1ba..295e78cdb 100644
--- a/src/qmmpui/commandlinemanager.cpp
+++ b/src/qmmpui/commandlinemanager.cpp
@@ -32,8 +32,6 @@
#include "mediaplayer.h"
#include "commandlinemanager.h"
-using namespace std;
-
QList<CommandLineHandler *> *CommandLineManager::m_options = 0;
QHash<CommandLineHandler*, QString> *CommandLineManager::m_files = 0;
@@ -76,29 +74,41 @@ void CommandLineManager::checkOptions()
QString CommandLineManager::executeCommand(const QString &name, const QStringList &args)
{
checkOptions();
- if(!UiHelper::instance() || !SoundCore::instance() || !MediaPlayer::instance())
- {
- qWarning("CommandLineManager: player objects are not created");
- return QString();
- }
+ bool started = UiHelper::instance() && SoundCore::instance() && MediaPlayer::instance();
+
foreach(CommandLineHandler *opt, *m_options)
{
int id = opt->identify(name);
- if(id >= 0)
- {
+ if(id < 0)
+ continue;
+
+ if(started || (opt->flags(id) & CommandLineHandler::NO_START))
return opt->executeCommand(id, args);
+ else
+ {
+ qWarning("CommandLineManager: player objects are not created");
+ return QString();
}
+
+
}
return QString();
}
-bool CommandLineManager::hasOption(const QString &opt_str)
+bool CommandLineManager::hasOption(const QString &opt_str, CommandLineHandler::OptionFlags *flags)
{
checkOptions();
+ if(flags)
+ *flags = 0;
foreach(CommandLineHandler *opt, *m_options)
{
- if (opt->identify(opt_str) >= 0)
+ int id = opt->identify(opt_str);
+ if(id >= 0)
+ {
+ if(flags)
+ *flags = opt->flags(id);
return true;
+ }
}
return false;
}
@@ -112,7 +122,7 @@ void CommandLineManager::printUsage()
{
QString str = formatHelpString(line);
if(!str.isEmpty())
- cout << qPrintable(str) << endl;
+ std::cout << qPrintable(str) << std::endl;
}
}
}
diff --git a/src/qmmpui/commandlinemanager.h b/src/qmmpui/commandlinemanager.h
index 78cba92c6..88a6177b7 100644
--- a/src/qmmpui/commandlinemanager.h
+++ b/src/qmmpui/commandlinemanager.h
@@ -42,7 +42,7 @@ public:
/*!
* Return \b true if command \b opt_str is supported, otherwise returns \b false.
*/
- static bool hasOption(const QString &opt_str);
+ static bool hasOption(const QString &opt_str, CommandLineHandler::OptionFlags *flags = 0);
/*!
* Prints usage to stdout.
*/