[UI+Backend] Custom keybinds, made player init after renderer created.
This commit is contained in:
parent
4b5e81a706
commit
20e262b709
|
@ -1,7 +1,7 @@
|
||||||
TARGET = KittehPlayer
|
TARGET = KittehPlayer
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
QT += qml quickcontrols2 widgets core-private gui-private
|
QT += qml quickcontrols2 widgets
|
||||||
SOURCES += src/main.cpp src/MpvPlayerBackend.cpp
|
SOURCES += src/main.cpp src/MpvPlayerBackend.cpp
|
||||||
|
|
||||||
CONFIG += release
|
CONFIG += release
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
if (mpv_render_context_create(&obj->mpv_gl, obj->mpv, params) < 0)
|
if (mpv_render_context_create(&obj->mpv_gl, obj->mpv, params) < 0)
|
||||||
throw std::runtime_error("failed to initialize mpv GL context");
|
throw std::runtime_error("failed to initialize mpv GL context");
|
||||||
mpv_render_context_set_update_callback(obj->mpv_gl, on_mpv_redraw, obj);
|
mpv_render_context_set_update_callback(obj->mpv_gl, on_mpv_redraw, obj);
|
||||||
|
QMetaObject::invokeMethod(obj,"startPlayer");
|
||||||
}
|
}
|
||||||
|
|
||||||
return QQuickFramebufferObject::Renderer::createFramebufferObject(size);
|
return QQuickFramebufferObject::Renderer::createFramebufferObject(size);
|
||||||
|
@ -176,6 +177,7 @@ QVariant MpvPlayerBackend::getProperty(const QString &name) const
|
||||||
|
|
||||||
void MpvPlayerBackend::command(const QVariant& params)
|
void MpvPlayerBackend::command(const QVariant& params)
|
||||||
{
|
{
|
||||||
|
qDebug() << params;
|
||||||
mpv::qt::command_variant(mpv, params);
|
mpv::qt::command_variant(mpv, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,56 +199,56 @@ void MpvPlayerBackend::launchAboutQt()
|
||||||
|
|
||||||
void MpvPlayerBackend::togglePlayPause()
|
void MpvPlayerBackend::togglePlayPause()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "cycle" << "pause");
|
command(QVariantList() << "cycle" << "pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::toggleMute()
|
void MpvPlayerBackend::toggleMute()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "cycle" << "mute");
|
command(QVariantList() << "cycle" << "mute");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::nextAudioTrack()
|
void MpvPlayerBackend::nextAudioTrack()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "cycle" << "audio");
|
command(QVariantList() << "cycle" << "audio");
|
||||||
}
|
}
|
||||||
void MpvPlayerBackend::nextSubtitleTrack()
|
void MpvPlayerBackend::nextSubtitleTrack()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "cycle" << "sub");
|
command(QVariantList() << "cycle" << "sub");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::nextVideoTrack()
|
void MpvPlayerBackend::nextVideoTrack()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "cycle" << "video");
|
command(QVariantList() << "cycle" << "video");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::prevPlaylistItem()
|
void MpvPlayerBackend::prevPlaylistItem()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "playlist-prev");
|
command(QVariantList() << "playlist-prev");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::nextPlaylistItem()
|
void MpvPlayerBackend::nextPlaylistItem()
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "playlist-next" << "force");
|
command(QVariantList() << "playlist-next" << "force");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::loadFile(const QVariant &filename)
|
void MpvPlayerBackend::loadFile(const QVariant &filename)
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "loadfile" << filename);
|
command(QVariantList() << "loadfile" << filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::setVolume(const QVariant &volume)
|
void MpvPlayerBackend::setVolume(const QVariant &volume)
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "set" << "volume" << volume);
|
command(QVariantList() << "set" << "volume" << volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::addVolume(const QVariant &volume)
|
void MpvPlayerBackend::addVolume(const QVariant &volume)
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "add" << "volume" << volume);
|
command(QVariantList() << "add" << "volume" << volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MpvPlayerBackend::seek(const QVariant &seekTime)
|
void MpvPlayerBackend::seek(const QVariant &seekTime)
|
||||||
{
|
{
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "seek" << seekTime);
|
command(QVariantList() << "seek" << seekTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MpvPlayerBackend::getTracks() const
|
QVariant MpvPlayerBackend::getTracks() const
|
||||||
|
@ -331,6 +333,5 @@ QQuickFramebufferObject::Renderer *MpvPlayerBackend::createRenderer() const
|
||||||
{
|
{
|
||||||
window()->setPersistentOpenGLContext(true);
|
window()->setPersistentOpenGLContext(true);
|
||||||
window()->setPersistentSceneGraph(true);
|
window()->setPersistentSceneGraph(true);
|
||||||
|
|
||||||
return new MpvRenderer(const_cast<MpvPlayerBackend *>(this));
|
return new MpvRenderer(const_cast<MpvPlayerBackend *>(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,19 +97,6 @@ ApplicationWindow {
|
||||||
property bool nyanCat: false
|
property bool nyanCat: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: initTimer
|
|
||||||
interval: 1000
|
|
||||||
running: false
|
|
||||||
repeat: false
|
|
||||||
onTriggered: {
|
|
||||||
player.startPlayer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
|
||||||
initTimer.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
function startPlayer() {
|
function startPlayer() {
|
||||||
var args = Qt.application.arguments
|
var args = Qt.application.arguments
|
||||||
var len = Qt.application.arguments.length
|
var len = Qt.application.arguments.length
|
||||||
|
@ -393,6 +380,27 @@ ApplicationWindow {
|
||||||
property string increaseVolume: "*"
|
property string increaseVolume: "*"
|
||||||
property string decreaseVolume: "/"
|
property string decreaseVolume: "/"
|
||||||
property string mute: "m"
|
property string mute: "m"
|
||||||
|
property string customKeybind0:""
|
||||||
|
property string customKeybind0Command: ""
|
||||||
|
property string customKeybind1:""
|
||||||
|
property string customKeybind1Command: ""
|
||||||
|
property string customKeybind2:""
|
||||||
|
property string customKeybind2Command: ""
|
||||||
|
property string customKeybind3:""
|
||||||
|
property string customKeybind3Command: ""
|
||||||
|
property string customKeybind4:""
|
||||||
|
property string customKeybind4Command: ""
|
||||||
|
property string customKeybind5:""
|
||||||
|
property string customKeybind5Command: ""
|
||||||
|
property string customKeybind6:""
|
||||||
|
property string customKeybind6Command: ""
|
||||||
|
property string customKeybind7:""
|
||||||
|
property string customKeybind7Command: ""
|
||||||
|
property string customKeybind8:""
|
||||||
|
property string customKeybind8Command: ""
|
||||||
|
property string customKeybind9:""
|
||||||
|
property string customKeybind9Command: ""
|
||||||
|
|
||||||
}
|
}
|
||||||
MenuBar {
|
MenuBar {
|
||||||
id: menuBar
|
id: menuBar
|
||||||
|
@ -800,6 +808,47 @@ ApplicationWindow {
|
||||||
onTriggered: player.skipToNinth(parseInt(shortcut))
|
onTriggered: player.skipToNinth(parseInt(shortcut))
|
||||||
shortcut: "0"
|
shortcut: "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind0Command)
|
||||||
|
shortcut: keybinds.customKeybind0
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind1Command)
|
||||||
|
shortcut: keybinds.customKeybind1
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind2Command)
|
||||||
|
shortcut: keybinds.customKeybind2
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind3Command)
|
||||||
|
shortcut: keybinds.customKeybind3
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind4Command)
|
||||||
|
shortcut: keybinds.customKeybind4
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind5Command)
|
||||||
|
shortcut: keybinds.customKeybind5
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind6Command)
|
||||||
|
shortcut: keybinds.customKeybind6
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind7Command)
|
||||||
|
shortcut: keybinds.customKeybind7
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind8Command)
|
||||||
|
shortcut: keybinds.customKeybind8
|
||||||
|
}
|
||||||
|
Action {
|
||||||
|
onTriggered: player.command(keybinds.customKeybind9Command)
|
||||||
|
shortcut: keybinds.customKeybind9
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
Loading…
Reference in a new issue