diff options
Diffstat (limited to 'src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp')
| -rw-r--r-- | src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp new file mode 100644 index 000000000..93a7dd21d --- /dev/null +++ b/src/plugins/CommandLineOptions/IncDecVolumeOption/incdecvolumeoption.cpp @@ -0,0 +1,60 @@ +#include <QtPlugin> +#include <QTranslator> + +#include "incdecvolumeoption.h" + +bool IncDecVolumeCommandLineOption::identify(const QString & str) const +{ + if ( + str == QString("--volume-inc") || + str == QString("--volume-dec") + ) + { + return TRUE; + } + + return FALSE; +} + +const QString IncDecVolumeCommandLineOption::helpString() const +{ + return QString( + "--volume-inc " + tr("Increase volume with step 5")+"\n" + "--volume-dec " + tr("Decrease volume with step 5")+"\n" + ); +} + + +void IncDecVolumeCommandLineOption::executeCommand(const QString& opt_str, CommandLineManager* clm, Control* ctrl) +{ + int volume = qMax(clm->leftVolume(), clm->rightVolume()); + int balance = 0; + int left = clm->leftVolume(); + int right = clm->rightVolume(); + if (left || right) + balance = (right - left)*100/volume; + + if (opt_str == "--volume-inc") + { + volume = qMin (100, volume + 5); + } + else if (opt_str == "--volume-dec") + { + volume = qMax (0, volume - 5); + } + ctrl->setVolume(volume-qMax(balance,0)*volume/100, + volume+qMin(balance,0)*volume/100); +} + +const QString IncDecVolumeCommandLineOption::name() const +{ + return "IncDecVolumeCommandLineOption"; +} + +QTranslator *IncDecVolumeCommandLineOption::createTranslator(QObject *parent) +{ + Q_UNUSED(parent); + return 0; +} + +Q_EXPORT_PLUGIN(IncDecVolumeCommandLineOption) |
