diff --git a/.gitignore b/.gitignore index dddc7c1..a6b75f0 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,18 @@ qmlcache* qrc_src* discord-rpc *.kate-swp + +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +*_autogen +*.core +.core \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 430bb33..441585f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ endif(CCACHE_FOUND) set(CMAKE_BUILD_TYPE DEBUG) -SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -ggdb -g3 -Og") +SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -ggdb -g3 -O3") if(DEFINED ENV{TRAVIS}) execute_process( diff --git a/src/Backends/MPVCommon/MPVCommon.cpp b/src/Backends/MPVCommon/MPVCommon.cpp index 82b8f7d..4a86ef5 100644 --- a/src/Backends/MPVCommon/MPVCommon.cpp +++ b/src/Backends/MPVCommon/MPVCommon.cpp @@ -7,6 +7,42 @@ auto mpvLogger = initLogger("mpv"); +static inline QVariant node_to_variant(const mpv_node *node) +{ + if (!node) { + return QVariant(); + } + + switch (node->format) { + case MPV_FORMAT_STRING: + return QVariant(QString::fromUtf8(node->u.string)); + case MPV_FORMAT_FLAG: + return QVariant(static_cast(node->u.flag)); + case MPV_FORMAT_INT64: + return QVariant(static_cast(node->u.int64)); + case MPV_FORMAT_DOUBLE: + return QVariant(node->u.double_); + case MPV_FORMAT_NODE_ARRAY: { + mpv_node_list *list = node->u.list; + QVariantList qlist; + for (int n = 0; n < list->num; n++) + qlist.append(node_to_variant(&list->values[n])); + return QVariant(qlist); + } + case MPV_FORMAT_NODE_MAP: { + mpv_node_list *list = node->u.list; + QVariantMap qmap; + for (int n = 0; n < list->num; n++) { + qmap.insert(QString::fromUtf8(list->keys[n]), + node_to_variant(&list->values[n])); + } + return QVariant(qmap); + } + default: // MPV_FORMAT_NONE, unknown values (e.g. future extensions) + return QVariant(); + } +} + namespace MPVCommon { QString getStats(BackendInterface *b) { @@ -349,7 +385,7 @@ QVariant playerCommand(BackendInterface *b, const Enums::Commands& cmd, const QV } default: { - qDebug() << "Command not found: " << cmd; + //qDebug() << "Command not found: " << cmd; break; } } @@ -438,7 +474,7 @@ handle_mpv_event(BackendInterface *b, mpv_event* event) } } else if (strcmp(prop->name, "pause") == 0) { mpv_node* nod = (mpv_node*)prop->data; - if (mpv::qt::node_to_variant(nod).toBool()) { + if (node_to_variant(nod).toBool()) { emit b->playStatusChanged(Enums::PlayStatus::Paused); // Utils::SetScreensaver(window()->winId(), true); } else { @@ -447,16 +483,16 @@ handle_mpv_event(BackendInterface *b, mpv_event* event) } } else if (strcmp(prop->name, "track-list") == 0) { mpv_node* nod = (mpv_node*)prop->data; - emit b->tracksChanged(mpv::qt::node_to_variant(nod).toList()); + emit b->tracksChanged(node_to_variant(nod).toList()); } else if (strcmp(prop->name, "audio-device-list") == 0) { mpv_node* nod = (mpv_node*)prop->data; - emit b->audioDevicesChanged(b->getAudioDevices(mpv::qt::node_to_variant(nod))); + emit b->audioDevicesChanged(b->getAudioDevices(node_to_variant(nod))); } else if (strcmp(prop->name, "playlist") == 0) { mpv_node* nod = (mpv_node*)prop->data; - emit b->playlistChanged(mpv::qt::node_to_variant(nod).toList()); + emit b->playlistChanged(node_to_variant(nod).toList()); } else if (strcmp(prop->name, "chapter-list") == 0) { mpv_node* nod = (mpv_node*)prop->data; - emit b->chaptersChanged(mpv::qt::node_to_variant(nod).toList()); + emit b->chaptersChanged(node_to_variant(nod).toList()); } else if (strcmp(prop->name, "speed") == 0) { double speed = *(double*)prop->data; emit b->speedChanged(speed); @@ -492,6 +528,9 @@ handle_mpv_event(BackendInterface *b, mpv_event* event) QVariantMap getAudioDevices(const QVariant& drivers) { QVariantMap newDrivers; + if (drivers.isNull()) { + return newDrivers; + } QSequentialIterable iterable = drivers.value(); foreach (const QVariant& v, iterable) { diff --git a/src/backendinterface.hpp b/src/backendinterface.hpp index 2ef2b79..1eb9f7e 100644 --- a/src/backendinterface.hpp +++ b/src/backendinterface.hpp @@ -29,7 +29,6 @@ public slots: virtual QVariant getProperty(const QString& name) const = 0; virtual QVariantMap getAudioDevices(const QVariant& drivers) const = 0; - signals: // All below required for Player API virtual void playStatusChanged(const Enums::PlayStatus& status) = 0; diff --git a/src/qml/main.qml b/src/qml/main.qml index 9dcfb1a..7c03e98 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -67,6 +67,7 @@ Window { property double scaleFactor: 1.0 property int subtitlesFontSize: 18 property int uiFadeTimer: 1000 + property bool maximizeInsteadOfFullscreen: false } Settings { @@ -180,16 +181,17 @@ Window { property int lastScreenVisibility function toggleFullscreen() { - console.error("a", mainWindow.visibility, Window.FullScreen, - lastScreenVisibility) - if (mainWindow.visibility != Window.FullScreen) { + var fs = Window.FullScreen + if (appearance.maximizeInsteadOfFullscreen) { + fs = Window.Maximized + } + + if (mainWindow.visibility != fs) { lastScreenVisibility = mainWindow.visibility - mainWindow.visibility = Window.FullScreen + mainWindow.visibility = fs } else { mainWindow.visibility = lastScreenVisibility } - console.error("b", mainWindow.visibility, Window.FullScreen, - lastScreenVisibility) } Utils { @@ -349,9 +351,7 @@ Window { } Action { onTriggered: { - if (mainWindow.visibility == Window.FullScreen) { - toggleFullscreen() - } + toggleFullscreen() } shortcut: "Esc" } @@ -438,12 +438,13 @@ Window { anchors.bottomMargin: 4 anchors.top: parent.top font.family: appearance.fontName - font.pixelSize: menuBar.height - (anchors.bottomMargin + anchors.topMargin) + fontSizeMode: Text.VerticalFit + font.pixelSize: appearance.scaleFactor*(height-anchors.topMargin-anchors.bottomMargin-2) font.bold: true opacity: 1 visible: controlsOverlay.controlsShowing && ((!appearance.titleOnlyOnFullscreen) - || (mainWindow.visibility == Window.FullScreen)) + || (mainWindow.visibility == Window.FullScreen || mainWindow.visibility == Window.Maximized)) Connections { target: player onTitleChanged: function (title) {