Reformat code.
This commit is contained in:
parent
e1dd828968
commit
9cf2aafd73
5
.clang-format
Normal file
5
.clang-format
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: WebKit
|
||||||
|
...
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -x
|
||||||
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||||
pushd $SOURCE_DIR
|
pushd $SOURCE_DIR
|
||||||
find . -name "*.qml" -exec qmlfmt -w {} \;
|
find . -name "*.qml" -exec qmlfmt -i 2 -w {} \;
|
||||||
find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" -exec clang-format90 -style mozilla -i {} \;
|
clang-format -style=file -i $(find src -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h")
|
||||||
|
#find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" -exec clang-format -style=file -i {} \;
|
||||||
popd
|
popd
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#include "src/Backends/MPV/MPVBackend.hpp"
|
#include "src/Backends/MPV/MPVBackend.hpp"
|
||||||
#include <QtCore/qglobal.h>
|
#include "src/Backends/MPVCommon/MPVCommon.hpp"
|
||||||
#include <mpv/render_gl.h>
|
#include "src/qthelper.hpp"
|
||||||
|
#include "src/utils.hpp"
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QEvent>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <stdio.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "src/qthelper.hpp"
|
#include <mpv/render_gl.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "src/Backends/MPVCommon/MPVCommon.hpp"
|
#include <stdio.h>
|
||||||
#include "src/utils.hpp"
|
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class QSize;
|
class QSize;
|
||||||
|
|
||||||
|
@ -26,27 +26,23 @@ class QSize;
|
||||||
#ifdef ENABLE_X11
|
#ifdef ENABLE_X11
|
||||||
#include <QX11Info> // IWYU pragma: keep
|
#include <QX11Info> // IWYU pragma: keep
|
||||||
#include <QtX11Extras/QX11Info> // IWYU pragma: keep
|
#include <QtX11Extras/QX11Info> // IWYU pragma: keep
|
||||||
#include <qx11info_x11.h> // IWYU pragma: keep
|
|
||||||
#include <X11/Xlib.h> // IWYU pragma: keep
|
#include <X11/Xlib.h> // IWYU pragma: keep
|
||||||
#include <X11/Xutil.h> // IWYU pragma: keep
|
#include <X11/Xutil.h> // IWYU pragma: keep
|
||||||
|
#include <qx11info_x11.h> // IWYU pragma: keep
|
||||||
#endif
|
#endif
|
||||||
#include <qpa/qplatformnativeinterface.h> // IWYU pragma: keep
|
#include <qpa/qplatformnativeinterface.h> // IWYU pragma: keep
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool usedirect = false;
|
bool usedirect = false;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void
|
void wakeup(void* ctx)
|
||||||
wakeup(void* ctx)
|
|
||||||
{
|
{
|
||||||
QCoreApplication::postEvent((MPVBackend*)ctx, new QEvent(QEvent::User));
|
QCoreApplication::postEvent((MPVBackend*)ctx, new QEvent(QEvent::User));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void on_mpv_redraw(void* ctx)
|
||||||
on_mpv_redraw(void* ctx)
|
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
reinterpret_cast<MPVBackend*>(ctx), "update", Qt::QueuedConnection);
|
reinterpret_cast<MPVBackend*>(ctx), "update", Qt::QueuedConnection);
|
||||||
|
@ -61,8 +57,7 @@ get_proc_address_mpv(void* ctx, const char* name)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class MpvRenderer : public QQuickFramebufferObject::Renderer
|
class MpvRenderer : public QQuickFramebufferObject::Renderer {
|
||||||
{
|
|
||||||
MPVBackend* obj;
|
MPVBackend* obj;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -70,14 +65,12 @@ public:
|
||||||
: obj{ new_obj }
|
: obj{ new_obj }
|
||||||
{
|
{
|
||||||
if (usedirect) {
|
if (usedirect) {
|
||||||
int r =
|
int r = mpv_opengl_cb_init_gl(obj->mpv_gl_cb, NULL, get_proc_address_mpv, QOpenGLContext::currentContext());
|
||||||
mpv_opengl_cb_init_gl(obj->mpv_gl_cb, NULL, get_proc_address_mpv, QOpenGLContext::currentContext());
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
std::cout << "No." << std::endl;
|
std::cout << "No." << std::endl;
|
||||||
throw std::runtime_error("failed to initialize mpv GL context");
|
throw std::runtime_error("failed to initialize mpv GL context");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~MpvRenderer() {}
|
virtual ~MpvRenderer() {}
|
||||||
|
@ -120,7 +113,6 @@ public:
|
||||||
}
|
}
|
||||||
QMetaObject::invokeMethod(obj, "startPlayer");
|
QMetaObject::invokeMethod(obj, "startPlayer");
|
||||||
|
|
||||||
|
|
||||||
return QQuickFramebufferObject::Renderer::createFramebufferObject(size);
|
return QQuickFramebufferObject::Renderer::createFramebufferObject(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,15 +228,13 @@ MPVBackend::~MPVBackend()
|
||||||
printf("MPV terminated.\n");
|
printf("MPV terminated.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::on_update(void* ctx)
|
||||||
MPVBackend::on_update(void* ctx)
|
|
||||||
{
|
{
|
||||||
MPVBackend* self = (MPVBackend*)ctx;
|
MPVBackend* self = (MPVBackend*)ctx;
|
||||||
emit self->onUpdate();
|
emit self->onUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::doUpdate()
|
||||||
MPVBackend::doUpdate()
|
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -255,23 +245,20 @@ MPVBackend::getProperty(const QString& name) const
|
||||||
return mpv::qt::get_property_variant(mpv, name);
|
return mpv::qt::get_property_variant(mpv, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::command(const QVariant& params)
|
||||||
MPVBackend::command(const QVariant& params)
|
|
||||||
{
|
{
|
||||||
mpv::qt::node_builder node(params);
|
mpv::qt::node_builder node(params);
|
||||||
mpv_command_node(mpv, node.node(), nullptr);
|
mpv_command_node(mpv, node.node(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::setProperty(const QString& name, const QVariant& value)
|
||||||
MPVBackend::setProperty(const QString& name, const QVariant& value)
|
|
||||||
{
|
{
|
||||||
mpv::qt::node_builder node(value);
|
mpv::qt::node_builder node(value);
|
||||||
qDebug() << "Setting property" << name << "to" << value;
|
qDebug() << "Setting property" << name << "to" << value;
|
||||||
mpv_set_property(mpv, name.toUtf8().data(), MPV_FORMAT_NODE, node.node());
|
mpv_set_property(mpv, name.toUtf8().data(), MPV_FORMAT_NODE, node.node());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::setOption(const QString& name, const QVariant& value)
|
||||||
MPVBackend::setOption(const QString& name, const QVariant& value)
|
|
||||||
{
|
{
|
||||||
mpv::qt::set_option_variant(mpv, name, value);
|
mpv::qt::set_option_variant(mpv, name, value);
|
||||||
}
|
}
|
||||||
|
@ -294,24 +281,19 @@ MPVBackend::getStats()
|
||||||
return MPVCommon::getStats(this);
|
return MPVCommon::getStats(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MPVBackend::updateDurationString(int numTime)
|
||||||
void
|
|
||||||
MPVBackend::updateDurationString(int numTime)
|
|
||||||
{
|
{
|
||||||
QMetaMethod metaMethod = sender()->metaObject()->method(senderSignalIndex());
|
QMetaMethod metaMethod = sender()->metaObject()->method(senderSignalIndex());
|
||||||
MPVCommon::updateDurationString(this, numTime, metaMethod);
|
MPVCommon::updateDurationString(this, numTime, metaMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MPVBackend::toggleOnTop()
|
||||||
void
|
|
||||||
MPVBackend::toggleOnTop()
|
|
||||||
{
|
{
|
||||||
onTop = !onTop;
|
onTop = !onTop;
|
||||||
Utils::AlwaysOnTop(window()->winId(), onTop);
|
Utils::AlwaysOnTop(window()->winId(), onTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool MPVBackend::event(QEvent* event)
|
||||||
MPVBackend::event(QEvent* event)
|
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::User) {
|
if (event->type() == QEvent::User) {
|
||||||
on_mpv_events();
|
on_mpv_events();
|
||||||
|
@ -319,8 +301,7 @@ MPVBackend::event(QEvent* event)
|
||||||
return QObject::event(event);
|
return QObject::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::on_mpv_events()
|
||||||
MPVBackend::on_mpv_events()
|
|
||||||
{
|
{
|
||||||
while (mpv) {
|
while (mpv) {
|
||||||
mpv_event* event = mpv_wait_event(mpv, 0);
|
mpv_event* event = mpv_wait_event(mpv, 0);
|
||||||
|
@ -337,8 +318,7 @@ MPVBackend::getAudioDevices(const QVariant& drivers) const
|
||||||
return MPVCommon::getAudioDevices(drivers);
|
return MPVCommon::getAudioDevices(drivers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVBackend::handle_mpv_event(mpv_event* event)
|
||||||
MPVBackend::handle_mpv_event(mpv_event* event)
|
|
||||||
{
|
{
|
||||||
MPVCommon::handle_mpv_event(this, event);
|
MPVCommon::handle_mpv_event(this, event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
#ifndef MPVBackend_H
|
#ifndef MPVBackend_H
|
||||||
#define MPVBackend_H
|
#define MPVBackend_H
|
||||||
|
|
||||||
#include <mpv/client.h>
|
#include "src/backendinterface.hpp"
|
||||||
#include <mpv/opengl_cb.h>
|
#include "src/enums.hpp"
|
||||||
#include <mpv/render.h>
|
#include <QEvent>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QEvent>
|
|
||||||
#include <QQuickItem>
|
|
||||||
#include <QQuickFramebufferObject>
|
#include <QQuickFramebufferObject>
|
||||||
|
#include <QQuickItem>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "src/backendinterface.hpp"
|
#include <mpv/client.h>
|
||||||
#include "src/enums.hpp"
|
#include <mpv/opengl_cb.h>
|
||||||
|
#include <mpv/render.h>
|
||||||
|
|
||||||
class MPVBackend
|
class MPVBackend
|
||||||
: public QQuickFramebufferObject
|
: public QQuickFramebufferObject,
|
||||||
, public BackendInterface
|
public BackendInterface {
|
||||||
{
|
|
||||||
Q_INTERFACES(BackendInterface)
|
Q_INTERFACES(BackendInterface)
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#include "src/Backends/MPVCommon/MPVCommon.hpp"
|
#include "src/Backends/MPVCommon/MPVCommon.hpp"
|
||||||
|
#include "spdlog/logger.h"
|
||||||
|
#include "src/backendinterface.hpp"
|
||||||
|
#include "src/logger.h"
|
||||||
|
#include "src/utils.hpp"
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMetaObject>
|
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
|
#include <QMetaObject>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <spdlog/fmt/fmt.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "spdlog/logger.h"
|
#include <spdlog/fmt/fmt.h>
|
||||||
#include "src/backendinterface.hpp"
|
#include <string.h>
|
||||||
#include "src/logger.h"
|
|
||||||
#include "src/utils.hpp"
|
|
||||||
|
|
||||||
auto mpvLogger = initLogger("mpv");
|
auto mpvLogger = initLogger("mpv");
|
||||||
|
|
||||||
|
@ -74,12 +74,11 @@ static inline QVariant mpvnode_to_variant(const mpv_node *node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace MPVCommon {
|
namespace MPVCommon {
|
||||||
QString getStats(BackendInterface *b) {
|
QString getStats(BackendInterface* b)
|
||||||
|
{
|
||||||
QString stats;
|
QString stats;
|
||||||
stats =
|
stats = "<style> blockquote { text-indent: 0px; margin-left:40px; margin-top: 0px; "
|
||||||
"<style> blockquote { text-indent: 0px; margin-left:40px; margin-top: 0px; "
|
|
||||||
"margin-bottom: 0px; padding-bottom: 0px; padding-top: 0px; padding-left: "
|
"margin-bottom: 0px; padding-bottom: 0px; padding-top: 0px; padding-left: "
|
||||||
"0px; } b span p br { margin-bottom: 0px; margin-top: 0px; padding-top: "
|
"0px; } b span p br { margin-bottom: 0px; margin-top: 0px; padding-top: "
|
||||||
"0px; padding-botom: 0px; text-indent: 0px; } </style>";
|
"0px; padding-botom: 0px; text-indent: 0px; } </style>";
|
||||||
|
@ -116,8 +115,7 @@ QString getStats(BackendInterface *b) {
|
||||||
cacheStats += "<br>";
|
cacheStats += "<br>";
|
||||||
stats += cacheStats;
|
stats += cacheStats;
|
||||||
}
|
}
|
||||||
QString fileSize =
|
QString fileSize = humanSize(b->getProperty("file-size").toInt()).remove("-");
|
||||||
humanSize(b->getProperty("file-size").toInt()).remove("-");
|
|
||||||
stats += "<b>Size:</b> " + fileSize + "<br>";
|
stats += "<b>Size:</b> " + fileSize + "<br>";
|
||||||
|
|
||||||
stats += "</blockquote>";
|
stats += "</blockquote>";
|
||||||
|
@ -284,10 +282,8 @@ QVariant playerCommand(BackendInterface *b, const Enums::Commands& cmd, const QV
|
||||||
|
|
||||||
case Enums::Commands::AddSpeed: {
|
case Enums::Commands::AddSpeed: {
|
||||||
|
|
||||||
QString speedString =
|
QString speedString = QString::number(b->getProperty("speed").toDouble() + args.toDouble());
|
||||||
QString::number(b->getProperty("speed").toDouble() + args.toDouble());
|
QVariant newSpeed = QVariant(speedString.left(speedString.lastIndexOf('.') + 2));
|
||||||
QVariant newSpeed =
|
|
||||||
QVariant(speedString.left(speedString.lastIndexOf('.') + 2));
|
|
||||||
|
|
||||||
b->playerCommand(Enums::Commands::SetSpeed, newSpeed);
|
b->playerCommand(Enums::Commands::SetSpeed, newSpeed);
|
||||||
break;
|
break;
|
||||||
|
@ -295,10 +291,8 @@ QVariant playerCommand(BackendInterface *b, const Enums::Commands& cmd, const QV
|
||||||
|
|
||||||
case Enums::Commands::SubtractSpeed: {
|
case Enums::Commands::SubtractSpeed: {
|
||||||
|
|
||||||
QString speedString =
|
QString speedString = QString::number(b->getProperty("speed").toDouble() - args.toDouble());
|
||||||
QString::number(b->getProperty("speed").toDouble() - args.toDouble());
|
QVariant newSpeed = QVariant(speedString.left(speedString.lastIndexOf('.') + 2));
|
||||||
QVariant newSpeed =
|
|
||||||
QVariant(speedString.left(speedString.lastIndexOf('.') + 2));
|
|
||||||
b->playerCommand(Enums::Commands::SetSpeed, newSpeed);
|
b->playerCommand(Enums::Commands::SetSpeed, newSpeed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -442,16 +436,14 @@ void updateDurationString(BackendInterface *b, int numTime, QMetaMethod metaMeth
|
||||||
durationString += " / ";
|
durationString += " / ";
|
||||||
durationString += b->totalDurationString;
|
durationString += b->totalDurationString;
|
||||||
if (b->lastSpeed != 1) {
|
if (b->lastSpeed != 1) {
|
||||||
if (settings.value("Appearance/themeName", "").toString() !=
|
if (settings.value("Appearance/themeName", "").toString() != "RoosterTeeth") {
|
||||||
"RoosterTeeth") {
|
|
||||||
durationString += " (" + speed.toString() + "x)";
|
durationString += " (" + speed.toString() + "x)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit b->durationStringChanged(durationString);
|
emit b->durationStringChanged(durationString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void handle_mpv_event(BackendInterface* b, mpv_event* event)
|
||||||
handle_mpv_event(BackendInterface *b, mpv_event* event)
|
|
||||||
{
|
{
|
||||||
switch (event->event_id) {
|
switch (event->event_id) {
|
||||||
case MPV_EVENT_PROPERTY_CHANGE: {
|
case MPV_EVENT_PROPERTY_CHANGE: {
|
||||||
|
@ -466,8 +458,7 @@ handle_mpv_event(BackendInterface *b, mpv_event* event)
|
||||||
double time = *(double*)prop->data;
|
double time = *(double*)prop->data;
|
||||||
emit b->durationChanged(time);
|
emit b->durationChanged(time);
|
||||||
}
|
}
|
||||||
} else if (strcmp(prop->name, "mute") == 0 ||
|
} else if (strcmp(prop->name, "mute") == 0 || strcmp(prop->name, "volume") == 0) {
|
||||||
strcmp(prop->name, "volume") == 0) {
|
|
||||||
double volume = b->getProperty("volume").toDouble();
|
double volume = b->getProperty("volume").toDouble();
|
||||||
bool mute = b->getProperty("mute").toBool();
|
bool mute = b->getProperty("mute").toBool();
|
||||||
if (mute || volume == 0) {
|
if (mute || volume == 0) {
|
||||||
|
@ -529,8 +520,7 @@ handle_mpv_event(BackendInterface *b, mpv_event* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
case MPV_EVENT_LOG_MESSAGE: {
|
case MPV_EVENT_LOG_MESSAGE: {
|
||||||
struct mpv_event_log_message* msg =
|
struct mpv_event_log_message* msg = (struct mpv_event_log_message*)event->data;
|
||||||
(struct mpv_event_log_message*)event->data;
|
|
||||||
QString logMsg = "[" + QString(msg->prefix) + "] " + QString(msg->text);
|
QString logMsg = "[" + QString(msg->prefix) + "] " + QString(msg->text);
|
||||||
QString msgLevel = QString(msg->level);
|
QString msgLevel = QString(msg->level);
|
||||||
if (msgLevel.startsWith("d") || msgLevel.startsWith("t")) {
|
if (msgLevel.startsWith("d") || msgLevel.startsWith("t")) {
|
||||||
|
@ -567,5 +557,4 @@ QVariantMap getAudioDevices(const QVariant& drivers)
|
||||||
}
|
}
|
||||||
return newDrivers;
|
return newDrivers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,15 +1,14 @@
|
||||||
#ifndef MPVCommon_H
|
#ifndef MPVCommon_H
|
||||||
#define MPVCommon_H
|
#define MPVCommon_H
|
||||||
|
|
||||||
#include <mpv/client.h>
|
#include "src/enums.hpp"
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "src/enums.hpp"
|
#include <mpv/client.h>
|
||||||
class BackendInterface;
|
class BackendInterface;
|
||||||
class QMetaMethod;
|
class QMetaMethod;
|
||||||
|
|
||||||
|
|
||||||
namespace MPVCommon {
|
namespace MPVCommon {
|
||||||
|
|
||||||
QString getStats(BackendInterface* b);
|
QString getStats(BackendInterface* b);
|
||||||
|
@ -17,8 +16,6 @@ QVariant playerCommand(BackendInterface *b, const Enums::Commands& cmd, const QV
|
||||||
void updateDurationString(BackendInterface* b, int numTime, QMetaMethod metaMethod);
|
void updateDurationString(BackendInterface* b, int numTime, QMetaMethod metaMethod);
|
||||||
void handle_mpv_event(BackendInterface* b, mpv_event* event);
|
void handle_mpv_event(BackendInterface* b, mpv_event* event);
|
||||||
QVariantMap getAudioDevices(const QVariant& drivers);
|
QVariantMap getAudioDevices(const QVariant& drivers);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,24 +1,22 @@
|
||||||
#include "src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp"
|
#include "src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp"
|
||||||
|
#include "src/Backends/MPVCommon/MPVCommon.hpp"
|
||||||
|
#include "src/qthelper.hpp"
|
||||||
|
#include "src/utils.hpp"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QEvent>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QEvent>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
|
#include <clocale>
|
||||||
|
#include <stdexcept>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <clocale>
|
|
||||||
#include "src/qthelper.hpp"
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "src/Backends/MPVCommon/MPVCommon.hpp"
|
|
||||||
#include "src/utils.hpp"
|
|
||||||
|
|
||||||
|
void nofbowakeup(void* ctx)
|
||||||
void
|
|
||||||
nofbowakeup(void* ctx)
|
|
||||||
{
|
{
|
||||||
QCoreApplication::postEvent((MPVNoFBOBackend*)ctx, new QEvent(QEvent::User));
|
QCoreApplication::postEvent((MPVNoFBOBackend*)ctx, new QEvent(QEvent::User));
|
||||||
}
|
}
|
||||||
|
@ -52,8 +50,7 @@ MPVNoFBORenderer::~MPVNoFBORenderer()
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBORenderer::paint()
|
||||||
MPVNoFBORenderer::paint()
|
|
||||||
{
|
{
|
||||||
window->resetOpenGLState();
|
window->resetOpenGLState();
|
||||||
|
|
||||||
|
@ -145,8 +142,7 @@ MPVNoFBOBackend::~MPVNoFBOBackend()
|
||||||
printf("MPV terminated.\n");
|
printf("MPV terminated.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::sync()
|
||||||
MPVNoFBOBackend::sync()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
|
@ -163,14 +159,12 @@ MPVNoFBOBackend::sync()
|
||||||
renderer->size = window()->size() * window()->devicePixelRatio();
|
renderer->size = window()->size() * window()->devicePixelRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::swapped()
|
||||||
MPVNoFBOBackend::swapped()
|
|
||||||
{
|
{
|
||||||
mpv_opengl_cb_report_flip(mpv_gl, 0);
|
mpv_opengl_cb_report_flip(mpv_gl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::cleanup()
|
||||||
MPVNoFBOBackend::cleanup()
|
|
||||||
{
|
{
|
||||||
if (renderer) {
|
if (renderer) {
|
||||||
delete renderer;
|
delete renderer;
|
||||||
|
@ -178,15 +172,13 @@ MPVNoFBOBackend::cleanup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::on_update(void* ctx)
|
||||||
MPVNoFBOBackend::on_update(void* ctx)
|
|
||||||
{
|
{
|
||||||
MPVNoFBOBackend* self = (MPVNoFBOBackend*)ctx;
|
MPVNoFBOBackend* self = (MPVNoFBOBackend*)ctx;
|
||||||
emit self->onUpdate();
|
emit self->onUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::doUpdate()
|
||||||
MPVNoFBOBackend::doUpdate()
|
|
||||||
{
|
{
|
||||||
window()->update();
|
window()->update();
|
||||||
update();
|
update();
|
||||||
|
@ -198,29 +190,24 @@ MPVNoFBOBackend::getProperty(const QString& name) const
|
||||||
return mpv::qt::get_property_variant(mpv, name);
|
return mpv::qt::get_property_variant(mpv, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::command(const QVariant& params)
|
||||||
MPVNoFBOBackend::command(const QVariant& params)
|
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, params);
|
mpv::qt::command_variant(mpv, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::setProperty(const QString& name, const QVariant& value)
|
||||||
MPVNoFBOBackend::setProperty(const QString& name, const QVariant& value)
|
|
||||||
{
|
{
|
||||||
mpv::qt::set_property_variant(mpv, name, value);
|
mpv::qt::set_property_variant(mpv, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::setOption(const QString& name, const QVariant& value)
|
||||||
MPVNoFBOBackend::setOption(const QString& name, const QVariant& value)
|
|
||||||
{
|
{
|
||||||
mpv::qt::set_option_variant(mpv, name, value);
|
mpv::qt::set_option_variant(mpv, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::launchAboutQt()
|
||||||
MPVNoFBOBackend::launchAboutQt()
|
|
||||||
{
|
{
|
||||||
QApplication* qapp =
|
QApplication* qapp = qobject_cast<QApplication*>(QCoreApplication::instance());
|
||||||
qobject_cast<QApplication*>(QCoreApplication::instance());
|
|
||||||
qapp->aboutQt();
|
qapp->aboutQt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +224,7 @@ MPVNoFBOBackend::playerCommand(const Enums::Commands& cmd,
|
||||||
return MPVCommon::playerCommand(this, cmd, args);
|
return MPVCommon::playerCommand(this, cmd, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::handleWindowChanged(QQuickWindow* win)
|
||||||
MPVNoFBOBackend::handleWindowChanged(QQuickWindow* win)
|
|
||||||
{
|
{
|
||||||
if (!win)
|
if (!win)
|
||||||
return;
|
return;
|
||||||
|
@ -260,15 +246,13 @@ MPVNoFBOBackend::handleWindowChanged(QQuickWindow* win)
|
||||||
win->setClearBeforeRendering(false);
|
win->setClearBeforeRendering(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::toggleOnTop()
|
||||||
MPVNoFBOBackend::toggleOnTop()
|
|
||||||
{
|
{
|
||||||
onTop = !onTop;
|
onTop = !onTop;
|
||||||
Utils::AlwaysOnTop(window()->winId(), onTop);
|
Utils::AlwaysOnTop(window()->winId(), onTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool MPVNoFBOBackend::event(QEvent* event)
|
||||||
MPVNoFBOBackend::event(QEvent* event)
|
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::User) {
|
if (event->type() == QEvent::User) {
|
||||||
on_mpv_events();
|
on_mpv_events();
|
||||||
|
@ -276,8 +260,7 @@ MPVNoFBOBackend::event(QEvent* event)
|
||||||
return QObject::event(event);
|
return QObject::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::on_mpv_events()
|
||||||
MPVNoFBOBackend::on_mpv_events()
|
|
||||||
{
|
{
|
||||||
while (mpv) {
|
while (mpv) {
|
||||||
mpv_event* event = mpv_wait_event(mpv, 0);
|
mpv_event* event = mpv_wait_event(mpv, 0);
|
||||||
|
@ -288,8 +271,7 @@ MPVNoFBOBackend::on_mpv_events()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::updateDurationString(int numTime)
|
||||||
MPVNoFBOBackend::updateDurationString(int numTime)
|
|
||||||
{
|
{
|
||||||
QMetaMethod metaMethod = sender()->metaObject()->method(senderSignalIndex());
|
QMetaMethod metaMethod = sender()->metaObject()->method(senderSignalIndex());
|
||||||
MPVCommon::updateDurationString(this, numTime, metaMethod);
|
MPVCommon::updateDurationString(this, numTime, metaMethod);
|
||||||
|
@ -301,8 +283,7 @@ MPVNoFBOBackend::getAudioDevices(const QVariant& drivers) const
|
||||||
return MPVCommon::getAudioDevices(drivers);
|
return MPVCommon::getAudioDevices(drivers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MPVNoFBOBackend::handle_mpv_event(mpv_event* event)
|
||||||
MPVNoFBOBackend::handle_mpv_event(mpv_event* event)
|
|
||||||
{
|
{
|
||||||
MPVCommon::handle_mpv_event(this, event);
|
MPVCommon::handle_mpv_event(this, event);
|
||||||
}
|
}
|
||||||
|
@ -312,5 +293,3 @@ MPVNoFBOBackend::getStats()
|
||||||
{
|
{
|
||||||
return MPVCommon::getStats(this);
|
return MPVCommon::getStats(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef MPVNoFBOBackend_H
|
#ifndef MPVNoFBOBackend_H
|
||||||
#define MPVNoFBOBackend_H
|
#define MPVNoFBOBackend_H
|
||||||
|
|
||||||
#include <mpv/client.h>
|
#include "src/backendinterface.hpp"
|
||||||
#include <mpv/opengl_cb.h>
|
#include "src/enums.hpp"
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -12,11 +12,10 @@
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "src/backendinterface.hpp"
|
#include <mpv/client.h>
|
||||||
#include "src/enums.hpp"
|
#include <mpv/opengl_cb.h>
|
||||||
|
|
||||||
class MPVNoFBORenderer : public QObject
|
class MPVNoFBORenderer : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
mpv_handle* mpv;
|
mpv_handle* mpv;
|
||||||
mpv_opengl_cb_context* mpv_gl;
|
mpv_opengl_cb_context* mpv_gl;
|
||||||
|
@ -33,9 +32,8 @@ public slots:
|
||||||
};
|
};
|
||||||
|
|
||||||
class MPVNoFBOBackend
|
class MPVNoFBOBackend
|
||||||
: public QQuickItem
|
: public QQuickItem,
|
||||||
, public BackendInterface
|
public BackendInterface {
|
||||||
{
|
|
||||||
Q_INTERFACES(BackendInterface)
|
Q_INTERFACES(BackendInterface)
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -5,10 +5,10 @@ class QObject;
|
||||||
|
|
||||||
Process::Process(QObject* parent)
|
Process::Process(QObject* parent)
|
||||||
: QProcess(parent)
|
: QProcess(parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void Process::start(const QString& program, const QVariantList& arguments)
|
||||||
Process::start(const QString& program, const QVariantList& arguments)
|
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class Process : public QProcess
|
class Process : public QProcess {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QIODevice>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QIODevice>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
@ -16,16 +16,13 @@ ThumbnailCache::ThumbnailCache(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, manager(new QNetworkAccessManager(this))
|
, manager(new QNetworkAccessManager(this))
|
||||||
{
|
{
|
||||||
cacheFolder =
|
cacheFolder = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/thumbs");
|
||||||
QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
|
|
||||||
"/thumbs");
|
|
||||||
if (!cacheFolder.exists()) {
|
if (!cacheFolder.exists()) {
|
||||||
cacheFolder.mkpath(".");
|
cacheFolder.mkpath(".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ThumbnailCache::addURL(const QString& name, const QString& mediaURL)
|
||||||
ThumbnailCache::addURL(const QString& name, const QString& mediaURL)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
QString hashedURL = QString(
|
QString hashedURL = QString(
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef ThumbnailCache_H
|
#ifndef ThumbnailCache_H
|
||||||
#define ThumbnailCache_H
|
#define ThumbnailCache_H
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
|
|
||||||
class ThumbnailCache : public QObject
|
class ThumbnailCache : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -16,8 +15,7 @@ public slots:
|
||||||
Q_INVOKABLE void addURL(const QString& name, const QString& url);
|
Q_INVOKABLE void addURL(const QString& name, const QString& url);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void thumbnailReady(const QString& name,
|
void thumbnailReady(const QString& name, const QString& url,
|
||||||
const QString& url,
|
|
||||||
const QString& filePath);
|
const QString& filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
#define BackendInterface_H
|
#define BackendInterface_H
|
||||||
#include "enums.hpp"
|
#include "enums.hpp"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
class BackendInterface
|
class BackendInterface {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~BackendInterface(){};
|
virtual ~BackendInterface(){};
|
||||||
int lastTime = 0;
|
int lastTime = 0;
|
||||||
|
@ -14,7 +13,8 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
// All 5 required for Player API
|
// All 5 required for Player API
|
||||||
virtual QVariant playerCommand(const Enums::Commands& command,
|
virtual QVariant playerCommand(const Enums::Commands& command,
|
||||||
const QVariant& args) = 0;
|
const QVariant& args)
|
||||||
|
= 0;
|
||||||
virtual QVariant playerCommand(const Enums::Commands& command) = 0;
|
virtual QVariant playerCommand(const Enums::Commands& command) = 0;
|
||||||
virtual void toggleOnTop() = 0;
|
virtual void toggleOnTop() = 0;
|
||||||
// Optional but handy for MPV or custom backend settings.
|
// Optional but handy for MPV or custom backend settings.
|
||||||
|
|
|
@ -6,21 +6,18 @@
|
||||||
|
|
||||||
namespace Enums {
|
namespace Enums {
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
enum class PlayStatus : int
|
enum class PlayStatus : int {
|
||||||
{
|
|
||||||
Playing = 0,
|
Playing = 0,
|
||||||
Paused = 1
|
Paused = 1
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(PlayStatus)
|
Q_ENUM_NS(PlayStatus)
|
||||||
enum class VolumeStatus : int
|
enum class VolumeStatus : int {
|
||||||
{
|
|
||||||
Muted = 0,
|
Muted = 0,
|
||||||
Low = 1,
|
Low = 1,
|
||||||
Normal = 2
|
Normal = 2
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(VolumeStatus)
|
Q_ENUM_NS(VolumeStatus)
|
||||||
enum class Commands : int
|
enum class Commands : int {
|
||||||
{
|
|
||||||
TogglePlayPause = 0,
|
TogglePlayPause = 0,
|
||||||
ToggleMute = 1,
|
ToggleMute = 1,
|
||||||
SetAudioDevice = 2,
|
SetAudioDevice = 2,
|
||||||
|
@ -48,18 +45,15 @@ enum class Commands : int
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(Commands)
|
Q_ENUM_NS(Commands)
|
||||||
|
|
||||||
enum class Backends : int
|
enum class Backends : int {
|
||||||
{
|
|
||||||
MPVBackend = 0,
|
MPVBackend = 0,
|
||||||
DirectMPVBackend = 1
|
DirectMPVBackend = 1
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(Backends)
|
Q_ENUM_NS(Backends)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forces meta generation.
|
// Forces meta generation.
|
||||||
class Dummy : public QObject
|
class Dummy : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,35 @@
|
||||||
#include <QByteArray>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <spdlog/logger.h>
|
|
||||||
#include <iterator>
|
|
||||||
#include <vector>
|
|
||||||
#include <iosfwd> // IWYU pragma: keep
|
|
||||||
#include <memory> // IWYU pragma: keep
|
|
||||||
#include <spdlog/spdlog.h> // IWYU pragma: export
|
|
||||||
#include <spdlog/sinks/basic_file_sink.h> // IWYU pragma: export
|
|
||||||
#include <spdlog/sinks/daily_file_sink.h> // IWYU pragma: export
|
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h> // IWYU pragma: export
|
|
||||||
#include "spdlog/common.h"
|
#include "spdlog/common.h"
|
||||||
#include "spdlog/details/file_helper-inl.h"
|
#include "spdlog/details/file_helper-inl.h"
|
||||||
#include "spdlog/sinks/ansicolor_sink-inl.h"
|
#include "spdlog/sinks/ansicolor_sink-inl.h"
|
||||||
#include "spdlog/sinks/base_sink-inl.h"
|
#include "spdlog/sinks/base_sink-inl.h"
|
||||||
#include "spdlog/sinks/basic_file_sink-inl.h"
|
#include "spdlog/sinks/basic_file_sink-inl.h"
|
||||||
#include "spdlog/spdlog-inl.h"
|
#include "spdlog/spdlog-inl.h"
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <iosfwd> // IWYU pragma: keep
|
||||||
|
#include <iterator>
|
||||||
|
#include <memory> // IWYU pragma: keep
|
||||||
|
#include <spdlog/logger.h>
|
||||||
|
#include <spdlog/sinks/basic_file_sink.h> // IWYU pragma: export
|
||||||
|
#include <spdlog/sinks/daily_file_sink.h> // IWYU pragma: export
|
||||||
|
#include <spdlog/sinks/stdout_color_sinks.h> // IWYU pragma: export
|
||||||
|
#include <spdlog/spdlog.h> // IWYU pragma: export
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
std::shared_ptr<spdlog::logger>
|
std::shared_ptr<spdlog::logger>
|
||||||
initLogger(std::string name)
|
initLogger(std::string name)
|
||||||
{
|
{
|
||||||
QSettings settings("KittehPlayer", "KittehPlayer");
|
QSettings settings("KittehPlayer", "KittehPlayer");
|
||||||
|
|
||||||
QString logFile =
|
QString logFile = settings.value("Logging/logFile", "/tmp/KittehPlayer.log").toString();
|
||||||
settings.value("Logging/logFile", "/tmp/KittehPlayer.log").toString();
|
|
||||||
|
|
||||||
std::vector<spdlog::sink_ptr> sinks;
|
std::vector<spdlog::sink_ptr> sinks;
|
||||||
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
||||||
sinks.push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(
|
sinks.push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(
|
||||||
logFile.toUtf8().constData()));
|
logFile.toUtf8().constData()));
|
||||||
auto console =
|
auto console = std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks));
|
||||||
std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks));
|
|
||||||
console->set_pattern("[%l][%n] %v%$");
|
console->set_pattern("[%l][%n] %v%$");
|
||||||
spdlog::register_logger(console);
|
spdlog::register_logger(console);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h> // IWYU pragma: keep
|
#include <spdlog/sinks/stdout_color_sinks.h> // IWYU pragma: keep
|
||||||
#include <spdlog/spdlog.h> // IWYU pragma: keep
|
#include <spdlog/spdlog.h> // IWYU pragma: keep
|
||||||
|
|
||||||
std::shared_ptr<spdlog::logger>
|
std::shared_ptr<spdlog::logger> initLogger(std::string name);
|
||||||
initLogger(std::string name);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
23
src/main.cpp
23
src/main.cpp
|
@ -1,24 +1,24 @@
|
||||||
#include <QtGlobal>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QtQml>
|
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QtQml>
|
||||||
|
#include <locale.h>
|
||||||
#ifdef QT_QML_DEBUG
|
#ifdef QT_QML_DEBUG
|
||||||
#warning "QML Debugging Enabled!!!"
|
#warning "QML Debugging Enabled!!!"
|
||||||
#include <QQmlDebug>
|
#include <QQmlDebug>
|
||||||
#endif
|
#endif
|
||||||
|
#include "logger.h"
|
||||||
|
#include "spdlog/logger.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <spdlog/fmt/fmt.h>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "logger.h"
|
#include <spdlog/fmt/fmt.h>
|
||||||
#include "spdlog/logger.h"
|
|
||||||
|
|
||||||
extern void registerTypes();
|
extern void registerTypes();
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ extern void registerTypes();
|
||||||
auto qmlLogger = initLogger("qml");
|
auto qmlLogger = initLogger("qml");
|
||||||
auto miscLogger = initLogger("misc");
|
auto miscLogger = initLogger("misc");
|
||||||
|
|
||||||
void
|
void spdLogger(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||||
spdLogger(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
|
||||||
{
|
{
|
||||||
std::string localMsg = msg.toUtf8().constData();
|
std::string localMsg = msg.toUtf8().constData();
|
||||||
std::shared_ptr<spdlog::logger> logger;
|
std::shared_ptr<spdlog::logger> logger;
|
||||||
|
@ -59,8 +58,7 @@ spdLogger(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main(int argc, char* argv[])
|
||||||
main(int argc, char* argv[])
|
|
||||||
{
|
{
|
||||||
qInstallMessageHandler(spdLogger);
|
qInstallMessageHandler(spdLogger);
|
||||||
|
|
||||||
|
@ -102,12 +100,9 @@ main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
settings.setValue("Setup/ranSetup", true);
|
settings.setValue("Setup/ranSetup", true);
|
||||||
|
|
||||||
QString newpath =
|
QString newpath = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + "/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", "");
|
||||||
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
|
||||||
"/usr/bin:" + QProcessEnvironment::systemEnvironment().value("PATH", "");
|
|
||||||
setenv("PATH", newpath.toUtf8().constData(), 1);
|
setenv("PATH", newpath.toUtf8().constData(), 1);
|
||||||
|
|
||||||
registerTypes();
|
registerTypes();
|
||||||
|
|
|
@ -48,7 +48,8 @@ Item {
|
||||||
|
|
||||||
VideoProgress {
|
VideoProgress {
|
||||||
id: progressBar
|
id: progressBar
|
||||||
visible: controlsBarItem.controlsShowing && appearance.themeName != "RoosterTeeth"
|
visible: controlsBarItem.controlsShowing
|
||||||
|
&& appearance.themeName != "RoosterTeeth"
|
||||||
bottomPadding: 0
|
bottomPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
|
@ -70,8 +71,7 @@ Item {
|
||||||
== "RoosterTeeth" ? 0 : progressBar.topPadding) : 0
|
== "RoosterTeeth" ? 0 : progressBar.topPadding) : 0
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
||||||
"mainBackground")
|
|
||||||
visible: controlsBarItem.controlsShowing
|
visible: controlsBarItem.controlsShowing
|
||||||
z: 10
|
z: 10
|
||||||
anchors {
|
anchors {
|
||||||
|
|
|
@ -6,8 +6,7 @@ Menu {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
implicitHeight: 10
|
implicitHeight: 10
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
||||||
"mainBackground")
|
|
||||||
}
|
}
|
||||||
delegate: CustomMenuItem {}
|
delegate: CustomMenuItem {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,12 @@ Dialog {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var component = Qt.createComponent("ThumbnailProcess.qml")
|
var component = Qt.createComponent("ThumbnailProcess.qml")
|
||||||
var thumbnailerProcess = component.createObject(
|
var thumbnailerProcess = component.createObject(playlistDialog, {
|
||||||
playlistDialog, {
|
|
||||||
"name": thumbnailJobs[0]
|
"name": thumbnailJobs[0]
|
||||||
})
|
})
|
||||||
if (String(titleJobs[0]).indexOf("://") !== -1) {
|
if (String(titleJobs[0]).indexOf("://") !== -1) {
|
||||||
|
|
||||||
thumbnailerProcess.start(
|
thumbnailerProcess.start("youtube-dl",
|
||||||
"youtube-dl",
|
|
||||||
["--get-thumbnail", thumbnailJobs[0]])
|
["--get-thumbnail", thumbnailJobs[0]])
|
||||||
} else {
|
} else {
|
||||||
thumbnailerProcess.start(
|
thumbnailerProcess.start(
|
||||||
|
@ -85,8 +83,7 @@ Dialog {
|
||||||
var titleProcess = component.createObject(playlistDialog, {
|
var titleProcess = component.createObject(playlistDialog, {
|
||||||
"name": titleJobs[0]
|
"name": titleJobs[0]
|
||||||
})
|
})
|
||||||
titleProcess.start("youtube-dl",
|
titleProcess.start("youtube-dl", ["--get-title", titleJobs[0]])
|
||||||
["--get-title", titleJobs[0]])
|
|
||||||
titleJobs.shift()
|
titleJobs.shift()
|
||||||
titleJobsRunning += 1
|
titleJobsRunning += 1
|
||||||
}
|
}
|
||||||
|
@ -178,8 +175,7 @@ Dialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.playerCommand(Enums.Commands.SetPlaylistPos,
|
player.playerCommand(Enums.Commands.SetPlaylistPos, playlistPos)
|
||||||
playlistPos)
|
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: current ? "orange" : "transparent"
|
color: current ? "orange" : "transparent"
|
||||||
|
|
|
@ -12,7 +12,7 @@ Dialog {
|
||||||
width: 720
|
width: 720
|
||||||
modality: Qt.NonModal
|
modality: Qt.NonModal
|
||||||
|
|
||||||
signal done;
|
signal done
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
id: content
|
id: content
|
||||||
|
@ -30,7 +30,9 @@ Dialog {
|
||||||
text: translate.getTranslation("LANGUAGE", i18n.language)
|
text: translate.getTranslation("LANGUAGE", i18n.language)
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
LanguageSettings { Layout.leftMargin: 30 }
|
LanguageSettings {
|
||||||
|
Layout.leftMargin: 30
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
height: 30
|
height: 30
|
||||||
text: translate.getTranslation("APPEARANCE", i18n.language)
|
text: translate.getTranslation("APPEARANCE", i18n.language)
|
||||||
|
@ -39,7 +41,8 @@ Dialog {
|
||||||
CheckBox {
|
CheckBox {
|
||||||
checked: appearance.titleOnlyOnFullscreen
|
checked: appearance.titleOnlyOnFullscreen
|
||||||
onClicked: appearance.titleOnlyOnFullscreen = !appearance.titleOnlyOnFullscreen
|
onClicked: appearance.titleOnlyOnFullscreen = !appearance.titleOnlyOnFullscreen
|
||||||
text: translate.getTranslation("TITLE_ONLY_ON_FULLSCREEN", i18n.language)
|
text: translate.getTranslation("TITLE_ONLY_ON_FULLSCREEN",
|
||||||
|
i18n.language)
|
||||||
Layout.leftMargin: 30
|
Layout.leftMargin: 30
|
||||||
}
|
}
|
||||||
CheckBox {
|
CheckBox {
|
||||||
|
@ -55,7 +58,8 @@ Dialog {
|
||||||
Text {
|
Text {
|
||||||
id: seekByLabel
|
id: seekByLabel
|
||||||
height: 30
|
height: 30
|
||||||
text: translate.getTranslation("DOUBLE_TAP_TO_SEEK_BY", i18n.language)
|
text: translate.getTranslation("DOUBLE_TAP_TO_SEEK_BY",
|
||||||
|
i18n.language)
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
|
@ -110,7 +114,8 @@ Dialog {
|
||||||
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
||||||
text: appearance.subtitlesFontSize
|
text: appearance.subtitlesFontSize
|
||||||
function setSubtitlesFontSize() {
|
function setSubtitlesFontSize() {
|
||||||
appearance.subtitlesFontSize = parseInt(subtitlesFontSizeInput.text)
|
appearance.subtitlesFontSize = parseInt(
|
||||||
|
subtitlesFontSizeInput.text)
|
||||||
}
|
}
|
||||||
onEditingFinished: setSubtitlesFontSize()
|
onEditingFinished: setSubtitlesFontSize()
|
||||||
}
|
}
|
||||||
|
@ -129,7 +134,9 @@ Dialog {
|
||||||
id: uiFadeTimeInput
|
id: uiFadeTimeInput
|
||||||
anchors.left: uiFadeTimeLabel.right
|
anchors.left: uiFadeTimeLabel.right
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
validator: IntValidator { bottom: 0 }
|
validator: IntValidator {
|
||||||
|
bottom: 0
|
||||||
|
}
|
||||||
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
inputMethodHints: Qt.ImhFormattedNumbersOnly
|
||||||
text: appearance.uiFadeTimer
|
text: appearance.uiFadeTimer
|
||||||
function setUIFadeTime() {
|
function setUIFadeTime() {
|
||||||
|
@ -140,7 +147,6 @@ Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
|
@ -7,7 +7,9 @@ ComboBox {
|
||||||
height: 30
|
height: 30
|
||||||
editable: false
|
editable: false
|
||||||
pressed: true
|
pressed: true
|
||||||
model: Object.keys(Translations.languages).map(function(key) {return Translations.languages[key];})
|
model: Object.keys(Translations.languages).map(function (key) {
|
||||||
|
return Translations.languages[key]
|
||||||
|
})
|
||||||
delegate: ItemDelegate {
|
delegate: ItemDelegate {
|
||||||
height: 25
|
height: 25
|
||||||
width: languageSelector.width
|
width: languageSelector.width
|
||||||
|
@ -22,7 +24,9 @@ ComboBox {
|
||||||
}
|
}
|
||||||
onActivated: {
|
onActivated: {
|
||||||
console.warn(currentText)
|
console.warn(currentText)
|
||||||
i18n.language = Object.keys(Translations.languages).filter(function(key) {return Translations.languages[key] === currentText})[0];
|
i18n.language = Object.keys(Translations.languages).filter(function (key) {
|
||||||
|
return Translations.languages[key] === currentText
|
||||||
|
})[0]
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
currentIndex = languageSelector.find(Translations.languages[i18n.language])
|
currentIndex = languageSelector.find(Translations.languages[i18n.language])
|
||||||
|
|
|
@ -3,8 +3,7 @@ import QtQuick 2.0
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: chapterMarker
|
id: chapterMarker
|
||||||
property int time: 0
|
property int time: 0
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName, "chapterMarkerColor")
|
||||||
"chapterMarkerColor")
|
|
||||||
width: 4
|
width: 4
|
||||||
height: parent.height
|
height: parent.height
|
||||||
x: progressBar.background.width / progressBar.to * time
|
x: progressBar.background.width / progressBar.to * time
|
||||||
|
|
|
@ -7,8 +7,7 @@ Process {
|
||||||
if (String(name).indexOf("://") !== -1) {
|
if (String(name).indexOf("://") !== -1) {
|
||||||
playlistDialog.addThumbnailToCache(name, getOutput())
|
playlistDialog.addThumbnailToCache(name, getOutput())
|
||||||
} else {
|
} else {
|
||||||
playlistDialog.addThumbnailToCache(name,
|
playlistDialog.addThumbnailToCache(name, "/tmp/" + Qt.md5(name) + ".png")
|
||||||
"/tmp/" + Qt.md5(name) + ".png")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,16 +44,14 @@ MenuBar {
|
||||||
var track = newTracks[i]
|
var track = newTracks[i]
|
||||||
var trackID = track["id"]
|
var trackID = track["id"]
|
||||||
var trackType = track["type"]
|
var trackType = track["type"]
|
||||||
var trackLang = LanguageCodes.localeCodeToEnglish(
|
var trackLang = LanguageCodes.localeCodeToEnglish(String(track["lang"]))
|
||||||
String(track["lang"]))
|
|
||||||
trackLang = trackLang == undefined ? "" : trackLang
|
trackLang = trackLang == undefined ? "" : trackLang
|
||||||
var trackTitle = track["title"] == undefined ? "" : track["title"] + " "
|
var trackTitle = track["title"] == undefined ? "" : track["title"] + " "
|
||||||
var component = Qt.createComponent("TrackItem.qml")
|
var component = Qt.createComponent("TrackItem.qml")
|
||||||
if (trackType == "sub") {
|
if (trackType == "sub") {
|
||||||
var action = component.createObject(subMenu, {
|
var action = component.createObject(subMenu, {
|
||||||
"text": trackLang,
|
"text": trackLang,
|
||||||
"trackID": String(
|
"trackID": String(trackID),
|
||||||
trackID),
|
|
||||||
"trackType": "sid",
|
"trackType": "sid",
|
||||||
"checked": track["selected"]
|
"checked": track["selected"]
|
||||||
})
|
})
|
||||||
|
@ -62,8 +60,7 @@ MenuBar {
|
||||||
} else if (trackType == "audio") {
|
} else if (trackType == "audio") {
|
||||||
var action = component.createObject(audioMenu, {
|
var action = component.createObject(audioMenu, {
|
||||||
"text": trackTitle + trackLang,
|
"text": trackTitle + trackLang,
|
||||||
"trackID": String(
|
"trackID": String(trackID),
|
||||||
trackID),
|
|
||||||
"trackType": "aid",
|
"trackType": "aid",
|
||||||
"checked": track["selected"]
|
"checked": track["selected"]
|
||||||
})
|
})
|
||||||
|
@ -72,8 +69,7 @@ MenuBar {
|
||||||
} else if (trackType == "video") {
|
} else if (trackType == "video") {
|
||||||
var action = component.createObject(videoMenu, {
|
var action = component.createObject(videoMenu, {
|
||||||
"text": "Video " + trackID + trackTitle,
|
"text": "Video " + trackID + trackTitle,
|
||||||
"trackID": String(
|
"trackID": String(trackID),
|
||||||
trackID),
|
|
||||||
"trackType": "vid",
|
"trackType": "vid",
|
||||||
"checked": track["selected"]
|
"checked": track["selected"]
|
||||||
})
|
})
|
||||||
|
@ -89,8 +85,7 @@ MenuBar {
|
||||||
nameFilters: ["All files (*)"]
|
nameFilters: ["All files (*)"]
|
||||||
selectMultiple: false
|
selectMultiple: false
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
player.playerCommand(Enums.Commands.LoadFile,
|
player.playerCommand(Enums.Commands.LoadFile, String(fileDialog.fileUrl))
|
||||||
String(fileDialog.fileUrl))
|
|
||||||
fileDialog.close()
|
fileDialog.close()
|
||||||
}
|
}
|
||||||
onRejected: {
|
onRejected: {
|
||||||
|
@ -108,8 +103,7 @@ MenuBar {
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: pathText
|
id: pathText
|
||||||
placeholderText: translate.getTranslation("URL_FILE_PATH",
|
placeholderText: translate.getTranslation("URL_FILE_PATH", i18n.language)
|
||||||
i18n.language)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +158,7 @@ MenuBar {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
implicitHeight: 10
|
implicitHeight: 10
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
||||||
"mainBackground")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomMenu {
|
CustomMenu {
|
||||||
|
@ -233,16 +226,14 @@ MenuBar {
|
||||||
shortcut: keybinds.forward5
|
shortcut: keybinds.forward5
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("SPEED_DECREASE_POINT_ONE",
|
text: translate.getTranslation("SPEED_DECREASE_POINT_ONE", i18n.language)
|
||||||
i18n.language)
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.playerCommand(Enums.Commands.SubtractSpeed, 0.1)
|
player.playerCommand(Enums.Commands.SubtractSpeed, 0.1)
|
||||||
}
|
}
|
||||||
shortcut: keybinds.decreaseSpeedByPointOne
|
shortcut: keybinds.decreaseSpeedByPointOne
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("SPEED_INCREASE_POINT_ONE",
|
text: translate.getTranslation("SPEED_INCREASE_POINT_ONE", i18n.language)
|
||||||
i18n.language)
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.playerCommand(Enums.Commands.AddSpeed, 0.1)
|
player.playerCommand(Enums.Commands.AddSpeed, 0.1)
|
||||||
}
|
}
|
||||||
|
@ -472,8 +463,7 @@ MenuBar {
|
||||||
shortcut: keybinds.nyanCat
|
shortcut: keybinds.nyanCat
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: translate.getTranslation("TOGGLE_ALWAYS_ON_TOP",
|
text: translate.getTranslation("TOGGLE_ALWAYS_ON_TOP", i18n.language)
|
||||||
i18n.language)
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
player.toggleOnTop()
|
player.toggleOnTop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,7 @@ Item {
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: menuBar.height
|
height: menuBar.height
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
||||||
"mainBackground")
|
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
left: menuBar.right
|
left: menuBar.right
|
||||||
|
@ -54,8 +53,7 @@ Item {
|
||||||
font {
|
font {
|
||||||
family: appearance.fontName
|
family: appearance.fontName
|
||||||
bold: true
|
bold: true
|
||||||
pixelSize: appearance.scaleFactor * (height - anchors.topMargin
|
pixelSize: appearance.scaleFactor * (height - anchors.topMargin - anchors.bottomMargin - 2)
|
||||||
- anchors.bottomMargin - 2)
|
|
||||||
}
|
}
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
|
|
@ -3,7 +3,8 @@ import player 1.0
|
||||||
|
|
||||||
SmoothButton {
|
SmoothButton {
|
||||||
property var playing: Enums.PlayStatus.Playing
|
property var playing: Enums.PlayStatus.Playing
|
||||||
iconSource: "icons/" + appearance.themeName + (playing == Enums.PlayStatus.Playing ? "/pause.svg" : "/play.svg")
|
iconSource: "icons/" + appearance.themeName
|
||||||
|
+ (playing == Enums.PlayStatus.Playing ? "/pause.svg" : "/play.svg")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.playerCommand(Enums.Commands.TogglePlayPause)
|
player.playerCommand(Enums.Commands.TogglePlayPause)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,10 @@ Control {
|
||||||
id: buttonImage
|
id: buttonImage
|
||||||
smooth: false
|
smooth: false
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
sourceSize.height: Math.floor(root.parent.height / (appearance.themeName == "Niconico" ? 1.8 : 1.25))
|
sourceSize.height: Math.floor(
|
||||||
sourceSize.width: Math.floor(root.parent.height / (appearance.themeName == "Niconico" ? 1.8 : 1.25))
|
root.parent.height / (appearance.themeName == "Niconico" ? 1.8 : 1.25))
|
||||||
|
sourceSize.width: Math.floor(
|
||||||
|
root.parent.height / (appearance.themeName == "Niconico" ? 1.8 : 1.25))
|
||||||
}
|
}
|
||||||
ColorOverlay {
|
ColorOverlay {
|
||||||
id: colorOverlay
|
id: colorOverlay
|
||||||
|
@ -38,7 +40,6 @@ Control {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -18,8 +18,7 @@ Rectangle {
|
||||||
implicitWidth: Math.max(
|
implicitWidth: Math.max(
|
||||||
background ? background.implicitWidth : 0,
|
background ? background.implicitWidth : 0,
|
||||||
(handle ? handle.implicitWidth : 0) + leftPadding + rightPadding)
|
(handle ? handle.implicitWidth : 0) + leftPadding + rightPadding)
|
||||||
implicitHeight: Math.max(
|
implicitHeight: Math.max(background.implicitHeight,
|
||||||
background.implicitHeight,
|
|
||||||
handle.implicitHeight + topPadding + bottomPadding)
|
handle.implicitHeight + topPadding + bottomPadding)
|
||||||
|
|
||||||
padding: 6
|
padding: 6
|
||||||
|
|
|
@ -17,8 +17,7 @@ Slider {
|
||||||
width: hoverProgressLabel.width
|
width: hoverProgressLabel.width
|
||||||
height: hoverProgressLabel.height
|
height: hoverProgressLabel.height
|
||||||
z: 100
|
z: 100
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
||||||
"mainBackground")
|
|
||||||
Text {
|
Text {
|
||||||
id: hoverProgressLabel
|
id: hoverProgressLabel
|
||||||
text: "0:00"
|
text: "0:00"
|
||||||
|
@ -92,7 +91,8 @@ Slider {
|
||||||
|
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
// code taken from https://github.com/qt/qtquickcontrols2/blob/39892547145ba4e73bebee86352bd384732b5d19/src/quicktemplates2/qquickslider.cpp#L138
|
// code taken from https://github.com/qt/qtquickcontrols2/blob/39892547145ba4e73bebee86352bd384732b5d19/src/quicktemplates2/qquickslider.cpp#L138
|
||||||
var a = ((mouseAreaProgressBar.mouseX - (handleRect.width / 2)) / (progressBar.availableWidth - handleRect.width)) * progressBar.to
|
var a = ((mouseAreaProgressBar.mouseX - (handleRect.width / 2))
|
||||||
|
/ (progressBar.availableWidth - handleRect.width)) * progressBar.to
|
||||||
hoverProgressLabel.text = utils.createTimestamp(a)
|
hoverProgressLabel.text = utils.createTimestamp(a)
|
||||||
timestampBox.x = mouseAreaProgressBar.mouseX - (timestampBox.width / 2)
|
timestampBox.x = mouseAreaProgressBar.mouseX - (timestampBox.width / 2)
|
||||||
timestampBox.y = progressBackground.y - timestampBox.height * 2
|
timestampBox.y = progressBackground.y - timestampBox.height * 2
|
||||||
|
@ -105,8 +105,8 @@ Slider {
|
||||||
id: progressBackground
|
id: progressBackground
|
||||||
z: 30
|
z: 30
|
||||||
width: progressBar.availableWidth
|
width: progressBar.availableWidth
|
||||||
height: progressBar.getProgressBarHeight(
|
height: progressBar.getProgressBarHeight(fun.nyanCat,
|
||||||
fun.nyanCat, mouseAreaProgressBar.containsMouse)
|
mouseAreaProgressBar.containsMouse)
|
||||||
color: getAppearanceValueForTheme(appearance.themeName,
|
color: getAppearanceValueForTheme(appearance.themeName,
|
||||||
"progressBackgroundColor")
|
"progressBackgroundColor")
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ Slider {
|
||||||
"volumeSliderBackground")
|
"volumeSliderBackground")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
z: 10
|
z: 10
|
||||||
|
@ -61,8 +60,7 @@ Slider {
|
||||||
onWheel: {
|
onWheel: {
|
||||||
if (wheel.angleDelta.y < 0) {
|
if (wheel.angleDelta.y < 0) {
|
||||||
volumeBar.value -= 5
|
volumeBar.value -= 5
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
volumeBar.value += 5
|
volumeBar.value += 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import QtQuick 2.0
|
||||||
import "translations.js" as Translations
|
import "translations.js" as Translations
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
function getTranslation(code, language) {
|
function getTranslation(code, language) {
|
||||||
var lang = Translations.translations[language]
|
var lang = Translations.translations[language]
|
||||||
if (lang == undefined || lang == "undefined") {
|
if (lang == undefined || lang == "undefined") {
|
||||||
|
|
|
@ -256,12 +256,11 @@ Window {
|
||||||
argument = argument.substr(2)
|
argument = argument.substr(2)
|
||||||
if (argument.length > 0) {
|
if (argument.length > 0) {
|
||||||
var splitArg = argument.split(/=(.+)/)
|
var splitArg = argument.split(/=(.+)/)
|
||||||
if (splitArg[0] == "screen"
|
if (splitArg[0] == "screen" || splitArg[0] == "fs-screen") {
|
||||||
|| splitArg[0] == "fs-screen") {
|
|
||||||
for (var i = 0, len = Qt.application.screens.length; i < len; i++) {
|
for (var i = 0, len = Qt.application.screens.length; i < len; i++) {
|
||||||
var screen = Qt.application.screens[i]
|
var screen = Qt.application.screens[i]
|
||||||
console.log("Screen Name: " + screen["name"]
|
console.log(
|
||||||
+ " Screen Number: " + String(
|
"Screen Name: " + screen["name"] + " Screen Number: " + String(
|
||||||
i))
|
i))
|
||||||
if (screen["name"] == splitArg[1] || String(
|
if (screen["name"] == splitArg[1] || String(
|
||||||
i) == splitArg[1]) {
|
i) == splitArg[1]) {
|
||||||
|
@ -269,10 +268,8 @@ Window {
|
||||||
mainWindow.screen = screen
|
mainWindow.screen = screen
|
||||||
mainWindow.width = mainWindow.screen.width / 2
|
mainWindow.width = mainWindow.screen.width / 2
|
||||||
mainWindow.height = mainWindow.screen.height / 2
|
mainWindow.height = mainWindow.screen.height / 2
|
||||||
mainWindow.x = mainWindow.screen.virtualX
|
mainWindow.x = mainWindow.screen.virtualX + mainWindow.width / 2
|
||||||
+ mainWindow.width / 2
|
mainWindow.y = mainWindow.screen.virtualY + mainWindow.height / 2
|
||||||
mainWindow.y = mainWindow.screen.virtualY
|
|
||||||
+ mainWindow.height / 2
|
|
||||||
if (splitArg[0] == "fs-screen") {
|
if (splitArg[0] == "fs-screen") {
|
||||||
toggleFullscreen()
|
toggleFullscreen()
|
||||||
}
|
}
|
||||||
|
@ -285,15 +282,13 @@ Window {
|
||||||
toggleFullscreen()
|
toggleFullscreen()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (splitArg[1] == undefined
|
if (splitArg[1] == undefined || splitArg[1].length == 0) {
|
||||||
|| splitArg[1].length == 0) {
|
|
||||||
splitArg[1] = "yes"
|
splitArg[1] = "yes"
|
||||||
}
|
}
|
||||||
player.setOption(splitArg[0], splitArg[1])
|
player.setOption(splitArg[0], splitArg[1])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.playerCommand(Enums.Commands.AppendFile,
|
player.playerCommand(Enums.Commands.AppendFile, argument)
|
||||||
argument)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,11 +364,11 @@ Window {
|
||||||
function doubleMouseClick(mouse) {
|
function doubleMouseClick(mouse) {
|
||||||
if (appearance.doubleTapToSeek) {
|
if (appearance.doubleTapToSeek) {
|
||||||
if (mouse.x > (mouseAreaPlayer.width / 2)) {
|
if (mouse.x > (mouseAreaPlayer.width / 2)) {
|
||||||
player.playerCommand(Enums.Commands.Seek, String(
|
player.playerCommand(Enums.Commands.Seek,
|
||||||
appearance.doubleTapToSeekBy))
|
String(appearance.doubleTapToSeekBy))
|
||||||
} else {
|
} else {
|
||||||
player.playerCommand(Enums.Commands.Seek, "-" + String(
|
player.playerCommand(Enums.Commands.Seek,
|
||||||
appearance.doubleTapToSeekBy))
|
"-" + String(appearance.doubleTapToSeekBy))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toggleFullscreen()
|
toggleFullscreen()
|
||||||
|
@ -391,7 +386,8 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
var isLongEnough = Math.sqrt(xStart*xStart, mouse.x*mouse.x) > mainWindow.width * 0.3
|
var isLongEnough = Math.sqrt(xStart * xStart,
|
||||||
|
mouse.x * mouse.x) > mainWindow.width * 0.3
|
||||||
if (velocity > 2 && isLongEnough) {
|
if (velocity > 2 && isLongEnough) {
|
||||||
appearance.scaleFactor += 0.2
|
appearance.scaleFactor += 0.2
|
||||||
} else if (velocity < -2 && isLongEnough) {
|
} else if (velocity < -2 && isLongEnough) {
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
#define QMLDEBUGGER_H
|
#define QMLDEBUGGER_H
|
||||||
|
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QVariant>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
class QMLDebugger : public QObject
|
class QMLDebugger : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE static QString properties(QQuickItem* item,
|
Q_INVOKABLE static QString properties(QQuickItem* item,
|
||||||
|
|
|
@ -5,25 +5,28 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QString>
|
|
||||||
#include <QList>
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QSharedPointer>
|
#include <QList>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
namespace mpv {
|
namespace mpv {
|
||||||
namespace qt {
|
namespace qt {
|
||||||
|
|
||||||
// Wrapper around mpv_handle. Does refcounting under the hood.
|
// Wrapper around mpv_handle. Does refcounting under the hood.
|
||||||
class Handle
|
class Handle {
|
||||||
{
|
|
||||||
struct container {
|
struct container {
|
||||||
container(mpv_handle *h) : mpv(h) {}
|
container(mpv_handle* h)
|
||||||
|
: mpv(h)
|
||||||
|
{
|
||||||
|
}
|
||||||
~container() { mpv_terminate_destroy(mpv); }
|
~container() { mpv_terminate_destroy(mpv); }
|
||||||
mpv_handle* mpv;
|
mpv_handle* mpv;
|
||||||
};
|
};
|
||||||
QSharedPointer<container> sptr;
|
QSharedPointer<container> sptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Construct a new Handle from a raw mpv_handle with refcount 1. If the
|
// Construct a new Handle from a raw mpv_handle with refcount 1. If the
|
||||||
// last Handle goes out of scope, the mpv_handle will be destroyed with
|
// last Handle goes out of scope, the mpv_handle will be destroyed with
|
||||||
|
@ -33,7 +36,8 @@ public:
|
||||||
// destroying the mpv_handle.
|
// destroying the mpv_handle.
|
||||||
// Never create multiple wrappers from the same raw mpv_handle; copy the
|
// Never create multiple wrappers from the same raw mpv_handle; copy the
|
||||||
// wrapper instead (that's what it's for).
|
// wrapper instead (that's what it's for).
|
||||||
static Handle FromRawHandle(mpv_handle *handle) {
|
static Handle FromRawHandle(mpv_handle* handle)
|
||||||
|
{
|
||||||
Handle h;
|
Handle h;
|
||||||
h.sptr = QSharedPointer<container>(new container(handle));
|
h.sptr = QSharedPointer<container>(new container(handle));
|
||||||
return h;
|
return h;
|
||||||
|
@ -76,17 +80,21 @@ static inline QVariant node_to_variant(const mpv_node *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct node_builder {
|
struct node_builder {
|
||||||
node_builder(const QVariant& v) {
|
node_builder(const QVariant& v)
|
||||||
|
{
|
||||||
set(&node_, v);
|
set(&node_, v);
|
||||||
}
|
}
|
||||||
~node_builder() {
|
~node_builder()
|
||||||
|
{
|
||||||
free_node(&node_);
|
free_node(&node_);
|
||||||
}
|
}
|
||||||
mpv_node* node() { return &node_; }
|
mpv_node* node() { return &node_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(node_builder)
|
Q_DISABLE_COPY(node_builder)
|
||||||
mpv_node node_;
|
mpv_node node_;
|
||||||
mpv_node_list *create_list(mpv_node *dst, bool is_map, int num) {
|
mpv_node_list* create_list(mpv_node* dst, bool is_map, int num)
|
||||||
|
{
|
||||||
dst->format = is_map ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NODE_ARRAY;
|
dst->format = is_map ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NODE_ARRAY;
|
||||||
mpv_node_list* list = new mpv_node_list();
|
mpv_node_list* list = new mpv_node_list();
|
||||||
dst->u.list = list;
|
dst->u.list = list;
|
||||||
|
@ -105,21 +113,24 @@ private:
|
||||||
free_node(dst);
|
free_node(dst);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
char *dup_qstring(const QString &s) {
|
char* dup_qstring(const QString& s)
|
||||||
|
{
|
||||||
QByteArray b = s.toUtf8();
|
QByteArray b = s.toUtf8();
|
||||||
char* r = new char[b.size() + 1];
|
char* r = new char[b.size() + 1];
|
||||||
if (r)
|
if (r)
|
||||||
std::memcpy(r, b.data(), b.size() + 1);
|
std::memcpy(r, b.data(), b.size() + 1);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
bool test_type(const QVariant &v, QMetaType::Type t) {
|
bool test_type(const QVariant& v, QMetaType::Type t)
|
||||||
|
{
|
||||||
// The Qt docs say: "Although this function is declared as returning
|
// The Qt docs say: "Although this function is declared as returning
|
||||||
// "QVariant::Type(obsolete), the return value should be interpreted
|
// "QVariant::Type(obsolete), the return value should be interpreted
|
||||||
// as QMetaType::Type."
|
// as QMetaType::Type."
|
||||||
// So a cast really seems to be needed to avoid warnings (urgh).
|
// So a cast really seems to be needed to avoid warnings (urgh).
|
||||||
return static_cast<int>(v.type()) == static_cast<int>(t);
|
return static_cast<int>(v.type()) == static_cast<int>(t);
|
||||||
}
|
}
|
||||||
void set(mpv_node *dst, const QVariant &src) {
|
void set(mpv_node* dst, const QVariant& src)
|
||||||
|
{
|
||||||
if (test_type(src, QMetaType::QString)) {
|
if (test_type(src, QMetaType::QString)) {
|
||||||
dst->format = MPV_FORMAT_STRING;
|
dst->format = MPV_FORMAT_STRING;
|
||||||
dst->u.string = dup_qstring(src.toString());
|
dst->u.string = dup_qstring(src.toString());
|
||||||
|
@ -128,11 +139,7 @@ private:
|
||||||
} else if (test_type(src, QMetaType::Bool)) {
|
} else if (test_type(src, QMetaType::Bool)) {
|
||||||
dst->format = MPV_FORMAT_FLAG;
|
dst->format = MPV_FORMAT_FLAG;
|
||||||
dst->u.flag = src.toBool() ? 1 : 0;
|
dst->u.flag = src.toBool() ? 1 : 0;
|
||||||
} else if (test_type(src, QMetaType::Int) ||
|
} else if (test_type(src, QMetaType::Int) || test_type(src, QMetaType::LongLong) || test_type(src, QMetaType::UInt) || test_type(src, QMetaType::ULongLong)) {
|
||||||
test_type(src, QMetaType::LongLong) ||
|
|
||||||
test_type(src, QMetaType::UInt) ||
|
|
||||||
test_type(src, QMetaType::ULongLong))
|
|
||||||
{
|
|
||||||
dst->format = MPV_FORMAT_INT64;
|
dst->format = MPV_FORMAT_INT64;
|
||||||
dst->u.int64 = src.toLongLong();
|
dst->u.int64 = src.toLongLong();
|
||||||
} else if (test_type(src, QMetaType::Double)) {
|
} else if (test_type(src, QMetaType::Double)) {
|
||||||
|
@ -167,7 +174,8 @@ private:
|
||||||
fail:
|
fail:
|
||||||
dst->format = MPV_FORMAT_NONE;
|
dst->format = MPV_FORMAT_NONE;
|
||||||
}
|
}
|
||||||
void free_node(mpv_node *dst) {
|
void free_node(mpv_node* dst)
|
||||||
|
{
|
||||||
switch (dst->format) {
|
switch (dst->format) {
|
||||||
case MPV_FORMAT_STRING:
|
case MPV_FORMAT_STRING:
|
||||||
delete[] dst->u.string;
|
delete[] dst->u.string;
|
||||||
|
@ -199,7 +207,10 @@ private:
|
||||||
*/
|
*/
|
||||||
struct node_autofree {
|
struct node_autofree {
|
||||||
mpv_node* ptr;
|
mpv_node* ptr;
|
||||||
node_autofree(mpv_node *a_ptr) : ptr(a_ptr) {}
|
node_autofree(mpv_node* a_ptr)
|
||||||
|
: ptr(a_ptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
~node_autofree() { mpv_free_node_contents(ptr); }
|
~node_autofree() { mpv_free_node_contents(ptr); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -267,15 +278,20 @@ static inline QVariant command_variant(mpv_handle *ctx, const QVariant &args)
|
||||||
* You can use get_error() or is_error() to extract the error status from a
|
* You can use get_error() or is_error() to extract the error status from a
|
||||||
* QVariant value.
|
* QVariant value.
|
||||||
*/
|
*/
|
||||||
struct ErrorReturn
|
struct ErrorReturn {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* enum mpv_error value (or a value outside of it if ABI was extended)
|
* enum mpv_error value (or a value outside of it if ABI was extended)
|
||||||
*/
|
*/
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
ErrorReturn() : error(0) {}
|
ErrorReturn()
|
||||||
explicit ErrorReturn(int err) : error(err) {}
|
: error(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit ErrorReturn(int err)
|
||||||
|
: error(err)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,7 +360,6 @@ static inline QVariant command(mpv_handle *ctx, const QVariant &args)
|
||||||
node_autofree f(&res);
|
node_autofree f(&res);
|
||||||
return node_to_variant(&res);
|
return node_to_variant(&res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
void registerTypes() {
|
void registerTypes()
|
||||||
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
|
||||||
qmlRegisterUncreatableMetaObject(
|
qmlRegisterUncreatableMetaObject(
|
||||||
Enums::staticMetaObject, "player", 1, 0, "Enums", "Error: only enums");
|
Enums::staticMetaObject, "player", 1, 0, "Enums", "Error: only enums");
|
||||||
qRegisterMetaType<Enums::PlayStatus>("Enums.PlayStatus");
|
qRegisterMetaType<Enums::PlayStatus>("Enums.PlayStatus");
|
||||||
|
|
|
@ -36,8 +36,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int setenv(const char* var, const char* value, int overwrite)
|
||||||
setenv(const char* var, const char* value, int overwrite)
|
|
||||||
{
|
{
|
||||||
/* Core implementation for both setenv() and unsetenv() functions;
|
/* Core implementation for both setenv() and unsetenv() functions;
|
||||||
* at the outset, assume that the requested operation may fail.
|
* at the outset, assume that the requested operation may fail.
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "spdlog/logger.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "logger.h"
|
|
||||||
#include "spdlog/logger.h"
|
|
||||||
|
|
||||||
#if (defined(__linux__) || defined(__FreeBSD__)) && ENABLE_X11
|
#if (defined(__linux__) || defined(__FreeBSD__)) && ENABLE_X11
|
||||||
|
#include <QX11Info> // IWYU pragma: keep
|
||||||
#include <X11/X.h> // IWYU pragma: keep
|
#include <X11/X.h> // IWYU pragma: keep
|
||||||
#include <X11/Xlib.h> // IWYU pragma: keep
|
#include <X11/Xlib.h> // IWYU pragma: keep
|
||||||
#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
|
|
||||||
#undef Bool
|
#undef Bool
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -23,24 +23,19 @@ namespace Utils {
|
||||||
QString
|
QString
|
||||||
getPlatformName()
|
getPlatformName()
|
||||||
{
|
{
|
||||||
QGuiApplication* qapp =
|
QGuiApplication* qapp = qobject_cast<QGuiApplication*>(QCoreApplication::instance());
|
||||||
qobject_cast<QGuiApplication*>(QCoreApplication::instance());
|
|
||||||
return qapp->platformName();
|
return qapp->platformName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void launchAboutQt()
|
||||||
launchAboutQt()
|
|
||||||
{
|
{
|
||||||
QApplication* qapp =
|
QApplication* qapp = qobject_cast<QApplication*>(QCoreApplication::instance());
|
||||||
qobject_cast<QApplication*>(QCoreApplication::instance());
|
|
||||||
qapp->aboutQt();
|
qapp->aboutQt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAppImage()
|
void updateAppImage()
|
||||||
{
|
{
|
||||||
QString program =
|
QString program = QProcessEnvironment::systemEnvironment().value("APPDIR", "") + "/usr/bin/appimageupdatetool";
|
||||||
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
|
||||||
"/usr/bin/appimageupdatetool";
|
|
||||||
QProcess updater;
|
QProcess updater;
|
||||||
updater.setProcessChannelMode(QProcess::ForwardedChannels);
|
updater.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
updater.start(program,
|
updater.start(program,
|
||||||
|
@ -72,8 +67,7 @@ createTimestamp(const int seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SetScreensaver(WId wid, bool on)
|
||||||
SetScreensaver(WId wid, bool on)
|
|
||||||
{
|
{
|
||||||
QProcess xdgScreensaver;
|
QProcess xdgScreensaver;
|
||||||
xdgScreensaver.setProcessChannelMode(QProcess::ForwardedChannels);
|
xdgScreensaver.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
@ -89,8 +83,7 @@ SetScreensaver(WId wid, bool on)
|
||||||
xdgScreensaver.waitForFinished();
|
xdgScreensaver.waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SetDPMS(bool on)
|
||||||
SetDPMS(bool on)
|
|
||||||
{
|
{
|
||||||
#if defined(__linux__) || defined(__FreeBSD__)
|
#if defined(__linux__) || defined(__FreeBSD__)
|
||||||
if (getPlatformName() != "xcb") {
|
if (getPlatformName() != "xcb") {
|
||||||
|
@ -118,8 +111,7 @@ SetDPMS(bool on)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AlwaysOnTop(WId wid, bool on)
|
||||||
AlwaysOnTop(WId wid, bool on)
|
|
||||||
{
|
{
|
||||||
#if (defined(__linux__) || defined(__FreeBSD__)) && ENABLE_X11
|
#if (defined(__linux__) || defined(__FreeBSD__)) && ENABLE_X11
|
||||||
Display* display = QX11Info::display();
|
Display* display = QX11Info::display();
|
||||||
|
@ -149,4 +141,3 @@ AlwaysOnTop(WId wid, bool on)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,16 @@
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
void
|
void SetDPMS(bool on);
|
||||||
SetDPMS(bool on);
|
void SetScreensaver(WId wid, bool on);
|
||||||
void
|
void AlwaysOnTop(WId wid, bool on);
|
||||||
SetScreensaver(WId wid, bool on);
|
|
||||||
void
|
|
||||||
AlwaysOnTop(WId wid, bool on);
|
|
||||||
QString
|
QString
|
||||||
createTimestamp(int seconds);
|
createTimestamp(int seconds);
|
||||||
void
|
void launchAboutQt();
|
||||||
launchAboutQt();
|
void updateAppImage();
|
||||||
void
|
|
||||||
updateAppImage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UtilsClass : public QObject
|
class UtilsClass : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public slots:
|
public slots:
|
||||||
void SetDPMS(bool on) { Utils::SetDPMS(on); };
|
void SetDPMS(bool on) { Utils::SetDPMS(on); };
|
||||||
|
@ -29,7 +23,6 @@ public slots:
|
||||||
void launchAboutQt() { Utils::launchAboutQt(); };
|
void launchAboutQt() { Utils::launchAboutQt(); };
|
||||||
void updateAppImage() { Utils::updateAppImage(); };
|
void updateAppImage() { Utils::updateAppImage(); };
|
||||||
|
|
||||||
|
|
||||||
QString createTimestamp(int seconds)
|
QString createTimestamp(int seconds)
|
||||||
{
|
{
|
||||||
return Utils::createTimestamp(seconds);
|
return Utils::createTimestamp(seconds);
|
||||||
|
|
Loading…
Reference in a new issue