mirror of
https://code.videolan.org/videolan/vlc
synced 2024-08-27 04:21:53 +02:00
qt: make player identifiers translatable
Signed-off-by: Pierre Lamot <pierre@videolabs.io>
This commit is contained in:
parent
6f26730005
commit
eb9b3a0378
@ -21,8 +21,15 @@
|
||||
#include <QMetaEnum>
|
||||
#include <QJSEngine>
|
||||
|
||||
#include "qt.hpp"
|
||||
#include "control_list_model.hpp"
|
||||
|
||||
decltype (PlayerControlbarModel::playerIdentifierDictionary)
|
||||
PlayerControlbarModel::playerIdentifierDictionary {
|
||||
{Mainplayer, N_("Mainplayer")},
|
||||
{Miniplayer, N_("Miniplayer")}
|
||||
};
|
||||
|
||||
QJSValue PlayerControlbarModel::getPlaylistIdentifierListModel(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine)
|
||||
@ -35,8 +42,20 @@ QJSValue PlayerControlbarModel::getPlaylistIdentifierListModel(QQmlEngine *engin
|
||||
{
|
||||
QJSValue obj = scriptEngine->newObject();
|
||||
|
||||
obj.setProperty("identifier", metaEnum.value(i));
|
||||
obj.setProperty("name", metaEnum.key(i));
|
||||
const int val = metaEnum.value(i);
|
||||
obj.setProperty("identifier", val);
|
||||
|
||||
QString key;
|
||||
if ( playerIdentifierDictionary.contains(static_cast<PlayerControlbarModel::PlayerIdentifier>(i)) )
|
||||
{
|
||||
key = qtr( playerIdentifierDictionary[static_cast<PlayerControlbarModel::PlayerIdentifier>(i)] );
|
||||
}
|
||||
else
|
||||
{
|
||||
key = metaEnum.key(i);
|
||||
}
|
||||
|
||||
obj.setProperty("name", key);
|
||||
|
||||
array.setProperty(i, obj);
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QJSValue>
|
||||
#include <QMap>
|
||||
|
||||
#include <array>
|
||||
|
||||
class ControlListModel;
|
||||
@ -40,6 +42,9 @@ public:
|
||||
// add its identifier in this enum and set QML buttons layout
|
||||
// identifier to it. Such as `property int identifier =
|
||||
// PlayerControlbarModel.Mainplayer`.
|
||||
// To make it translatable, add a corresponding entry to
|
||||
// the static member playerIdentifierDictionary which is
|
||||
// initalized in the source file.
|
||||
enum PlayerIdentifier {
|
||||
Mainplayer = 0,
|
||||
Miniplayer
|
||||
@ -51,6 +56,9 @@ public:
|
||||
// Thanks to MOC, adding an entry to this enum
|
||||
// is enough for the editor to consider the
|
||||
// added entry without any other modification.
|
||||
// (except for the translation)
|
||||
|
||||
static const QMap<PlayerIdentifier, const char*> playerIdentifierDictionary;
|
||||
|
||||
static QJSValue getPlaylistIdentifierListModel(class QQmlEngine *engine,
|
||||
class QJSEngine *scriptEngine);
|
||||
|
@ -799,6 +799,8 @@ modules/gui/qt/widgets/native/searchlineedit.hpp
|
||||
modules/gui/qt/util/singleton.hpp
|
||||
modules/gui/qt/util/validators.cpp
|
||||
modules/gui/qt/util/validators.hpp
|
||||
modules/gui/qt/player/player_controlbar_model.cpp
|
||||
modules/gui/qt/player/player_controlbar_model.hpp
|
||||
modules/gui/qt/dialogs/dialogs/qml/CustomDialog.qml
|
||||
modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
|
||||
modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
|
||||
|
Loading…
Reference in New Issue
Block a user