diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-07-21 14:38:08 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2018-07-21 14:38:08 +0000 |
| commit | 0006966c0f307ec7dff51130ce26bbe3c7061418 (patch) | |
| tree | a9a760770de8b91c543e1308392bf2ec9e926a58 /src/qmmpui | |
| parent | 20967c016b4c63b75cb0af2b0f3ccc006addd6df (diff) | |
| download | qmmp-0006966c0f307ec7dff51130ce26bbe3c7061418.tar.gz qmmp-0006966c0f307ec7dff51130ce26bbe3c7061418.tar.bz2 qmmp-0006966c0f307ec7dff51130ce26bbe3c7061418.zip | |
changed translation api
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8196 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/commandlinemanager.cpp | 2 | ||||
| -rw-r--r-- | src/qmmpui/commandlineoption.h | 5 | ||||
| -rw-r--r-- | src/qmmpui/filedialog.cpp | 1 | ||||
| -rw-r--r-- | src/qmmpui/filedialogfactory.h | 19 | ||||
| -rw-r--r-- | src/qmmpui/generalfactory.h | 7 | ||||
| -rw-r--r-- | src/qmmpui/mediaplayer.cpp | 4 | ||||
| -rw-r--r-- | src/qmmpui/qmmpuiplugincache.cpp | 19 | ||||
| -rw-r--r-- | src/qmmpui/qmmpuiplugincache_p.h | 3 | ||||
| -rw-r--r-- | src/qmmpui/qtfiledialog.cpp | 6 | ||||
| -rw-r--r-- | src/qmmpui/qtfiledialog_p.h | 3 | ||||
| -rw-r--r-- | src/qmmpui/uifactory.h | 7 |
11 files changed, 29 insertions, 47 deletions
diff --git a/src/qmmpui/commandlinemanager.cpp b/src/qmmpui/commandlinemanager.cpp index 8074d5b12..fb672e335 100644 --- a/src/qmmpui/commandlinemanager.cpp +++ b/src/qmmpui/commandlinemanager.cpp @@ -60,7 +60,7 @@ void CommandLineManager::checkOptions() { m_options->append(option); m_files->insert(option, filePath); - qApp->installTranslator(option->createTranslator(qApp)); + //qApp->installTranslator(option->createTranslator(qApp)); } } } diff --git a/src/qmmpui/commandlineoption.h b/src/qmmpui/commandlineoption.h index a8847897d..6e1a52638 100644 --- a/src/qmmpui/commandlineoption.h +++ b/src/qmmpui/commandlineoption.h @@ -23,7 +23,6 @@ #include "qmmpui_export.h" class CommandLineManager; -class QTranslator; class QString; class QObject; class QStringList; @@ -56,10 +55,6 @@ public: */ virtual QString executeCommand(const QString &opt_str, const QStringList &args) = 0; /*! - * Creates translator with parent object \b parent - */ - virtual QTranslator *createTranslator(QObject *parent) = 0; - /*! * Object destructor */ virtual ~CommandLineOption() {} diff --git a/src/qmmpui/filedialog.cpp b/src/qmmpui/filedialog.cpp index 60f9c6e97..75cef24e2 100644 --- a/src/qmmpui/filedialog.cpp +++ b/src/qmmpui/filedialog.cpp @@ -20,7 +20,6 @@ #include <QFile> #include <QSettings> -#include <QTranslator> #include <QApplication> #include <QPluginLoader> #include <QMetaObject> diff --git a/src/qmmpui/filedialogfactory.h b/src/qmmpui/filedialogfactory.h index fd416f1e1..5174a8f1b 100644 --- a/src/qmmpui/filedialogfactory.h +++ b/src/qmmpui/filedialogfactory.h @@ -23,7 +23,6 @@ #include "qmmpui_export.h" class QObject; -class QTranslator; class FileDialog; class QWidget; class QString; @@ -41,12 +40,13 @@ public: hasAbout = false; modal = true; } - bool hasAbout; /*!< Should be \b true if the file dialog plugin has about dialog, - * otherwise should be \b false */ - QString name; /*!< File dialog plugin full name */ - QString shortName; /*!< File dialog short name for internal usage */ - bool modal; /*!< Should be \b true if the file dialog doesn't support nonmodal mode, - * otherwise should be \b false */ + bool hasAbout; /*!< Should be \b true if the file dialog plugin has about dialog, + * otherwise should be \b false */ + QString name; /*!< File dialog plugin full name */ + QString shortName; /*!< File dialog short name for internal usage */ + QString translation; /*!< Translation file path without locale code and extension */ + bool modal; /*!< Should be \b true if the file dialog doesn't support nonmodal mode, + * otherwise should be \b false */ }; /*! @brief File dialog plugin interface. * @author Vladimir Kuznetsov <vovanec@gmail.com> @@ -71,11 +71,6 @@ public: * @param parent Parent widget. */ virtual void showAbout(QWidget *parent) = 0; - /*! - * Creates QTranslator object of the system locale. Should return 0 if translation doesn't exist. - * @param parent Parent object. - */ - virtual QTranslator *createTranslator(QObject *parent) = 0; }; Q_DECLARE_INTERFACE(FileDialogFactory, "FileDialogFactory/1.0") diff --git a/src/qmmpui/generalfactory.h b/src/qmmpui/generalfactory.h index dcb2e87e9..5075f60d7 100644 --- a/src/qmmpui/generalfactory.h +++ b/src/qmmpui/generalfactory.h @@ -23,7 +23,6 @@ #include "qmmpui_export.h" class QObject; -class QTranslator; class QDialog; class QString; class QWidget; @@ -46,6 +45,7 @@ public: } QString name; /*!< File dialog plugin full name */ QString shortName; /*!< File dialog short name for internal usage */ + QString translation; /*!< Translation file path without locale code and extension */ bool hasAbout; /*!< Should be \b true if plugin has about dialog, otherwise returns \b false */ bool hasSettings; /*!< Should be \b true if plugin has settings dialog, otherwise returns \b false */ bool visibilityControl; /*!< Should be \b true if plugin can show/hide main window of the player, @@ -80,11 +80,6 @@ public: * @param parent Parent widget. */ virtual void showAbout(QWidget *parent) = 0; - /*! - * Creates QTranslator object of the system locale. Should return \b 0 if translation doesn't exist. - * @param parent Parent object. - */ - virtual QTranslator *createTranslator(QObject *parent) = 0; }; Q_DECLARE_INTERFACE(GeneralFactory, "GeneralFactory/1.0") diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp index b60596739..8dd0fbf61 100644 --- a/src/qmmpui/mediaplayer.cpp +++ b/src/qmmpui/mediaplayer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2015 by Ilya Kotov * + * Copyright (C) 2008-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -20,9 +20,9 @@ #include <QApplication> #include <QString> -#include <QTranslator> #include <QLocale> #include <QTimer> +#include <QTranslator> #include "playlistitem.h" #include "qmmpuisettings.h" #include "mediaplayer.h" diff --git a/src/qmmpui/qmmpuiplugincache.cpp b/src/qmmpui/qmmpuiplugincache.cpp index 0969b1a29..9495f6fa1 100644 --- a/src/qmmpui/qmmpuiplugincache.cpp +++ b/src/qmmpui/qmmpuiplugincache.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013 by Ilya Kotov * + * Copyright (C) 2013-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -24,6 +24,7 @@ #include <QPluginLoader> #include <QApplication> #include <QTranslator> +#include <qmmp/qmmp.h> #include "generalfactory.h" #include "uifactory.h" #include "filedialogfactory.h" @@ -159,7 +160,7 @@ GeneralFactory *QmmpUiPluginCache::generalFactory() { m_generalFactory = qobject_cast<GeneralFactory *> (instance()); if(m_generalFactory) - qApp->installTranslator(m_generalFactory->createTranslator(qApp)); + loadTranslation(m_generalFactory->properties().translation); } return m_generalFactory; } @@ -170,7 +171,7 @@ UiFactory *QmmpUiPluginCache::uiFactory() { m_uiFactory = qobject_cast<UiFactory *> (instance()); if(m_uiFactory) - qApp->installTranslator(m_uiFactory->createTranslator(qApp)); + loadTranslation(m_uiFactory->properties().translation); } return m_uiFactory; } @@ -181,7 +182,7 @@ FileDialogFactory *QmmpUiPluginCache::fileDialogFactory() { m_fileDialogFactory = qobject_cast<FileDialogFactory *> (instance()); if(m_fileDialogFactory) - qApp->installTranslator(m_fileDialogFactory->createTranslator(qApp)); + loadTranslation(m_fileDialogFactory->properties().translation); } return m_fileDialogFactory; } @@ -204,6 +205,16 @@ QObject *QmmpUiPluginCache::instance() return m_instance; } +void QmmpUiPluginCache::loadTranslation(const QString &translation) +{ + if(!translation.isEmpty()) + { + QTranslator *translator = new QTranslator(qApp); + translator->load(translation + Qmmp::systemLanguageID()); + qApp->installTranslator(translator); + } +} + void QmmpUiPluginCache::cleanup(QSettings *settings) { settings->beginGroup("PluginCache"); diff --git a/src/qmmpui/qmmpuiplugincache_p.h b/src/qmmpui/qmmpuiplugincache_p.h index 2c06c5c1c..e961463db 100644 --- a/src/qmmpui/qmmpuiplugincache_p.h +++ b/src/qmmpui/qmmpuiplugincache_p.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013 by Ilya Kotov * + * Copyright (C) 2013-2018 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -51,6 +51,7 @@ public: private: QObject *instance(); + void loadTranslation(const QString &translation); QString m_path; QString m_shortName; bool m_error; diff --git a/src/qmmpui/qtfiledialog.cpp b/src/qmmpui/qtfiledialog.cpp index e81330c60..7ec53c5f9 100644 --- a/src/qmmpui/qtfiledialog.cpp +++ b/src/qmmpui/qtfiledialog.cpp @@ -41,12 +41,6 @@ const FileDialogProperties QtFileDialogFactory::properties() const void QtFileDialogFactory::showAbout(QWidget*){} -QTranslator *QtFileDialogFactory::createTranslator(QObject *parent) -{ - Q_UNUSED(parent) - return 0; -} - QtFileDialog::~QtFileDialog() { qDebug("QtFileDialog::~QtFileDialog()"); diff --git a/src/qmmpui/qtfiledialog_p.h b/src/qmmpui/qtfiledialog_p.h index 9955802aa..bbc60282d 100644 --- a/src/qmmpui/qtfiledialog_p.h +++ b/src/qmmpui/qtfiledialog_p.h @@ -23,8 +23,6 @@ #include <QObject> #include "filedialog.h" -class QTranslator; - /*! @internal * @author Vladimir Kuznetsov <vovanec@gmail.com> */ @@ -38,7 +36,6 @@ public: FileDialog* create(); const FileDialogProperties properties() const; void showAbout(QWidget*); - QTranslator *createTranslator(QObject*); virtual ~QtFileDialogFactory() { ; diff --git a/src/qmmpui/uifactory.h b/src/qmmpui/uifactory.h index caabde506..9b4acad39 100644 --- a/src/qmmpui/uifactory.h +++ b/src/qmmpui/uifactory.h @@ -23,7 +23,6 @@ #include "qmmpui_export.h" class QObject; -class QTranslator; class QDialog; class QString; class QWidget; @@ -44,6 +43,7 @@ public: } QString name; /*!< File dialog plugin full name */ QString shortName; /*!< File dialog short name for internal usage */ + QString translation; /*!< Translation file path without locale code and extension */ bool hasAbout; /*!< Should be \b true if plugin has about dialog, otherwise returns \b false */ }; /*! @brief User interface plugin interface. @@ -69,11 +69,6 @@ public: * @param parent Parent widget. */ virtual void showAbout(QWidget *parent) = 0; - /*! - * Creates QTranslator object of the system locale. Should return \b 0 if translation doesn't exist. - * @param parent Parent object. - */ - virtual QTranslator *createTranslator(QObject *parent) = 0; }; Q_DECLARE_INTERFACE(UiFactory, "UiFactory/1.0") |
