From 2f376a7ebcfc4103b50c523eff7655f619c77353 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 5 Mar 2017 17:40:01 +0000 Subject: changed command line api git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7069 90c681e8-e032-0410-971d-27865f9a5e38 --- src/app/builtincommandlineoption.cpp | 37 +++++++++++----------- src/app/builtincommandlineoption.h | 6 ++-- src/app/qmmpstarter.cpp | 19 +++++++---- .../IncDecVolumeOption/incdecvolumeoption.cpp | 12 +++---- .../IncDecVolumeOption/incdecvolumeoption.h | 8 ++--- .../PlayListOption/playlistoption.cpp | 9 +++--- .../PlayListOption/playlistoption.h | 8 ++--- .../CommandLineOptions/SeekOption/seekoption.cpp | 13 ++++---- .../CommandLineOptions/SeekOption/seekoption.h | 8 ++--- .../StatusOption/statusoption.cpp | 13 ++++---- .../CommandLineOptions/StatusOption/statusoption.h | 8 ++--- .../UninstallOption/uninstalloption.cpp | 10 +++--- .../UninstallOption/uninstalloption.h | 8 ++--- src/qmmpui/commandlinemanager.cpp | 21 ++++++++++-- src/qmmpui/commandlinemanager.h | 2 ++ src/qmmpui/commandlineoption.h | 11 ++++--- 16 files changed, 107 insertions(+), 86 deletions(-) (limited to 'src') 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 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 #include #include +#include #include #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