aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2017-03-05 17:40:01 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2017-03-05 17:40:01 +0000
commit2f376a7ebcfc4103b50c523eff7655f619c77353 (patch)
tree219a408556740105141949a920bda942441e7f0d
parentf731ee7de3fe936c65349d70650fe90045e79c8e (diff)
downloadqmmp-2f376a7ebcfc4103b50c523eff7655f619c77353.tar.gz
qmmp-2f376a7ebcfc4103b50c523eff7655f619c77353.tar.bz2
qmmp-2f376a7ebcfc4103b50c523eff7655f619c77353.zip
changed command line api
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7069 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/app/builtincommandlineoption.cpp37
-rw-r--r--src/app/builtincommandlineoption.h6
-rw-r--r--src/app/qmmpstarter.cpp19
-rw-r--r--src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp12
-rw-r--r--src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h8
-rw-r--r--src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp9
-rw-r--r--src/plugins/CommandLineOptions/PlayListOption/playlistoption.h8
-rw-r--r--src/plugins/CommandLineOptions/SeekOption/seekoption.cpp13
-rw-r--r--src/plugins/CommandLineOptions/SeekOption/seekoption.h8
-rw-r--r--src/plugins/CommandLineOptions/StatusOption/statusoption.cpp13
-rw-r--r--src/plugins/CommandLineOptions/StatusOption/statusoption.h8
-rw-r--r--src/plugins/CommandLineOptions/UninstallOption/uninstalloption.cpp10
-rw-r--r--src/plugins/CommandLineOptions/UninstallOption/uninstalloption.h8
-rw-r--r--src/qmmpui/commandlinemanager.cpp21
-rw-r--r--src/qmmpui/commandlinemanager.h2
-rw-r--r--src/qmmpui/commandlineoption.h11
16 files changed, 107 insertions, 86 deletions
diff --git a/src/app/builtincommandlineoption.cpp b/src/app/builtincommandlineoption.cpp
index 4481b369b..e26b685f6 100644
--- a/src/app/builtincommandlineoption.cpp
+++ b/src/app/builtincommandlineoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2014 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -65,25 +65,24 @@ bool BuiltinCommandLineOption::identify(const QString &str) const
return m_options.contains(str);
}
-const QString BuiltinCommandLineOption::helpString() const
+const QStringList BuiltinCommandLineOption::helpString() const
{
- return QString(
- "-e, --enqueue "+tr("Don't clear the playlist") + "\n" +
- "-p, --play "+tr("Start playing current song")+"\n" +
- "-u, --pause "+tr("Pause current song")+ "\n"
- "-t, --play-pause "+tr("Pause if playing, play otherwise")+ "\n"
- "-s, --stop "+tr("Stop current song")+ "\n" +
- "-j, --jump-to-file "+tr("Display Jump to File dialog")+ "\n" +
- "-q, --quit "+tr("Quit application") + "\n" +
- "--volume <0..100> "+tr("Set playback volume (example: qmmp --volume 20)") + "\n"
- "--toggle-mute "+tr("Mute/Restore volume") + "\n"
- "--next "+tr("Skip forward in playlist")+ "\n" +
- "--previous "+tr("Skip backwards in playlist")+"\n" +
- "--toggle-visibility "+tr("Show/hide application")+ "\n" +
- "--show-mw "+tr("Show main window") + "\n" +
- "--add-file "+tr("Display Add File dialog")+ "\n" +
- "--add-dir "+tr("Display Add Directory dialog")
- );
+ return QStringList()
+ << QString("-e, --enqueue") + "||" + tr("Don't clear the playlist")
+ << QString("-p, --play") + "||" + tr("Start playing current song")
+ << QString("-u, --pause") + "||" + tr("Pause current song")
+ << QString("-t, --play-pause") + "||" + tr("Pause if playing, play otherwise")
+ << QString("-s, --stop") + "||" + tr("Stop current song")
+ << QString("-j, --jump-to-file") + "||" + tr("Display Jump to File dialog")
+ << QString("-q, --quit") + "||" + tr("Quit application")
+ << QString("--volume <0..100>") + "||" + tr("Set playback volume (example: qmmp --volume 20)")
+ << QString("--toggle-mute") + "||" + tr("Mute/Restore volume")
+ << QString("--next") + "||" + tr("Skip forward in playlist")
+ << QString("--previous") + "||" + tr("Skip backwards in playlist")
+ << QString("--toggle-visibility") + "||" + tr("Show/hide application")
+ << QString("--show-mw") + "||" + tr("Show main window")
+ << QString("--add-file") + "||" + tr("Display Add File dialog")
+ << QString("--add-dir") + "||" + tr("Display Add Directory dialog");
}
void BuiltinCommandLineOption::executeCommand(const QString &option_string,
diff --git a/src/app/builtincommandlineoption.h b/src/app/builtincommandlineoption.h
index 64e1cfac4..d47656a36 100644
--- a/src/app/builtincommandlineoption.h
+++ b/src/app/builtincommandlineoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2014 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -42,8 +42,8 @@ public:
~BuiltinCommandLineOption();
- bool identify(const QString& str)const;
- const QString helpString()const;
+ bool identify(const QString& str) const;
+ const QStringList helpString() const;
void executeCommand(const QString& option, const QStringList &args,
const QString &cwd);
QHash <QString, QStringList> splitArgs(const QStringList &args) const;
diff --git a/src/app/qmmpstarter.cpp b/src/app/qmmpstarter.cpp
index aa5ccd45a..a58534678 100644
--- a/src/app/qmmpstarter.cpp
+++ b/src/app/qmmpstarter.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006-2016 by Ilya Kotov *
+ * Copyright (C) 2006-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -342,12 +342,19 @@ void QMMPStarter::printUsage()
cout << qPrintable(tr("Usage: qmmp [options] [files]")) << endl;
cout << qPrintable(tr("Options:")) << endl;
cout << "--------" << endl;
- cout << qPrintable(m_option_manager->helpString()) << endl;
+ foreach (QString line, m_option_manager->helpString())
+ cout << qPrintable(CommandLineManager::formatHelpString(line) ) << endl;
CommandLineManager::printUsage();
- cout << "--no-start " << qPrintable(tr("Don't start the application")) << endl;
- cout << "--help " << qPrintable(tr("Display this text and exit")) << endl;
- cout << "--version " << qPrintable(tr("Print version number and exit")) << endl;
- cout << qPrintable(tr("Ideas, patches, bugreports send to forkotov02@hotmail.ru")) << endl;
+ QStringList extraHelp;
+ extraHelp << QString("--no-start") + "||" + tr("Don't start the application");
+ extraHelp << QString("--help") + "||" + tr("Display this text and exit");
+ extraHelp << QString("--version") + "||" + tr("Print version number and exit");
+ extraHelp << "";
+ extraHelp << tr("Home page: %1").arg("http://qmmp.ylsoftware.com");
+ extraHelp << tr("Development page: %1").arg("https://sourceforge.net/p/qmmp-dev");
+ extraHelp << tr("Bug tracker: %1").arg("https://sourceforge.net/p/qmmp-dev/tickets");
+ foreach (QString line, extraHelp)
+ cout << qPrintable(CommandLineManager::formatHelpString(line)) << endl;
#ifdef Q_OS_WIN
string text = tmp_stream.str();
QMessageBox::information(0, tr("Command Line Help"), QString::fromLocal8Bit(text.c_str()));
diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp
index b94b342fd..fbd8e3ef2 100644
--- a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp
+++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2016 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -21,6 +21,7 @@
#include <QtPlugin>
#include <QTranslator>
#include <QLocale>
+#include <QPair>
#include <qmmp/soundcore.h>
#include "incdecvolumeoption.h"
@@ -38,12 +39,11 @@ bool IncDecVolumeCommandLineOption::identify(const QString & str) const
return false;
}
-const QString IncDecVolumeCommandLineOption::helpString() const
+const QStringList IncDecVolumeCommandLineOption::helpString() const
{
- return QString(
- "--volume-inc " + tr("Increase volume by 5 steps")+"\n"
- "--volume-dec " + tr("Decrease volume by 5 steps")+"\n"
- );
+ return QStringList()
+ << QString("--volume-inc") + "||" + tr("Increase volume by 5 steps")
+ << QString("--volume-dec") + "||" + tr("Decrease volume by 5 steps");
}
QString IncDecVolumeCommandLineOption::executeCommand(const QString& opt_str, const QStringList &args)
diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h
index b0a8edb6e..59ee80039 100644
--- a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h
+++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2012 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,9 +33,9 @@ class IncDecVolumeCommandLineOption : public QObject, public CommandLineOption
Q_OBJECT
Q_INTERFACES(CommandLineOption)
public:
- virtual bool identify(const QString& opt_str)const;
- virtual const QString name()const;
- virtual const QString helpString()const;
+ virtual bool identify(const QString& opt_str) const;
+ virtual const QString name() const;
+ virtual const QStringList helpString() const;
virtual QString executeCommand(const QString& opt_str, const QStringList &args);
virtual QTranslator *createTranslator(QObject *parent);
};
diff --git a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
index 185521b3d..ff94bbcef 100644
--- a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
+++ b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011-2016 by Ilya Kotov *
+ * Copyright (C) 2011-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -40,11 +40,10 @@ bool PlayListOption::identify(const QString & str) const
str == QString("--pl-state");
}
-const QString PlayListOption::helpString() const
+const QStringList PlayListOption::helpString() const
{
- return QString(
- "--pl-help " + tr("Show playlist manipulation commands")+"\n"
- );
+ return QStringList()
+ << QString("--pl-help") + "||" + tr("Show playlist manipulation commands");
}
QString PlayListOption::executeCommand(const QString& opt_str, const QStringList &args)
diff --git a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h
index 2546449a8..ea8f0d600 100644
--- a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h
+++ b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011 by Ilya Kotov *
+ * Copyright (C) 2011-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -35,9 +35,9 @@ class PlayListOption : public QObject, public CommandLineOption
Q_OBJECT
Q_INTERFACES(CommandLineOption)
public:
- virtual bool identify(const QString& opt_str)const;
- virtual const QString name()const;
- virtual const QString helpString()const;
+ virtual bool identify(const QString& opt_str) const;
+ virtual const QString name() const;
+ virtual const QStringList helpString() const;
virtual QString executeCommand(const QString& opt_str, const QStringList &args);
virtual QTranslator *createTranslator(QObject *parent);
diff --git a/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp b/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp
index 427c99e6a..0219ddd28 100644
--- a/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp
+++ b/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010 by Ilya Kotov *
+ * Copyright (C) 2010-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -32,13 +32,12 @@ bool SeekOption::identify(const QString &str) const
return opts.contains(str);
}
-const QString SeekOption::helpString() const
+const QStringList SeekOption::helpString() const
{
- QString help;
- help += QString("--seek <time> ") + tr("Seek to position in the current track") + "\n";
- help += QString("--seek-fwd <time> ") + tr("Seek forward") + "\n";
- help += QString("--seek-bwd <time> ") + tr("Seek backwards") + "\n";
- return help;
+ return QStringList()
+ << 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");
}
QString SeekOption::executeCommand(const QString &opt_str, const QStringList &args)
diff --git a/src/plugins/CommandLineOptions/SeekOption/seekoption.h b/src/plugins/CommandLineOptions/SeekOption/seekoption.h
index ed1a36dea..dca61fbe7 100644
--- a/src/plugins/CommandLineOptions/SeekOption/seekoption.h
+++ b/src/plugins/CommandLineOptions/SeekOption/seekoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010 by Ilya Kotov *
+ * Copyright (C) 2010-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,9 +33,9 @@ class SeekOption : public QObject, public CommandLineOption
Q_OBJECT
Q_INTERFACES(CommandLineOption)
public:
- virtual bool identify(const QString& opt_str)const;
- virtual const QString name()const;
- virtual const QString helpString()const;
+ virtual bool identify(const QString& opt_str) const;
+ virtual const QString name() const;
+ virtual const QStringList helpString() const;
virtual QString executeCommand(const QString& opt_str, const QStringList &args);
virtual QTranslator *createTranslator(QObject *parent);
};
diff --git a/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp b/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp
index 7552c1a43..e9500f974 100644
--- a/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp
+++ b/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp
@@ -33,14 +33,13 @@ bool StatusOption::identify(const QString &str) const
return opts.contains(str);
}
-const QString StatusOption::helpString() const
+const QStringList StatusOption::helpString() const
{
- QString help;
- help += QString("--status ") + tr("Print playback status") + "\n";
- help += QString("--nowplaying <fmt> ")
- + tr("Print formatted track name (example: qmmp --nowplaying \"%t - %a\")") + "\n";
- help += QString("--nowplaying-syntax ") + tr("Print --nowplaying syntax") + "\n";
- return help;
+ return QStringList()
+ << 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");
}
QString StatusOption::executeCommand(const QString &opt_str, const QStringList &args)
diff --git a/src/plugins/CommandLineOptions/StatusOption/statusoption.h b/src/plugins/CommandLineOptions/StatusOption/statusoption.h
index 7d9662b46..93fd91e51 100644
--- a/src/plugins/CommandLineOptions/StatusOption/statusoption.h
+++ b/src/plugins/CommandLineOptions/StatusOption/statusoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011 by Ilya Kotov *
+ * Copyright (C) 2011-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -36,9 +36,9 @@ class StatusOption : public QObject, public CommandLineOption
Q_OBJECT
Q_INTERFACES(CommandLineOption)
public:
- virtual bool identify(const QString& opt_str)const;
- virtual const QString name()const;
- virtual const QString helpString()const;
+ virtual bool identify(const QString& opt_str) const;
+ virtual const QString name() const;
+ virtual const QStringList helpString() const;
virtual QString executeCommand(const QString& opt_str, const QStringList &args);
virtual QTranslator *createTranslator(QObject *parent);
diff --git a/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.cpp b/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.cpp
index 7e19020b8..14456e20b 100644
--- a/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.cpp
+++ b/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014 by Ilya Kotov *
+ * Copyright (C) 2014-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,12 +33,10 @@ bool UninstallOption::identify(const QString &str) const
return opts.contains(str);
}
-const QString UninstallOption::helpString() const
+const QStringList UninstallOption::helpString() const
{
- QString help;
- help += QString("--uninstall ") + tr("Restore the old file associations and clean up the registry")
- + "\n";
- return help;
+ return QStringList()
+ << QString("--uninstall") + "||" + tr("Restore the old file associations and clean up the registry");
}
QString UninstallOption::executeCommand(const QString &opt_str, const QStringList &args)
diff --git a/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.h b/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.h
index 71e99e3b4..5787e22f9 100644
--- a/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.h
+++ b/src/plugins/CommandLineOptions/UninstallOption/uninstalloption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014 by Ilya Kotov *
+ * Copyright (C) 2014-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -35,9 +35,9 @@ class UninstallOption : public QObject, public CommandLineOption
Q_OBJECT
Q_INTERFACES(CommandLineOption)
public:
- virtual bool identify(const QString& opt_str)const;
- virtual const QString name()const;
- virtual const QString helpString()const;
+ virtual bool identify(const QString& opt_str) const;
+ virtual const QString name() const;
+ virtual const QStringList helpString() const;
virtual QString executeCommand(const QString& opt_str, const QStringList &args);
virtual QTranslator *createTranslator(QObject *parent);
diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp
index 889d8d419..ac2e95aaa 100644
--- a/src/qmmpui/commandlinemanager.cpp
+++ b/src/qmmpui/commandlinemanager.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2016 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -103,5 +103,22 @@ void CommandLineManager::printUsage()
{
checkOptions();
foreach(CommandLineOption *opt, *m_options)
- cout << qPrintable(opt->helpString());
+ {
+ foreach (QString line, opt->helpString())
+ {
+ QString str = formatHelpString(line);
+ if(!str.isEmpty())
+ cout << qPrintable(str) << endl;
+ }
+ }
+}
+
+QString CommandLineManager::formatHelpString(const QString &line)
+{
+ QStringList list = line.split("||", QString::SkipEmptyParts);
+ if(list.count() == 1)
+ return list.at(0);
+ else if(list.count() >= 2)
+ return list.at(0).leftJustified(25) + list.at(1);
+ return QString();
}
diff --git a/src/qmmpui/commandlinemanager.h b/src/qmmpui/commandlinemanager.h
index 6ced4be5b..81a3bb9e8 100644
--- a/src/qmmpui/commandlinemanager.h
+++ b/src/qmmpui/commandlinemanager.h
@@ -47,6 +47,8 @@ public:
*/
static void printUsage();
+ static QString formatHelpString(const QString &line);
+
private:
static void checkOptions();
static QList<CommandLineOption *> *m_options;
diff --git a/src/qmmpui/commandlineoption.h b/src/qmmpui/commandlineoption.h
index b84a5cbe5..2a1ad71e4 100644
--- a/src/qmmpui/commandlineoption.h
+++ b/src/qmmpui/commandlineoption.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2009 by Ilya Kotov *
+ * Copyright (C) 2008-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,15 +37,16 @@ public:
* Returns \b true if \b opt_str string can be processed,
* otherise \b false
*/
- virtual bool identify(const QString& opt_str)const = 0;
+ virtual bool identify(const QString& opt_str) const = 0;
/*!
* Command line option name
*/
- virtual const QString name()const = 0;
+ virtual const QString name() const = 0;
/*!
- * Help string.
+ * A list of specially formatted help strings.
+ * Example: "--help||Display this text and exit".
*/
- virtual const QString helpString()const = 0;
+ virtual const QStringList helpString() const = 0;
/*!
* Parses \b opt_str args(if needed), executes command.
* @param opt_str Command to execute