From 08e9fcf55a285a700d045dffd833d421362a4b03 Mon Sep 17 00:00:00 2001 From: Kitteh Date: Sun, 21 Oct 2018 13:00:25 +0100 Subject: [PATCH] Minor changes. --- src/main.cpp | 2 +- src/mpvobject.cpp | 26 +++++--------------------- src/mpvobject.h | 3 +-- src/qml/main.qml | 8 ++++---- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f5b8d05..d8f2d4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@ int main( int argc, char *argv[] ) { -setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1); + setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1); QApplication app(argc, argv); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); qmlRegisterType("player", 1, 0, "MpvObject"); diff --git a/src/mpvobject.cpp b/src/mpvobject.cpp index d9d5e2c..2d96342 100644 --- a/src/mpvobject.cpp +++ b/src/mpvobject.cpp @@ -140,7 +140,6 @@ public: // See render_gl.h on what OpenGL environment mpv expects, and // other API details. mpv_render_context_render(obj->mpv_gl, params); - obj->window()->resetOpenGLState(); #else QOpenGLFramebufferObject *fbo = framebufferObject(); @@ -169,24 +168,22 @@ MpvObject::MpvObject(QQuickItem * parent) throw std::runtime_error("could not create mpv context"); mpv_set_option_string(mpv, "terminal", "yes"); - //mpv_set_option_string(mpv, "msg-level", "all=v"); + mpv_set_option_string(mpv, "msg-level", "all=v"); if (mpv_initialize(mpv) < 0) throw std::runtime_error("could not initialize mpv context"); #ifndef USE_RENDER mpv::qt::set_option_variant(mpv, "vo", "opengl-cb"); -#else - mpv::qt::set_option_variant(mpv, "vo", "libmpv"); #endif // Enable default bindings, because we're lazy. Normally, a player using // mpv as backend would implement its own key bindings. - mpv_set_option_string(mpv, "input-default-bindings", "yes"); + // mpv_set_option_string(mpv, "input-default-bindings", "yes"); // Enable keyboard input on the X11 window. For the messy details, see // --input-vo-keyboard on the manpage. - mpv_set_option_string(mpv, "input-vo-keyboard", "yes"); + // mpv_set_option_string(mpv, "input-vo-keyboard", "yes"); // Fix? mpv::qt::set_option_variant(mpv, "ytdl", "yes"); @@ -194,8 +191,6 @@ MpvObject::MpvObject(QQuickItem * parent) mpv_set_option_string(mpv, "input-default-bindings", "yes"); mpv_set_option_string(mpv, "input-vo-keyboard", "yes"); - mpv::qt::set_option_variant(mpv, "idle", "once"); - mpv::qt::set_option_variant(mpv, "hwdec", "off"); mpv::qt::set_option_variant(mpv, "slang", "en"); @@ -229,6 +224,8 @@ mpv_gl = (mpv_opengl_cb_context *)mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB); mpv_opengl_cb_set_update_callback(mpv_gl, MpvObject::on_update, (void *)this); #endif + mpv::qt::set_option_variant(mpv, "idle", "once"); + connect(this, &MpvObject::onUpdate, this, &MpvObject::doUpdate, Qt::QueuedConnection); } @@ -261,19 +258,6 @@ void MpvObject::doUpdate() } -QVariant MpvObject::getThumbnailFile(const QString &name) const -{ - QProcess process; - process.start("youtube-dl --get-thumbnail " + name); - process.waitForFinished(-1); - return process.readAllStandardOutput(); - -} - - - - - QVariant MpvObject::getProperty(const QString &name) const { return mpv::qt::get_property_variant(mpv, name); diff --git a/src/mpvobject.h b/src/mpvobject.h index 3b37be4..4bb3e0c 100644 --- a/src/mpvobject.h +++ b/src/mpvobject.h @@ -55,7 +55,6 @@ public slots: void setProperty(const QString& name, const QVariant& value); void setOption(const QString& name, const QVariant& value); QVariant getProperty(const QString& name) const; - QVariant getThumbnailFile(const QString& name) const; signals: @@ -75,4 +74,4 @@ private: -#endif \ No newline at end of file +#endif diff --git a/src/qml/main.qml b/src/qml/main.qml index 2272452..0c13452 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -133,7 +133,6 @@ Window { id: notoFont source: "fonts/NotoSans.ttf" } - Component.onCompleted: { startPlayer() } function startPlayer() { var args = Qt.application.arguments @@ -145,7 +144,7 @@ Window { for (argNo = 1; argNo < len; argNo++) { var argument = args[argNo] if (argument.indexOf("KittehPlayer") !== -1) { continue; } - /* if (argument.startsWith("--")) { + if (argument.startsWith("--")) { argument = argument.substr(2) if (argument.length > 0) { var splitArg = argument.split(/=(.+)/) @@ -158,9 +157,9 @@ Window { renderer.setOption(splitArg[0], splitArg[1]) } } - } else { */ + } else { renderer.command(["loadfile", argument, "append-play"]) - //} + } } } } @@ -693,5 +692,6 @@ Window { updateControls() } } + Component.onCompleted: { startPlayer() } } }