aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmmpui')
-rw-r--r--src/qmmpui/commandlinemanager.cpp10
-rw-r--r--src/qmmpui/commandlineoption.h25
2 files changed, 24 insertions, 11 deletions
diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp
index fb672e335..08424fa41 100644
--- a/src/qmmpui/commandlinemanager.cpp
+++ b/src/qmmpui/commandlinemanager.cpp
@@ -23,6 +23,7 @@
#include <QObject>
#include <QList>
#include <QApplication>
+#include <QTranslator>
#include <cstdlib>
#include <iostream>
#include <qmmp/qmmp.h>
@@ -60,7 +61,12 @@ void CommandLineManager::checkOptions()
{
m_options->append(option);
m_files->insert(option, filePath);
- //qApp->installTranslator(option->createTranslator(qApp));
+ if(!option->properties().translation.isEmpty())
+ {
+ QTranslator *translator = new QTranslator(qApp);
+ translator->load(option->properties().translation + Qmmp::systemLanguageID());
+ qApp->installTranslator(translator);
+ }
}
}
}
@@ -100,7 +106,7 @@ void CommandLineManager::printUsage()
checkOptions();
foreach(CommandLineOption *opt, *m_options)
{
- foreach (QString line, opt->helpString())
+ foreach(QString line, opt->properties().helpString)
{
QString str = formatHelpString(line);
if(!str.isEmpty())
diff --git a/src/qmmpui/commandlineoption.h b/src/qmmpui/commandlineoption.h
index 6e1a52638..f6f67d5e5 100644
--- a/src/qmmpui/commandlineoption.h
+++ b/src/qmmpui/commandlineoption.h
@@ -27,6 +27,18 @@ class QString;
class QObject;
class QStringList;
+/*! @brief Helper class to store command line plugin properties.
+ * @author Ilya Kotov <forkotov02@ya.ru>
+ */
+class CommandLineProperties
+{
+public:
+ QString shortName; /*!< Input plugin short name for internal usage */
+ QString translation; /*!< Translation file path without locale code and extension */
+ QStringList helpString; /*!< A list of specially formatted help strings.
+ Example: "--help||Display this text and exit" */
+};
+
/*! @brief Abstract base class of the command line plugins.
* @author Vladimir Kuznetsov <vovanec@gmail.ru>
*/
@@ -34,20 +46,15 @@ class QMMPUI_EXPORT CommandLineOption
{
public:
/*!
+ * Returns command line plugin properties.
+ */
+ virtual const CommandLineProperties properties() const = 0;
+ /*!
* Returns \b true if \b opt_str string can be processed,
* otherise \b false
*/
virtual bool identify(const QString& opt_str) const = 0;
/*!
- * Command line option name
- */
- virtual const QString name() const = 0;
- /*!
- * A list of specially formatted help strings.
- * Example: "--help||Display this text and exit".
- */
- virtual const QStringList helpString() const = 0;
- /*!
* Parses \b opt_str args(if needed), executes command.
* @param opt_str Command to execute
* @param args Command arguments