diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-12-27 21:19:42 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-12-27 21:19:42 +0000 |
| commit | a13a898395740f6663dcba0ba24ff4e46d42d29c (patch) | |
| tree | e65801d3962746788458f3bef59efbc4de57ed97 | |
| parent | 5905c1acda34d0c7a26c8ba34ae8a280431ece7e (diff) | |
| download | qmmp-a13a898395740f6663dcba0ba24ff4e46d42d29c.tar.gz qmmp-a13a898395740f6663dcba0ba24ff4e46d42d29c.tar.bz2 qmmp-a13a898395740f6663dcba0ba24ff4e46d42d29c.zip | |
added flags for command line options
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8534 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp | 23 | ||||
| -rw-r--r-- | src/qmmpui/commandlinehandler.cpp | 22 | ||||
| -rw-r--r-- | src/qmmpui/commandlinehandler.h | 13 | ||||
| -rw-r--r-- | src/qmmpui/commandlinemanager.cpp | 2 | ||||
| -rw-r--r-- | src/qmmpui/commandlinemanager.h | 2 |
5 files changed, 52 insertions, 10 deletions
diff --git a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp index d764c6841..09c7fb7d5 100644 --- a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp +++ b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp @@ -38,6 +38,15 @@ void PlayListOption::registerOprions() 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")); + + setOptionFlags(PL_HELP, NO_START); + setOptionFlags(PL_LIST, HIDDEN_FROM_HELP); + setOptionFlags(PL_DUMP, HIDDEN_FROM_HELP); + setOptionFlags(PL_PLAY, HIDDEN_FROM_HELP); + setOptionFlags(PL_CLEAR, HIDDEN_FROM_HELP); + setOptionFlags(PL_REPEATE_TOGGLE, HIDDEN_FROM_HELP); + setOptionFlags(PL_SHUFFLE_TOGGLE, HIDDEN_FROM_HELP); + setOptionFlags(PL_STATE, HIDDEN_FROM_HELP); } QString PlayListOption::shortName() const @@ -63,13 +72,13 @@ QString PlayListOption::executeCommand(int id, const QStringList &args) case PL_HELP: { QStringList list = QStringList() - << QString("--pl-list") + "||" + tr("List all available playlists") - << QString("--pl-dump <id>") + "||" + tr("Show playlist content") - << QString("--pl-play <id> <track>") + "||" + tr("Play track <track> in playlist <id>") - << QString("--pl-clear <id>") + "||" + tr("Clear playlist") - << QString("--pl-repeat-toggle") + "||" + tr("Toggle playlist repeat") - << QString("--pl-shuffle-toggle") + "||" + tr("Toggle playlist shuffle") - << QString("--pl-state") + "||" + tr("Show playlist options"); + << helpString(PL_LIST) + << helpString(PL_DUMP) + << helpString(PL_PLAY) + << helpString(PL_CLEAR) + << helpString(PL_REPEATE_TOGGLE) + << helpString(PL_SHUFFLE_TOGGLE) + << helpString(PL_STATE); foreach (QString line, list) out += CommandLineManager::formatHelpString(line) + "\n"; diff --git a/src/qmmpui/commandlinehandler.cpp b/src/qmmpui/commandlinehandler.cpp index 7bf98f069..e8a5e81da 100644 --- a/src/qmmpui/commandlinehandler.cpp +++ b/src/qmmpui/commandlinehandler.cpp @@ -25,7 +25,9 @@ QStringList CommandLineHandler::helpString() const QStringList out; foreach (const CommandLineOption &opt, m_options.values()) { - if(opt.values.isEmpty()) + if(opt.flags & HIDDEN_FROM_HELP) + continue; + else if(opt.values.isEmpty()) out << opt.names.join(", ") + "||" + opt.helpString; else out << opt.names.join(", ") + " <" + opt.values.join("> <") + ">||" + opt.helpString; @@ -33,6 +35,14 @@ QStringList CommandLineHandler::helpString() const return out; } +QString CommandLineHandler::helpString(int id) const +{ + if(m_options[id].values.isEmpty()) + return m_options[id].names.join(", ") + "||" + m_options[id].helpString; + else + return m_options[id].names.join(", ") + " <" + m_options[id].values.join("> <") + ">||" + m_options[id].helpString; +} + int CommandLineHandler::identify(const QString &name) const { foreach (const CommandLineOption &opt, m_options.values()) @@ -43,6 +53,11 @@ int CommandLineHandler::identify(const QString &name) const return -1; } +CommandLineHandler::OptionFlags CommandLineHandler::flags(int id) const +{ + return m_options.value(id).flags; +} + void CommandLineHandler::registerOption(int id, const QString &name, const QString &helpString, const QStringList &values) { registerOption(id, QStringList() << name, helpString, values); @@ -56,3 +71,8 @@ void CommandLineHandler::registerOption(int id, const QStringList &names, const opt.helpString = helpString; m_options.insert(id, opt); } + +void CommandLineHandler::setOptionFlags(int id, OptionFlags flags) +{ + m_options[id].flags = flags; +} diff --git a/src/qmmpui/commandlinehandler.h b/src/qmmpui/commandlinehandler.h index 78e2262ed..bc998fe0d 100644 --- a/src/qmmpui/commandlinehandler.h +++ b/src/qmmpui/commandlinehandler.h @@ -24,6 +24,7 @@ #include <QMap> #include <QStringList> #include <QtPlugin> +#include <QFlags> #include "qmmpui_export.h" @@ -64,11 +65,22 @@ public: virtual QString executeCommand(int id, const QStringList &args) = 0; QStringList helpString() const; + QString helpString(int id) const; int identify(const QString &name) const; + enum OptionFlag + { + HIDDEN_FROM_HELP = 0x1, + NO_START = 0x2 + }; + Q_DECLARE_FLAGS(OptionFlags, OptionFlag) + + CommandLineHandler::OptionFlags flags(int id) const; + protected: 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()); + void setOptionFlags(int id, OptionFlags flags); private: struct CommandLineOption @@ -76,6 +88,7 @@ private: QStringList names; QStringList values; QString helpString; + OptionFlags flags; inline bool operator == (const CommandLineOption &opt) const { diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp index 1c56e7db4..d1f28b1ba 100644 --- a/src/qmmpui/commandlinemanager.cpp +++ b/src/qmmpui/commandlinemanager.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2017 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 * diff --git a/src/qmmpui/commandlinemanager.h b/src/qmmpui/commandlinemanager.h index a57114ff2..78cba92c6 100644 --- a/src/qmmpui/commandlinemanager.h +++ b/src/qmmpui/commandlinemanager.h @@ -38,7 +38,7 @@ public: * @param args Command arguments. * @return Command output result. */ - static QString executeCommand(const QString& name, const QStringList &args = QStringList()); + static QString executeCommand(const QString &name, const QStringList &args = QStringList()); /*! * Return \b true if command \b opt_str is supported, otherwise returns \b false. */ |
