1
0
Fork 0

Rework some things, fix deps.

This commit is contained in:
namedkitten 2020-04-24 11:15:49 +01:00
parent bc13e08241
commit 59fecddc0a
12 changed files with 46 additions and 23 deletions

View file

@ -31,7 +31,7 @@ A video player based on Qt, QML and libmpv with themes for many online video pla
#### Dependencies #### Dependencies
##### Arch Linux ##### 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 ##### Ubuntu Xenial
``` ```

View file

@ -3,6 +3,7 @@
#include <qcbormap.h> // IWYU pragma: keep #include <qcbormap.h> // IWYU pragma: keep
#include <qcoreapplication.h> #include <qcoreapplication.h>
#include <qglobal.h> #include <qglobal.h>
#include <qjsonvalue.h> // IWYU pragma: keep
#include <qjsonarray.h> // IWYU pragma: keep #include <qjsonarray.h> // IWYU pragma: keep
#include <qjsonobject.h> // IWYU pragma: keep #include <qjsonobject.h> // IWYU pragma: keep
#include <qlist.h> #include <qlist.h>
@ -22,7 +23,7 @@
auto mpvLogger = initLogger("mpv"); 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) { if (!node) {
return QVariant(); return QVariant();
@ -41,7 +42,7 @@ static inline QVariant node_to_variant(const mpv_node *node)
mpv_node_list *list = node->u.list; mpv_node_list *list = node->u.list;
QVariantList qlist; QVariantList qlist;
for (int n = 0; n < list->num; n++) 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); return QVariant(qlist);
} }
case MPV_FORMAT_NODE_MAP: { case MPV_FORMAT_NODE_MAP: {
@ -49,7 +50,7 @@ static inline QVariant node_to_variant(const mpv_node *node)
QVariantMap qmap; QVariantMap qmap;
for (int n = 0; n < list->num; n++) { for (int n = 0; n < list->num; n++) {
qmap.insert(QString::fromUtf8(list->keys[n]), qmap.insert(QString::fromUtf8(list->keys[n]),
node_to_variant(&list->values[n])); mpvnode_to_variant(&list->values[n]));
} }
return QVariant(qmap); return QVariant(qmap);
} }
@ -489,7 +490,7 @@ handle_mpv_event(BackendInterface *b, mpv_event* event)
} }
} else if (strcmp(prop->name, "pause") == 0) { } else if (strcmp(prop->name, "pause") == 0) {
mpv_node* nod = (mpv_node*)prop->data; 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); emit b->playStatusChanged(Enums::PlayStatus::Paused);
// Utils::SetScreensaver(window()->winId(), true); // Utils::SetScreensaver(window()->winId(), true);
} else { } else {
@ -498,16 +499,16 @@ handle_mpv_event(BackendInterface *b, mpv_event* event)
} }
} else if (strcmp(prop->name, "track-list") == 0) { } else if (strcmp(prop->name, "track-list") == 0) {
mpv_node* nod = (mpv_node*)prop->data; 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) { } else if (strcmp(prop->name, "audio-device-list") == 0) {
mpv_node* nod = (mpv_node*)prop->data; 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) { } else if (strcmp(prop->name, "playlist") == 0) {
mpv_node* nod = (mpv_node*)prop->data; 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) { } else if (strcmp(prop->name, "chapter-list") == 0) {
mpv_node* nod = (mpv_node*)prop->data; 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) { } else if (strcmp(prop->name, "speed") == 0) {
double speed = *(double*)prop->data; double speed = *(double*)prop->data;
emit b->speedChanged(speed); emit b->speedChanged(speed);

View file

@ -20,7 +20,7 @@
void void
wakeup(void* ctx) nofbowakeup(void* ctx)
{ {
QCoreApplication::postEvent((MPVNoFBOBackend*)ctx, new QEvent(QEvent::User)); 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, "pause", MPV_FORMAT_NODE);
mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE); mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE);
mpv_observe_property(mpv, 0, "speed", MPV_FORMAT_DOUBLE); 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) if (mpv_initialize(mpv) < 0)
throw std::runtime_error("could not initialize mpv context"); throw std::runtime_error("could not initialize mpv context");

View file

@ -1,3 +1,6 @@
#ifndef Process_H
#define Process_H
#include <qmetatype.h> #include <qmetatype.h>
#include <qobjectdefs.h> #include <qobjectdefs.h>
#include <qprocess.h> #include <qprocess.h>
@ -15,3 +18,4 @@ public:
Q_INVOKABLE QString getOutput(); Q_INVOKABLE QString getOutput();
}; };
#endif

View file

@ -1,3 +1,5 @@
#ifndef ThumbnailCache_H
#define ThumbnailCache_H
#include <qdir.h> #include <qdir.h>
#include <qobject.h> #include <qobject.h>
#include <qobjectdefs.h> #include <qobjectdefs.h>
@ -23,3 +25,4 @@ private:
QNetworkAccessManager* manager; QNetworkAccessManager* manager;
QDir cacheFolder; QDir cacheFolder;
}; };
#endif

View file

