[Backend] Moved backends into their own folder.
This commit is contained in:
parent
287a51ba0b
commit
4f7da53bb4
|
@ -37,16 +37,17 @@ endif(X11_FOUND AND Xext_FOUND)
|
|||
|
||||
set(SOURCES
|
||||
src/main.cpp
|
||||
src/DirectMpvPlayerBackend.cpp
|
||||
src/Backends/DirectMPV/DirectMPVBackend.cpp
|
||||
src/utils.cpp
|
||||
src/enums.hpp
|
||||
src/Process.cpp
|
||||
src/ThumbnailCache.cpp
|
||||
src/logger.cpp
|
||||
src/qmldebugger.cpp
|
||||
)
|
||||
|
||||
if(MPV_VERSION VERSION_GREATER_EQUAL "1.28.0")
|
||||
set(SOURCES ${SOURCES} src/MpvPlayerBackend.cpp)
|
||||
set(SOURCES ${SOURCES} src/Backends/MPV/MPVBackend.cpp)
|
||||
else()
|
||||
add_definitions(-DDISABLE_MpvPlayerBackend)
|
||||
endif(MPV_VERSION VERSION_GREATER_EQUAL "1.28.0")
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "DirectMpvPlayerBackend.h"
|
||||
#include "src/Backends/DirectMPV/DirectMPVBackend.hpp"
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "src/utils.hpp"
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QOpenGLContext>
|
||||
|
@ -17,7 +17,7 @@
|
|||
void
|
||||
wakeup(void* ctx)
|
||||
{
|
||||
QCoreApplication::postEvent((DirectMpvPlayerBackend*)ctx,
|
||||
QCoreApplication::postEvent((DirectMPVBackend*)ctx,
|
||||
new QEvent(QEvent::User));
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ MpvRenderer::paint()
|
|||
window->resetOpenGLState();
|
||||
}
|
||||
|
||||
DirectMpvPlayerBackend::DirectMpvPlayerBackend(QQuickItem* parent)
|
||||
DirectMPVBackend::DirectMPVBackend(QQuickItem* parent)
|
||||
: QQuickItem(parent)
|
||||
, mpv_gl(0)
|
||||
, renderer(0)
|
||||
|
@ -117,27 +117,27 @@ DirectMpvPlayerBackend::DirectMpvPlayerBackend(QQuickItem* parent)
|
|||
if (!mpv_gl)
|
||||
throw std::runtime_error("OpenGL not compiled in");
|
||||
mpv_opengl_cb_set_update_callback(
|
||||
mpv_gl, DirectMpvPlayerBackend::on_update, (void*)this);
|
||||
mpv_gl, DirectMPVBackend::on_update, (void*)this);
|
||||
|
||||
connect(this,
|
||||
&DirectMpvPlayerBackend::onUpdate,
|
||||
&DirectMPVBackend::onUpdate,
|
||||
this,
|
||||
&DirectMpvPlayerBackend::doUpdate,
|
||||
&DirectMPVBackend::doUpdate,
|
||||
Qt::QueuedConnection);
|
||||
connect(this,
|
||||
&DirectMpvPlayerBackend::positionChanged,
|
||||
&DirectMpvPlayerBackend::updateDurationString);
|
||||
&DirectMPVBackend::positionChanged,
|
||||
&DirectMPVBackend::updateDurationString);
|
||||
connect(this,
|
||||
&DirectMpvPlayerBackend::durationChanged,
|
||||
&DirectMpvPlayerBackend::updateDurationString);
|
||||
&DirectMPVBackend::durationChanged,
|
||||
&DirectMPVBackend::updateDurationString);
|
||||
|
||||
connect(this,
|
||||
&QQuickItem::windowChanged,
|
||||
this,
|
||||
&DirectMpvPlayerBackend::handleWindowChanged);
|
||||
&DirectMPVBackend::handleWindowChanged);
|
||||
}
|
||||
|
||||
DirectMpvPlayerBackend::~DirectMpvPlayerBackend()
|
||||
DirectMPVBackend::~DirectMPVBackend()
|
||||
{
|
||||
printf("Shutting down...\n");
|
||||
qApp->quit();
|
||||
|
@ -145,7 +145,7 @@ DirectMpvPlayerBackend::~DirectMpvPlayerBackend()
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::sync()
|
||||
DirectMPVBackend::sync()
|
||||
{
|
||||
|
||||
if (!renderer) {
|
||||
|
@ -163,13 +163,13 @@ DirectMpvPlayerBackend::sync()
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::swapped()
|
||||
DirectMPVBackend::swapped()
|
||||
{
|
||||
mpv_opengl_cb_report_flip(mpv_gl, 0);
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::cleanup()
|
||||
DirectMPVBackend::cleanup()
|
||||
{
|
||||
if (renderer) {
|
||||
delete renderer;
|
||||
|
@ -178,45 +178,45 @@ DirectMpvPlayerBackend::cleanup()
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::on_update(void* ctx)
|
||||
DirectMPVBackend::on_update(void* ctx)
|
||||
{
|
||||
DirectMpvPlayerBackend* self = (DirectMpvPlayerBackend*)ctx;
|
||||
DirectMPVBackend* self = (DirectMPVBackend*)ctx;
|
||||
emit self->onUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::doUpdate()
|
||||
DirectMPVBackend::doUpdate()
|
||||
{
|
||||
window()->update();
|
||||
update();
|
||||
}
|
||||
|
||||
QVariant
|
||||
DirectMpvPlayerBackend::getProperty(const QString& name) const
|
||||
DirectMPVBackend::getProperty(const QString& name) const
|
||||
{
|
||||
return mpv::qt::get_property_variant(mpv, name);
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::command(const QVariant& params)
|
||||
DirectMPVBackend::command(const QVariant& params)
|
||||
{
|
||||
mpv::qt::command_variant(mpv, params);
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::setProperty(const QString& name, const QVariant& value)
|
||||
DirectMPVBackend::setProperty(const QString& name, const QVariant& value)
|
||||
{
|
||||
mpv::qt::set_property_variant(mpv, name, value);
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::setOption(const QString& name, const QVariant& value)
|
||||
DirectMPVBackend::setOption(const QString& name, const QVariant& value)
|
||||
{
|
||||
mpv::qt::set_option_variant(mpv, name, value);
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::launchAboutQt()
|
||||
DirectMPVBackend::launchAboutQt()
|
||||
{
|
||||
QApplication* qapp =
|
||||
qobject_cast<QApplication*>(QCoreApplication::instance());
|
||||
|
@ -224,13 +224,13 @@ DirectMpvPlayerBackend::launchAboutQt()
|
|||
}
|
||||
|
||||
QVariant
|
||||
DirectMpvPlayerBackend::playerCommand(const Enums::Commands& cmd)
|
||||
DirectMPVBackend::playerCommand(const Enums::Commands& cmd)
|
||||
{
|
||||
return playerCommand(cmd, QVariant("NoArgProvided"));
|
||||
}
|
||||
|
||||
QVariant
|
||||
DirectMpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
||||
DirectMPVBackend::playerCommand(const Enums::Commands& cmd,
|
||||
const QVariant& args)
|
||||
{
|
||||
switch (cmd) {
|
||||
|
@ -392,37 +392,37 @@ DirectMpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::handleWindowChanged(QQuickWindow* win)
|
||||
DirectMPVBackend::handleWindowChanged(QQuickWindow* win)
|
||||
{
|
||||
if (!win)
|
||||
return;
|
||||
connect(win,
|
||||
&QQuickWindow::beforeSynchronizing,
|
||||
this,
|
||||
&DirectMpvPlayerBackend::sync,
|
||||
&DirectMPVBackend::sync,
|
||||
Qt::DirectConnection);
|
||||
connect(win,
|
||||
&QQuickWindow::sceneGraphInvalidated,
|
||||
this,
|
||||
&DirectMpvPlayerBackend::cleanup,
|
||||
&DirectMPVBackend::cleanup,
|
||||
Qt::DirectConnection);
|
||||
connect(win,
|
||||
&QQuickWindow::frameSwapped,
|
||||
this,
|
||||
&DirectMpvPlayerBackend::swapped,
|
||||
&DirectMPVBackend::swapped,
|
||||
Qt::DirectConnection);
|
||||
win->setClearBeforeRendering(false);
|
||||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::toggleOnTop()
|
||||
DirectMPVBackend::toggleOnTop()
|
||||
{
|
||||
onTop = !onTop;
|
||||
Utils::AlwaysOnTop(window()->winId(), onTop);
|
||||
}
|
||||
|
||||
bool
|
||||
DirectMpvPlayerBackend::event(QEvent* event)
|
||||
DirectMPVBackend::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::User) {
|
||||
on_mpv_events();
|
||||
|
@ -431,7 +431,7 @@ DirectMpvPlayerBackend::event(QEvent* event)
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::on_mpv_events()
|
||||
DirectMPVBackend::on_mpv_events()
|
||||
{
|
||||
while (mpv) {
|
||||
mpv_event* event = mpv_wait_event(mpv, 0);
|
||||
|
@ -443,7 +443,7 @@ DirectMpvPlayerBackend::on_mpv_events()
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::updateDurationString(int numTime)
|
||||
DirectMPVBackend::updateDurationString(int numTime)
|
||||
{
|
||||
QVariant speed = getProperty("speed");
|
||||
QMetaMethod metaMethod = sender()->metaObject()->method(senderSignalIndex());
|
||||
|
@ -474,13 +474,13 @@ DirectMpvPlayerBackend::updateDurationString(int numTime)
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::updateAppImage()
|
||||
DirectMPVBackend::updateAppImage()
|
||||
{
|
||||
Utils::updateAppImage();
|
||||
}
|
||||
|
||||
QVariantMap
|
||||
DirectMpvPlayerBackend::getAudioDevices() const
|
||||
DirectMPVBackend::getAudioDevices() const
|
||||
{
|
||||
QVariant drivers = getProperty("audio-device-list");
|
||||
QVariant currentDevice = getProperty("audio-device");
|
||||
|
@ -502,7 +502,7 @@ DirectMpvPlayerBackend::getAudioDevices() const
|
|||
}
|
||||
|
||||
void
|
||||
DirectMpvPlayerBackend::handle_mpv_event(mpv_event* event)
|
||||
DirectMPVBackend::handle_mpv_event(mpv_event* event)
|
||||
{
|
||||
switch (event->event_id) {
|
||||
case MPV_EVENT_PROPERTY_CHANGE: {
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef DirectMpvPlayerBackend_H
|
||||
#define DirectMpvPlayerBackend_H
|
||||
#ifndef DirectMPVBackend_H
|
||||
#define DirectMPVBackend_H
|
||||
|
||||
#include <mpv/client.h>
|
||||
#include <mpv/opengl_cb.h>
|
||||
|
@ -11,8 +11,8 @@
|
|||
#include <QSettings>
|
||||
#include <QWidget>
|
||||
|
||||
#include "backendinterface.hpp"
|
||||
#include "enums.hpp"
|
||||
#include "src/backendinterface.hpp"
|
||||
#include "src/enums.hpp"
|
||||
|
||||
class MpvRenderer : public QObject
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ public slots:
|
|||
void paint();
|
||||
};
|
||||
|
||||
class DirectMpvPlayerBackend
|
||||
class DirectMPVBackend
|
||||
: public QQuickItem
|
||||
, public BackendInterface
|
||||
{
|
||||
|
@ -62,8 +62,8 @@ public:
|
|||
}
|
||||
bool logging() const { return m_logging; }
|
||||
|
||||
DirectMpvPlayerBackend(QQuickItem* parent = 0);
|
||||
virtual ~DirectMpvPlayerBackend();
|
||||
DirectMPVBackend(QQuickItem* parent = 0);
|
||||
virtual ~DirectMPVBackend();
|
||||
|
||||
public slots:
|
||||
QVariant playerCommand(const Enums::Commands& command, const QVariant& args);
|
|
@ -1,6 +1,6 @@
|
|||
#include "MpvPlayerBackend.h"
|
||||
#include "logger.h"
|
||||
#include "utils.hpp"
|
||||
#include "src/Backends/MPV/MPVBackend.hpp"
|
||||
#include "src/logger.h"
|
||||
#include "src/utils.hpp"
|
||||
#include <QApplication>
|
||||
#include <QElapsedTimer>
|
||||
#include <QOpenGLContext>
|
||||
|
@ -27,14 +27,14 @@ namespace {
|
|||
void
|
||||
wakeup(void* ctx)
|
||||
{
|
||||
QCoreApplication::postEvent((MpvPlayerBackend*)ctx, new QEvent(QEvent::User));
|
||||
QCoreApplication::postEvent((MPVBackend*)ctx, new QEvent(QEvent::User));
|
||||
}
|
||||
|
||||
void
|
||||
on_mpv_redraw(void* ctx)
|
||||
{
|
||||
QMetaObject::invokeMethod(
|
||||
reinterpret_cast<MpvPlayerBackend*>(ctx), "update", Qt::QueuedConnection);
|
||||
reinterpret_cast<MPVBackend*>(ctx), "update", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void*
|
||||
|
@ -53,10 +53,10 @@ get_proc_address_mpv(void* ctx, const char* name)
|
|||
|
||||
class MpvRenderer : public QQuickFramebufferObject::Renderer
|
||||
{
|
||||
MpvPlayerBackend* obj;
|
||||
MPVBackend* obj;
|
||||
|
||||
public:
|
||||
MpvRenderer(MpvPlayerBackend* new_obj)
|
||||
MpvRenderer(MPVBackend* new_obj)
|
||||
: obj{ new_obj }
|
||||
{}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
MpvPlayerBackend::MpvPlayerBackend(QQuickItem* parent)
|
||||
MPVBackend::MPVBackend(QQuickItem* parent)
|
||||
: QQuickFramebufferObject(parent)
|
||||
, mpv{ mpv_create() }
|
||||
, mpv_gl(nullptr)
|
||||
|
@ -171,23 +171,23 @@ MpvPlayerBackend::MpvPlayerBackend(QQuickItem* parent)
|
|||
throw std::runtime_error("could not initialize mpv context");
|
||||
|
||||
connect(this,
|
||||
&MpvPlayerBackend::onUpdate,
|
||||
&MPVBackend::onUpdate,
|
||||
this,
|
||||
&MpvPlayerBackend::doUpdate,
|
||||
&MPVBackend::doUpdate,
|
||||
Qt::QueuedConnection);
|
||||
connect(this,
|
||||
&MpvPlayerBackend::positionChanged,
|
||||
&MPVBackend::positionChanged,
|
||||
this,
|
||||
&MpvPlayerBackend::updateDurationString,
|
||||
&MPVBackend::updateDurationString,
|
||||
Qt::QueuedConnection);
|
||||
connect(this,
|
||||
&MpvPlayerBackend::durationChanged,
|
||||
&MPVBackend::durationChanged,
|
||||
this,
|
||||
&MpvPlayerBackend::updateDurationString,
|
||||
&MPVBackend::updateDurationString,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
MpvPlayerBackend::~MpvPlayerBackend()
|
||||
MPVBackend::~MPVBackend()
|
||||
{
|
||||
printf("Shutting down...\n");
|
||||
Utils::SetDPMS(true);
|
||||
|
@ -198,33 +198,33 @@ MpvPlayerBackend::~MpvPlayerBackend()
|
|||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::on_update(void* ctx)
|
||||
MPVBackend::on_update(void* ctx)
|
||||
{
|
||||
MpvPlayerBackend* self = (MpvPlayerBackend*)ctx;
|
||||
MPVBackend* self = (MPVBackend*)ctx;
|
||||
emit self->onUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::doUpdate()
|
||||
MPVBackend::doUpdate()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
QVariant
|
||||
MpvPlayerBackend::getProperty(const QString& name) const
|
||||
MPVBackend::getProperty(const QString& name) const
|
||||
{
|
||||
return mpv::qt::get_property_variant(mpv, name);
|
||||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::command(const QVariant& params)
|
||||
MPVBackend::command(const QVariant& params)
|
||||
{
|
||||
mpv::qt::node_builder node(params);
|
||||
mpv_command_node(mpv, node.node(), nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::setProperty(const QString& name, const QVariant& value)
|
||||
MPVBackend::setProperty(const QString& name, const QVariant& value)
|
||||
{
|
||||
mpv::qt::node_builder node(value);
|
||||
qDebug() << "Setting property" << name << "to" << value;
|
||||
|
@ -232,19 +232,19 @@ MpvPlayerBackend::setProperty(const QString& name, const QVariant& value)
|
|||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::setOption(const QString& name, const QVariant& value)
|
||||
MPVBackend::setOption(const QString& name, const QVariant& value)
|
||||
{
|
||||
mpv::qt::set_option_variant(mpv, name, value);
|
||||
}
|
||||
|
||||
QVariant
|
||||
MpvPlayerBackend::playerCommand(const Enums::Commands& cmd)
|
||||
MPVBackend::playerCommand(const Enums::Commands& cmd)
|
||||
{
|
||||
return playerCommand(cmd, QVariant("NoArgProvided"));
|
||||
}
|
||||
|
||||
QVariant
|
||||
MpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
||||
MPVBackend::playerCommand(const Enums::Commands& cmd,
|
||||
const QVariant& args)
|
||||
{
|
||||
switch (cmd) {
|
||||
|
@ -414,14 +414,14 @@ MpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
|||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::toggleOnTop()
|
||||
MPVBackend::toggleOnTop()
|
||||
{
|
||||
onTop = !onTop;
|
||||
Utils::AlwaysOnTop(window()->winId(), onTop);
|
||||
}
|
||||
|
||||
bool
|
||||
MpvPlayerBackend::event(QEvent* event)
|
||||
MPVBackend::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::User) {
|
||||
on_mpv_events();
|
||||
|
@ -430,7 +430,7 @@ MpvPlayerBackend::event(QEvent* event)
|
|||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::on_mpv_events()
|
||||
MPVBackend::on_mpv_events()
|
||||
{
|
||||
while (mpv) {
|
||||
mpv_event* event = mpv_wait_event(mpv, 0);
|
||||
|
@ -442,7 +442,7 @@ MpvPlayerBackend::on_mpv_events()
|
|||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::updateDurationString(int numTime)
|
||||
MPVBackend::updateDurationString(int numTime)
|
||||
{
|
||||
QVariant speed = getProperty("speed");
|
||||
QMetaMethod metaMethod = sender()->metaObject()->method(senderSignalIndex());
|
||||
|
@ -473,7 +473,7 @@ MpvPlayerBackend::updateDurationString(int numTime)
|
|||
}
|
||||
|
||||
QVariantMap
|
||||
MpvPlayerBackend::getAudioDevices(const QVariant& drivers) const
|
||||
MPVBackend::getAudioDevices(const QVariant& drivers) const
|
||||
{
|
||||
QVariantMap newDrivers;
|
||||
|
||||
|
@ -486,7 +486,7 @@ MpvPlayerBackend::getAudioDevices(const QVariant& drivers) const
|
|||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::handle_mpv_event(mpv_event* event)
|
||||
MPVBackend::handle_mpv_event(mpv_event* event)
|
||||
{
|
||||
switch (event->event_id) {
|
||||
case MPV_EVENT_PROPERTY_CHANGE: {
|
||||
|
@ -590,10 +590,10 @@ MpvPlayerBackend::handle_mpv_event(mpv_event* event)
|
|||
}
|
||||
|
||||
QQuickFramebufferObject::Renderer*
|
||||
MpvPlayerBackend::createRenderer() const
|
||||
MPVBackend::createRenderer() const
|
||||
{
|
||||
window()->setIcon(QIcon(":/icon.png"));
|
||||
window()->setPersistentOpenGLContext(true);
|
||||
window()->setPersistentSceneGraph(true);
|
||||
return new MpvRenderer(const_cast<MpvPlayerBackend*>(this));
|
||||
return new MpvRenderer(const_cast<MPVBackend*>(this));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef MpvPlayerBackend_H
|
||||
#define MpvPlayerBackend_H
|
||||
#ifndef MPVBackend_H
|
||||
#define MPVBackend_H
|
||||
|
||||
#include <mpv/client.h>
|
||||
#include <mpv/qthelper.hpp>
|
||||
|
@ -11,13 +11,13 @@
|
|||
#include <QQuickFramebufferObject>
|
||||
#include <QSettings>
|
||||
|
||||
#include "backendinterface.hpp"
|
||||
#include "enums.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "src/backendinterface.hpp"
|
||||
#include "src/enums.hpp"
|
||||
#include "src/utils.hpp"
|
||||
|
||||
class MpvRenderer;
|
||||
|
||||
class MpvPlayerBackend
|
||||
class MPVBackend
|
||||
: public QQuickFramebufferObject
|
||||
, public BackendInterface
|
||||
{
|
||||
|
@ -42,8 +42,8 @@ class MpvPlayerBackend
|
|||
public:
|
||||
static void on_update(void* ctx);
|
||||
|
||||
MpvPlayerBackend(QQuickItem* parent = 0);
|
||||
virtual ~MpvPlayerBackend();
|
||||
MPVBackend(QQuickItem* parent = 0);
|
||||
virtual ~MPVBackend();
|
||||
virtual Renderer* createRenderer() const;
|
||||
|
||||
void setLogging(bool a)
|
|
@ -50,8 +50,8 @@ Q_ENUM_NS(Commands)
|
|||
|
||||
enum class Backends : int
|
||||
{
|
||||
MpvBackend = 0,
|
||||
DirectMpvBackend = 1
|
||||
MPVBackend = 0,
|
||||
DirectMPVBackend = 1
|
||||
};
|
||||
Q_ENUM_NS(Backends)
|
||||
|
||||
|
|
18
src/main.cpp
18
src/main.cpp
|
@ -1,8 +1,9 @@
|
|||
#include "DirectMpvPlayerBackend.h"
|
||||
#include "Backends/DirectMPV/DirectMPVBackend.hpp"
|
||||
#ifndef DISABLE_MpvPlayerBackend
|
||||
#include "MpvPlayerBackend.h"
|
||||
#include "Backends/MPV/MPVBackend.hpp"
|
||||
#endif
|
||||
|
||||
#include "qmldebugger.h"
|
||||
#include "enums.hpp"
|
||||
#include "logger.h"
|
||||
#include "utils.hpp"
|
||||
|
@ -159,14 +160,15 @@ main(int argc, char* argv[])
|
|||
qRegisterMetaType<Enums::Commands>("Enums.Commands");
|
||||
qmlRegisterType<Process>("player", 1, 0, "Process");
|
||||
|
||||
qmlRegisterType<QMLDebugger>("player", 1, 0, "QMLDebugger");
|
||||
qmlRegisterType<ThumbnailCache>("player", 1, 0, "ThumbnailCache");
|
||||
|
||||
qmlRegisterType<UtilsClass>("player", 1, 0, "Utils");
|
||||
|
||||
if (backendString == "mpv") {
|
||||
backend = Enums::Backends::MpvBackend;
|
||||
backend = Enums::Backends::MPVBackend;
|
||||
} else if (backendString == "direct-mpv") {
|
||||
backend = Enums::Backends::DirectMpvBackend;
|
||||
backend = Enums::Backends::DirectMPVBackend;
|
||||
} else {
|
||||
launcherLogger->error("Invalid backend {}.",
|
||||
backendString.toUtf8().constData());
|
||||
|
@ -176,9 +178,9 @@ main(int argc, char* argv[])
|
|||
launcherLogger->info("Using backend={}", backendString.toUtf8().constData());
|
||||
|
||||
switch (backend) {
|
||||
case Enums::Backends::MpvBackend: {
|
||||
case Enums::Backends::MPVBackend: {
|
||||
#ifndef DISABLE_MpvPlayerBackend
|
||||
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
||||
qmlRegisterType<MPVBackend>("player", 1, 0, "PlayerBackend");
|
||||
#else
|
||||
qDebug() << "Normal MPV backend not available, resetting backend option "
|
||||
"to blank.";
|
||||
|
@ -187,8 +189,8 @@ main(int argc, char* argv[])
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
case Enums::Backends::DirectMpvBackend: {
|
||||
qmlRegisterType<DirectMpvPlayerBackend>("player", 1, 0, "PlayerBackend");
|
||||
case Enums::Backends::DirectMPVBackend: {
|
||||
qmlRegisterType<DirectMPVBackend>("player", 1, 0, "PlayerBackend");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ Window {
|
|||
|
||||
property bool onTop: false
|
||||
|
||||
QMLDebugger {
|
||||
id: qmlDebugger
|
||||
}
|
||||
|
||||
function getAppearanceValueForTheme(themeName, name) {
|
||||
if (themeName == "YouTube") {
|
||||
return youTubeAppearance[name]
|
||||
|
@ -223,6 +227,7 @@ Window {
|
|||
}
|
||||
|
||||
function startPlayer() {
|
||||
console.info(qmlDebugger.properties(player))
|
||||
console.info("OwO!")
|
||||
|
||||
var args = Qt.application.arguments
|
||||
|
|
33
src/qmldebugger.cpp
Normal file
33
src/qmldebugger.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "qmldebugger.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QMetaProperty>
|
||||
|
||||
QString QMLDebugger::properties(QQuickItem *item, bool linebreak)
|
||||
{
|
||||
const QMetaObject *meta = item->metaObject();
|
||||
|
||||
QHash<QString, QVariant> list;
|
||||
for (int i = 0; i < meta->propertyCount(); i++)
|
||||
{
|
||||
QMetaProperty property = meta->property(i);
|
||||
const char* name = property.name();
|
||||
QVariant value = item->property(name);
|
||||
list[name] = value;
|
||||
}
|
||||
|
||||
QString out;
|
||||
QHashIterator<QString, QVariant> i(list);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (!out.isEmpty())
|
||||
{
|
||||
out += ", ";
|
||||
if (linebreak) out += "\n";
|
||||
}
|
||||
out.append(i.key());
|
||||
out.append(": ");
|
||||
out.append(i.value().toString());
|
||||
}
|
||||
return out;
|
||||
}
|
16
src/qmldebugger.h
Normal file
16
src/qmldebugger.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef QMLDEBUGGER_H
|
||||
#define QMLDEBUGGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
|
||||
class QMLDebugger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_INVOKABLE static QString properties(QQuickItem *item, bool linebreak
|
||||
= true);
|
||||
|
||||
};
|
||||
|
||||
#endif // QMLDEBUGGER_H
|
Loading…
Reference in a new issue