diff --git a/README.md b/README.md index abf6fb0..b532e7a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ A video player based on Qt, QML and libmpv with themes for many online video pla #### Dependencies ##### Arch Linux ``` -pacman -S git cmake qt5-svg qt5-declarative qt5-quickcontrols qt5-quickcontrols2 mpv +pacman -S git cmake qt5-svg qt5-declarative qt5-quickcontrols qt5-quickcontrols2 qt5-graphicaleffects mpv ``` ##### Ubuntu Xenial ``` diff --git a/src/Backends/MPVCommon/MPVCommon.cpp b/src/Backends/MPVCommon/MPVCommon.cpp index 042eef6..4447b1f 100644 --- a/src/Backends/MPVCommon/MPVCommon.cpp +++ b/src/Backends/MPVCommon/MPVCommon.cpp @@ -3,6 +3,7 @@ #include // IWYU pragma: keep #include #include +#include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep #include @@ -22,7 +23,7 @@ auto mpvLogger = initLogger("mpv"); -static inline QVariant node_to_variant(const mpv_node *node) +static inline QVariant mpvnode_to_variant(const mpv_node *node) { if (!node) { return QVariant(); @@ -41,7 +42,7 @@ static inline QVariant node_to_variant(const mpv_node *node) 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])); + qlist.append(mpvnode_to_variant(&list->values[n])); return QVariant(qlist); } case MPV_FORMAT_NODE_MAP: { @@ -49,7 +50,7 @@ static inline QVariant node_to_variant(const mpv_node *node) QVariantMap qmap; for (int n = 0; n < list->num; n++) { qmap.insert(QString::fromUtf8(list->keys[n]), - node_to_variant(&list->values[n])); + mpvnode_to_variant(&list->values[n])); } return QVariant(qmap); } @@ -489,7 +490,7 @@ handle_mpv_event(BackendInterface *b, mpv_event* event) } } else if (strcmp(prop->name, "pause") == 0) { mpv_node* nod = (mpv_node*)prop->data; - if (node_to_variant(nod).toBool()) { + if (mpvnode_to_variant(nod).toBool()) { emit b->playStatusChanged(Enums::PlayStatus::Paused); // Utils::SetScreensaver(window()->winId(), true); } else { @@ -498,16 +499,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(node_to_variant(nod).toList()); + emit b->tracksChanged(mpvnode_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(node_to_variant(nod))); + emit b->audioDevicesChanged(b->getAudioDevices(mpvnode_to_variant(nod))); } else if (strcmp(prop->name, "playlist") == 0) { mpv_node* nod = (mpv_node*)prop->data; - emit b->playlistChanged(node_to_variant(nod).toList()); + emit b->playlistChanged(mpvnode_to_variant(nod).toList()); } else if (strcmp(prop->name, "chapter-list") == 0) { mpv_node* nod = (mpv_node*)prop->data; - emit b->chaptersChanged(node_to_variant(nod).toList()); + emit b->chaptersChanged(mpvnode_to_variant(nod).toList()); } else if (strcmp(prop->name, "speed") == 0) { double speed = *(double*)prop->data; emit b->speedChanged(speed); diff --git a/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp b/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp index b1681c8..bc54dc3 100644 --- a/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp +++ b/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp @@ -20,7 +20,7 @@ void -wakeup(void* ctx) +nofbowakeup(void* ctx) { QCoreApplication::postEvent((MPVNoFBOBackend*)ctx, new QEvent(QEvent::User)); } @@ -106,7 +106,7 @@ MPVNoFBOBackend::MPVNoFBOBackend(QQuickItem* parent) mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NODE); mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE); mpv_observe_property(mpv, 0, "speed", MPV_FORMAT_DOUBLE); - mpv_set_wakeup_callback(mpv, wakeup, this); + mpv_set_wakeup_callback(mpv, nofbowakeup, this); if (mpv_initialize(mpv) < 0) throw std::runtime_error("could not initialize mpv context"); diff --git a/src/Process.h b/src/Process.h index 7e128d9..4ec6124 100644 --- a/src/Process.h +++ b/src/Process.h @@ -1,3 +1,6 @@ +#ifndef Process_H +#define Process_H + #include #include #include @@ -15,3 +18,4 @@ public: Q_INVOKABLE QString getOutput(); }; +#endif \ No newline at end of file diff --git a/src/ThumbnailCache.h b/src/ThumbnailCache.h index 7c36880..e4cb212 100644 --- a/src/ThumbnailCache.h +++ b/src/ThumbnailCache.h @@ -1,3 +1,5 @@ +#ifndef ThumbnailCache_H +#define ThumbnailCache_H #include #include #include @@ -23,3 +25,4 @@ private: QNetworkAccessManager* manager; QDir cacheFolder; }; +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e801784..f6a6e37 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,7 +114,7 @@ main(int argc, char* argv[]) if (! settings.value("Backend/disableSunxiCheck", false).toBool()) { FILE *fd = popen("grep sunxi /proc/modules", "r"); char buf[16]; - if (fread(buf, 1, sizeof (buf), fd) > 0) + if (fread(buf, 1, sizeof (buf), fd) > 0) { launcherLogger->info("Running on sunxi, switching to NoFBO."); settings.setValue("Backend/fbo", false); settings.setValue("Appearance/clickToPause", false); @@ -122,6 +122,7 @@ main(int argc, char* argv[]) settings.setValue("Appearance/scaleFactor", 2.2); settings.setValue("Appearance/subtitlesFontSize", 38); settings.setValue("Appearance/uiFadeTimer", 2000); + } } #endif diff --git a/src/qml/ControlsBar.qml b/src/qml/ControlsBar.qml index 91c5695..26d6e9b 100644 --- a/src/qml/ControlsBar.qml +++ b/src/qml/ControlsBar.qml @@ -13,10 +13,7 @@ Item { anchors.left: parent.left anchors.right: parent.right - property var background: controlsBackground property var combinedHeight: progressBar.height + controlsBackground.height - property var controls: controlsBar - property var duration: progressBar.to property bool controlsShowing: true Connections { diff --git a/src/qml/MainMenu.qml b/src/qml/MainMenu.qml index 9fa35f3..37179d5 100644 --- a/src/qml/MainMenu.qml +++ b/src/qml/MainMenu.qml @@ -474,10 +474,21 @@ MenuBar { } } + Item { + id: skipToNinthDuration + property var duration: 0 + Connections { + target: player + onDurationChanged: function (duration) { + skipToNinthDuration.duration = duration + } + } + } + function skipToNinth(val) { var skipto = 0 if (val != 0) { - skipto = Math.floor(controlsBar.duration / 9 * val) + skipto = Math.floor(skipToNinthDuration.duration / 9 * val) } player.playerCommand(Enums.Commands.SeekAbsolute, skipto) } diff --git a/src/qml/UIComponents/SmoothButton.qml b/src/qml/UIComponents/SmoothButton.qml index 377ff56..582700b 100644 --- a/src/qml/UIComponents/SmoothButton.qml +++ b/src/qml/UIComponents/SmoothButton.qml @@ -14,6 +14,8 @@ Control { property alias iconHeight: icon.iconHeight property alias iconWidth: icon.iconWidth + property alias containsMouse: mouseArea.containsMouse + background: Item {} property bool iconRight: false @@ -32,6 +34,7 @@ Control { MouseArea { id: mouseArea anchors.fill: parent + hoverEnabled: true propagateComposedEvents: true onClicked: root.clicked() } diff --git a/src/qml/YouTubeButtonLayout.qml b/src/qml/YouTubeButtonLayout.qml index f9eba22..f865e0b 100644 --- a/src/qml/YouTubeButtonLayout.qml +++ b/src/qml/YouTubeButtonLayout.qml @@ -43,14 +43,14 @@ Item { MouseArea { id: mouseAreaVolumeArea anchors.bottom: parent.bottom - anchors.left: volumeButton.left - anchors.right: volumeSlider.right anchors.top: parent.top - width: volumeButton.width + (volumeSlider.visible ? volumeSlider.width : 0) + anchors.left: volumeSlider.left + anchors.right: volumeSlider.right + width: volumeSlider.width hoverEnabled: true propagateComposedEvents: true acceptedButtons: Qt.NoButton - z: 500 + z: 100 } VolumeButton { @@ -60,6 +60,7 @@ Item { anchors.bottom: parent.bottom iconHeight: parent.height / 1.25 iconWidth: parent.height / 1.25 + z: 50 } VolumeSlider { id: volumeSlider diff --git a/src/qml/main.qml b/src/qml/main.qml index 0e2d922..1b59635 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -75,6 +75,7 @@ Window { property int uiFadeTimer: 1000 property bool doubleTapToSeek: true property double doubleTapToSeekBy: 5 + property bool swipeToResize: true // Can fix some screen tearing on some devices. property bool maximizeInsteadOfFullscreen: false } @@ -309,6 +310,7 @@ Window { anchors.fill: parent width: parent.width height: parent.height + enabled: appearance.swipeToResize property real velocity: 0.0 property int xStart: 0 property int xPrev: 0 @@ -331,8 +333,6 @@ Window { appearance.scaleFactor += 0.2 } else if (velocity < -2 && mouse.x > parent.width * 0.2) { appearance.scaleFactor -= 0.2 - } else { - console.info(velocity, mouse.x) } } } @@ -369,7 +369,7 @@ Window { MouseArea { id: mouseAreaPlayer - z: 1000 + z: 10 focus: true width: parent.width anchors.bottom: mouseAreaBar.top diff --git a/src/utils.cpp b/src/utils.cpp index bdffc44..cd46a21 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -14,6 +14,7 @@ #include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep +#undef Bool #endif auto utilsLogger = initLogger("utils"); @@ -134,3 +135,4 @@ AlwaysOnTop(WId wid, bool on) #endif } } +