diff --git a/src/cpp/mpv/mpvobject.cpp b/src/cpp/mpv/mpvobject.cpp index 70a66cd..26e695e 100644 --- a/src/cpp/mpv/mpvobject.cpp +++ b/src/cpp/mpv/mpvobject.cpp @@ -533,7 +533,7 @@ void MpvObject::seek(double pos) { // qDebug() << "seek" << pos; pos = qMax(0.0, qMin(pos, m_duration)); - commandAsync(QVariantList() << "seek" << pos << "absolute"); + command(QVariantList() << "seek" << pos << "absolute"); } void MpvObject::loadFile(QVariant urls) @@ -542,9 +542,13 @@ void MpvObject::loadFile(QVariant urls) command(QVariantList() << "loadfile" << urls); } -void MpvObject::screenshotToFile(QUrl url) { - QString file = url.path() + ".jpg"; - commandAsync(QVariantList() << "screenshot-to-file" << file << "video"); +void MpvObject::screenshotToFile(QString file) { + command(QVariantList() << "show-progress"); + command(QVariantList() << "screenshot-to-file" << file << "video"); + command(QVariantList() << "show-progress"); + qDebug() << "screenshot-to-file" << file << "video"; + qDebug() << "screenshot made: " << file; + quit(); } void MpvObject::subAdd(QVariant urls) diff --git a/src/cpp/mpv/mpvobject.h b/src/cpp/mpv/mpvobject.h index d7a0244..52025d6 100644 --- a/src/cpp/mpv/mpvobject.h +++ b/src/cpp/mpv/mpvobject.h @@ -137,7 +137,7 @@ public slots: void stepForward(); void seek(double pos); void loadFile(QVariant urls); - void screenshotToFile(QUrl url); + void screenshotToFile(QString file); void subAdd(QVariant urls); bool enableAudio() const { return m_enableAudio; } diff --git a/src/cpp/slidemodel.cpp b/src/cpp/slidemodel.cpp index 3d5df9a..0a88cb8 100644 --- a/src/cpp/slidemodel.cpp +++ b/src/cpp/slidemodel.cpp @@ -1,4 +1,5 @@ #include "slidemodel.h" +#include "mpv/mpvobject.h" #include "serviceitem.h" #include "slide.h" #include @@ -12,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -645,31 +647,41 @@ void SlideModel::moveRowFromService(const int &fromIndex, QString SlideModel::thumbnailVideo(QString video, int serviceItemId) { - // if (!writeDir.mkpath(".")) { - // qFatal("Failed to create writable location at %s", qPrintable(writeDir.absolutePath())); + qDebug() << "dir location " << writeDir.absolutePath(); + if (!writeDir.mkpath(".")) { + qFatal("Failed to create writable location at %s", qPrintable(writeDir.absolutePath())); + } + + QDir dir = writeDir.absolutePath() + "/librepresenter/thumbnails"; + qDebug() << "thumbnails dir: " << dir; + QDir absDir = writeDir.absolutePath() + "/librepresenter"; + if (!dir.exists()) { + qDebug() << dir.path() << "does not exist"; + absDir.mkdir("thumbnails"); + } + qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; + qDebug() << dir.path(); + qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; + + QFileInfo vid(video); + QString id; + id.setNum(serviceItemId); + QString vidName(vid.fileName() + "-" + id); + qDebug() << vidName; + QString thumbnail = dir.path() + "/" + vidName + ".webp"; + QFileInfo thumbnailInfo(dir.path() + "/" + vidName + ".jpg"); + qDebug() << thumbnailInfo.filePath(); + // if (thumbnail.open(QIODevice::ReadOnly)) { + // qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; + // qDebug() << thumbnailInfo.filePath(); + // qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; // } - // qDebug() << "Url of screenshot to be taken: " << url; - // QDir dir = writeDir.absolutePath() + "/thumbnails"; - // qDebug() << "thumbnails dir: " << dir; - // QDir absDir = writeDir.absolutePath(); - // if (!dir.exists()) - // absDir.mkdir("thumbnails"); + MpvObject *mpv; + mpv->loadFile(video); + mpv->seek(5); + mpv->screenshotToFile(thumbnail); + // mpv.quit(); - QTemporaryFile thumbnail = ; - if (thumbnail.open()) { - qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; - qDebug() << thumbnail.fileName(); - qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; - - // return thumbnail.fileName(); - } - - QTemporaryDir dir; - if (dir.isValid()) { - // dir.path() returns the unique directory path - qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; - qDebug() << dir.path(); - qDebug() << "@@@@@@@@@@@@@@@@@@@@@"; - } + return thumbnailInfo.filePath(); } diff --git a/src/cpp/slidemodel.h b/src/cpp/slidemodel.h index f8d306a..49a42c8 100644 --- a/src/cpp/slidemodel.h +++ b/src/cpp/slidemodel.h @@ -79,7 +79,7 @@ public: Q_INVOKABLE QVariantMap getItem(int index) const; Q_INVOKABLE QVariantList getItems(); Q_INVOKABLE int findSlideIdFromServItm(int index); - Q_INVOKABLE void thumbnailVideo(QString video, int serviceItemId); + Q_INVOKABLE QString thumbnailVideo(QString video, int serviceItemId); public slots: diff --git a/src/qml/presenter/PreviewSlideListDelegate.qml b/src/qml/presenter/PreviewSlideListDelegate.qml index 9fa076f..edc893d 100644 --- a/src/qml/presenter/PreviewSlideListDelegate.qml +++ b/src/qml/presenter/PreviewSlideListDelegate.qml @@ -59,7 +59,8 @@ Item { anchors.fill: parent hoverEnabled: true onClicked: { - changeSlide(index); + /* changeSlide(index); */ + showPassiveNotification(SlideModel.thumbnailVideo(model.videoBackground, model.serviceItemId)); } cursorShape: Qt.PointingHandCursor propagateComposedEvents: true