diff --git a/src/mpv/mpvobject.cpp b/src/mpv/mpvobject.cpp index 17aa838..39fc683 100644 --- a/src/mpv/mpvobject.cpp +++ b/src/mpv/mpvobject.cpp @@ -87,7 +87,7 @@ MpvRenderer::~MpvRenderer() { if (mpv_gl) mpv_render_context_free(mpv_gl); - mpv_terminate_destroy(obj->mpv); + // mpv_destroy(obj->mpv); } void MpvRenderer::render() { @@ -242,7 +242,7 @@ MpvObject::MpvObject(QQuickItem *parent) MpvObject::~MpvObject() { - + // quit(); } QQuickFramebufferObject::Renderer *MpvObject::createRenderer() const @@ -340,6 +340,10 @@ void MpvObject::handle_mpv_event(mpv_event *event) // See: https://github.com/mpv-player/mpv/blob/master/player/lua.c#L471 switch (event->event_id) { + case MPV_EVENT_SHUTDOWN: { + mpv_destroy(mpv); + break; + } case MPV_EVENT_LOG_MESSAGE: { mpv_event_log_message *logData = (mpv_event_log_message *)event->data; Q_EMIT logMessage( @@ -487,7 +491,7 @@ void MpvObject::pause() { // qDebug() << "pause"; if (isPlaying()) { - // qDebug() << "!isPlaying"; + qDebug() << "!isPlaying"; set_paused(true); } } diff --git a/src/qml/presenter/Slide.qml b/src/qml/presenter/Slide.qml index ddc1244..525bc52 100644 --- a/src/qml/presenter/Slide.qml +++ b/src/qml/presenter/Slide.qml @@ -34,6 +34,9 @@ Item { property string itemType property bool preview: false + implicitWidth: 1920 + implicitHeight: 1080 + Rectangle { id: basePrColor anchors.fill: parent @@ -59,12 +62,12 @@ Item { id: playArea anchors.fill: parent enabled: editMode - onPressed: mpv.loadFile(videoSource.toString()); + onPressed: mpv.playPause(); cursorShape: preview ? Qt.ArrowCursor : Qt.BlankCursor } Controls.ProgressBar { - anchors.centerIn: parent + anchors.top: parent.bottom visible: editMode width: parent.width - 400 value: mpv.position @@ -74,13 +77,24 @@ Item { Timer { id: mpvLoadingTimer - interval: 2 + interval: 100 onTriggered: { + /* showPassiveNotification("YIPPEEE!") */ mpv.loadFile(videoSource.toString()); + if (preview) { + print("WHY AREN'T YOU PASUING!"); + pauseTimer.restart(); + } blackTimer.restart(); } } + Timer { + id: pauseTimer + interval: 200 + onTriggered: mpv.pause() + } + Timer { id: blackTimer interval: 400 diff --git a/src/qml/presenter/SlideEditor.qml b/src/qml/presenter/SlideEditor.qml index ec17628..842e703 100644 --- a/src/qml/presenter/SlideEditor.qml +++ b/src/qml/presenter/SlideEditor.qml @@ -1,4 +1,4 @@ -import QtQuick 2.13 +import QtQuick 2.15 import QtQuick.Dialogs 1.0 import QtQuick.Controls 2.15 as Controls import QtQuick.Window 2.13 @@ -18,40 +18,65 @@ Item { property string font property real fontSize - Presenter.Slide { - id: representation + property ListModel songs: songModel + + ListView { + id: slideList anchors.fill: parent - editMode: true - imageSource: imageBackground - videoSource: videoBackground - hTextAlignment: root.hTextAlignment - vTextAlignment: root.vTextAlignment - chosenFont: font - textSize: fontSize - preview: true + model: songModel + clip: true + cacheBuffer: 900 + reuseItems: true + spacing: Kirigami.Units.gridUnit + flickDeceleration: 4000 + /* boundsMovement: Flickable.StopAtBounds */ + synchronousDrag: true + delegate: Presenter.Slide { + id: representation + editMode: true + imageSource: root.imageBackground + videoSource: root.videoBackground + hTextAlignment: root.hTextAlignment + vTextAlignment: root.vTextAlignment + chosenFont: root.font + textSize: root.fontSize + preview: true + text: verse + implicitWidth: slideList.width + implicitHeight: width * 9 / 16 + } + } Component.onCompleted: { } - function loadVideo() { - representation.loadVideo(); - representation.pauseVideo(); + ListModel { + id: songModel } + function appendVerse(verse) { + print(verse); + songModel.append({"verse": verse}) + } + + /* function loadVideo() { */ + /* representation.loadVideo(); */ + /* } */ + function updateHAlignment(alignment) { switch (alignment) { case "left" : - representation.horizontalAlignment = Text.AlignLeft; + root.hTextAlignment = Text.AlignLeft; break; case "center" : - representation.horizontalAlignment = Text.AlignHCenter; + root.hTextAlignment = Text.AlignHCenter; break; case "right" : - representation.horizontalAlignment = Text.AlignRight; + root.hTextAlignment = Text.AlignRight; break; case "justify" : - representation.horizontalAlignment = Text.AlignJustify; + root.hTextAlignment = Text.AlignJustify; break; } } diff --git a/src/qml/presenter/SongEditor.qml b/src/qml/presenter/SongEditor.qml index 271cd0b..cbedf47 100644 --- a/src/qml/presenter/SongEditor.qml +++ b/src/qml/presenter/SongEditor.qml @@ -222,8 +222,9 @@ Item { id: slideEditor Layout.preferredWidth: 500 Layout.fillWidth: true - Layout.preferredHeight: slideEditor.width / 16 * 9 + Layout.fillHeight: true Layout.bottomMargin: 30 + Layout.topMargin: 30 Layout.rightMargin: 20 Layout.leftMargin: 20 } @@ -284,13 +285,14 @@ Item { } else { slideEditor.imageBackground = ""; slideEditor.videoBackground = song.background; - slideEditor.loadVideo(); + /* slideEditor.loadVideo(); */ } changeSlideHAlignment(song.horizontalTextAlignment); changeSlideVAlignment(song.verticalTextAlignment); changeSlideFont(song.font, true); changeSlideFontSize(song.fontSize, true) + changeSlideText(songIndex); print(s.title); } @@ -396,4 +398,11 @@ Item { fontSizeBox.value = fontSize; slideEditor.fontSize = fontSize; } + + function changeSlideText(id) { + const verses = songsqlmodel.getLyricList(id); + print("Here are the verses: " + verses); + slideEditor.songs.clear() + verses.forEach(slideEditor.appendVerse); + } }