@ -114,7 +114,7 @@ main(int argc, char* argv[])
if (! settings.value("Backend/disableSunxiCheck", false).toBool()) { if (! settings.value("Backend/disableSunxiCheck", false).toBool()) {
FILE *fd = popen("grep sunxi /proc/modules", "r"); FILE *fd = popen("grep sunxi /proc/modules", "r");
char buf[16]; 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."); launcherLogger->info("Running on sunxi, switching to NoFBO.");
settings.setValue("Backend/fbo", false); settings.setValue("Backend/fbo", false);
settings.setValue("Appearance/clickToPause", false); settings.setValue("Appearance/clickToPause", false);
@ -123,6 +123,7 @@ main(int argc, char* argv[])
settings.setValue("Appearance/subtitlesFontSize", 38); settings.setValue("Appearance/subtitlesFontSize", 38);
settings.setValue("Appearance/uiFadeTimer", 2000); settings.setValue("Appearance/uiFadeTimer", 2000);
} }
}
#endif #endif

View file

@ -13,10 +13,7 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
property var background: controlsBackground
property var combinedHeight: progressBar.height + controlsBackground.height property var combinedHeight: progressBar.height + controlsBackground.height
property var controls: controlsBar
property var duration: progressBar.to
property bool controlsShowing: true property bool controlsShowing: true
Connections { Connections {

View file

@ -474,10 +474,21 @@ MenuBar {
} }
} }
Item {
id: skipToNinthDuration
property var duration: 0
Connections {
target: player
onDurationChanged: function (duration) {
skipToNinthDuration.duration = duration
}
}
}
function skipToNinth(val) { function skipToNinth(val) {
var skipto = 0 var skipto = 0
if (val != 0) { if (val != 0) {
skipto = Math.floor(controlsBar.duration / 9 * val) skipto = Math.floor(skipToNinthDuration.duration / 9 * val)
} }
player.playerCommand(Enums.Commands.SeekAbsolute, skipto) player.playerCommand(Enums.Commands.SeekAbsolute, skipto)
} }

View file

@ -14,6 +14,8 @@ Control {
property alias iconHeight: icon.iconHeight property alias iconHeight: icon.iconHeight
property alias iconWidth: icon.iconWidth property alias iconWidth: icon.iconWidth
property alias containsMouse: mouseArea.containsMouse
background: Item {} background: Item {}
property bool iconRight: false property bool iconRight: false
@ -32,6 +34,7 @@ Control {
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true propagateComposedEvents: true
onClicked: root.clicked() onClicked: root.clicked()
} }

View file

@ -43,14 +43,14 @@ Item {
MouseArea { MouseArea {
id: mouseAreaVolumeArea id: mouseAreaVolumeArea
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: volumeButton.left
anchors.right: volumeSlider.right
anchors.top: parent.top 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 hoverEnabled: true
propagateComposedEvents: true propagateComposedEvents: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
z: 500 z: 100
} }
VolumeButton { VolumeButton {
@ -60,6 +60,7 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
iconHeight: parent.height / 1.25 iconHeight: parent.height / 1.25
iconWidth: parent.height / 1.25 iconWidth: parent.height / 1.25
z: 50
} }
VolumeSlider { VolumeSlider {
id: volumeSlider id: volumeSlider

View file

@ -75,6 +75,7 @@ Window {
property int uiFadeTimer: 1000 property int uiFadeTimer: 1000
property bool doubleTapToSeek: true property bool doubleTapToSeek: true
property double doubleTapToSeekBy: 5 property double doubleTapToSeekBy: 5
property bool swipeToResize: true
// Can fix some screen tearing on some devices. // Can fix some screen tearing on some devices.
property bool maximizeInsteadOfFullscreen: false property bool maximizeInsteadOfFullscreen: false
} }
@ -309,6 +310,7 @@ Window {
anchors.fill: parent anchors.fill: parent
width: parent.width width: parent.width
height: parent.height height: parent.height
enabled: appearance.swipeToResize
property real velocity: 0.0 property real velocity: 0.0
property int xStart: 0 property int xStart: 0
property int xPrev: 0 property int xPrev: 0
@ -331,8 +333,6 @@ Window {
appearance.scaleFactor += 0.2 appearance.scaleFactor += 0.2
} else if (velocity < -2 && mouse.x > parent.width * 0.2) { } else if (velocity < -2 && mouse.x > parent.width * 0.2) {
appearance.scaleFactor -= 0.2 appearance.scaleFactor -= 0.2
} else {
console.info(velocity, mouse.x)
} }
} }
} }
@ -369,7 +369,7 @@ Window {
MouseArea { MouseArea {
id: mouseAreaPlayer id: mouseAreaPlayer
z: 1000 z: 10
focus: true focus: true
width: parent.width width: parent.width
anchors.bottom: mouseAreaBar.top anchors.bottom: mouseAreaBar.top

View file

@ -14,6 +14,7 @@
#include <X11/Xutil.h> // IWYU pragma: keep #include <X11/Xutil.h> // IWYU pragma: keep
#include <qx11info_x11.h> // IWYU pragma: keep #include <qx11info_x11.h> // IWYU pragma: keep
#include <QX11Info> // IWYU pragma: keep #include <QX11Info> // IWYU pragma: keep
#undef Bool
#endif #endif
auto utilsLogger = initLogger("utils"); auto utilsLogger = initLogger("utils");
@ -134,3 +135,4 @@ AlwaysOnTop(WId wid, bool on)
#endif #endif
} }
} }