Skip to content
Snippets Groups Projects
Commit 6f267300 authored by Fatih Uzunoğlu's avatar Fatih Uzunoğlu Committed by Pierre Lamot
Browse files

qt: add function to access PlayerIdentifier enum from qml


Signed-off-by: default avatarPierre Lamot <pierre@videolabs.io>
parent 685f4e65
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,35 @@
#include "player_controlbar_model.hpp"
#include <QMetaEnum>
#include <QJSEngine>
#include "control_list_model.hpp"
QJSValue PlayerControlbarModel::getPlaylistIdentifierListModel(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
static const QMetaEnum metaEnum = QMetaEnum::fromType<PlayerIdentifier>();
QJSValue array = scriptEngine->newArray();
for (int i = 0; i < metaEnum.keyCount(); ++i)
{
QJSValue obj = scriptEngine->newObject();
obj.setProperty("identifier", metaEnum.value(i));
obj.setProperty("name", metaEnum.key(i));
array.setProperty(i, obj);
}
QJSValue value = scriptEngine->newObject();
value.setProperty("model", array);
return value;
}
PlayerControlbarModel::PlayerControlbarModel(QObject *parent) : QObject(parent)
{
m_left = new ControlListModel(this);
......
......@@ -20,6 +20,7 @@
#define PLAYERCONTROLBARMODEL_HPP
#include <QObject>
#include <QJSValue>
#include <array>
class ControlListModel;
......@@ -44,6 +45,15 @@ public:
Miniplayer
};
Q_ENUM(PlayerIdentifier)
// This enum is iterated through QMetaEnum, and
// a model out of this enum is generated
// and used in the configuration editor.
// Thanks to MOC, adding an entry to this enum
// is enough for the editor to consider the
// added entry without any other modification.
static QJSValue getPlaylistIdentifierListModel(class QQmlEngine *engine,
class QJSEngine *scriptEngine);
explicit PlayerControlbarModel(QObject *parent = nullptr);
~PlayerControlbarModel();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment