diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-12-25 20:50:08 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-12-25 20:50:08 +0000 |
| commit | c28061c4cf64e468dd3e230df1b96d1a72e295fd (patch) | |
| tree | 85cdef77d8851ab89e8a57ba1d5f823531a15831 /src/plugins/CommandLineOptions/IncDecVolumeOption | |
| parent | 164e24517d01eb95f74563cc66a691adf07ed514 (diff) | |
| download | qmmp-c28061c4cf64e468dd3e230df1b96d1a72e295fd.tar.gz qmmp-c28061c4cf64e468dd3e230df1b96d1a72e295fd.tar.bz2 qmmp-c28061c4cf64e468dd3e230df1b96d1a72e295fd.zip | |
fixed command line plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8532 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/CommandLineOptions/IncDecVolumeOption')
| -rw-r--r-- | src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp | 39 | ||||
| -rw-r--r-- | src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.h | 25 |
2 files changed, 36 insertions, 28 deletions
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 |
