From c7e3315b663566f71f83dcc9d2259aac262081c1 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 27 Nov 2016 20:25:49 +0100 Subject: Add preview for videos Grab 4 frames from a video and display them in the Viewer. First frame is @00:01:00, last at length - 1 minute, and the other two are in between: length / 4 * 2 and 3 (hardcoded). --- viewer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'viewer.cpp') diff --git a/viewer.cpp b/viewer.cpp index 5b35b96..cd17b6a 100644 --- a/viewer.cpp +++ b/viewer.cpp @@ -7,6 +7,7 @@ #include #include +#include "helper.h" #include "viewer.h" Viewer::Viewer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), mCurIndex(-1) { @@ -43,7 +44,21 @@ void Viewer::setFile(const QString &file, bool allFiles){ } } +void Viewer::preview(const QString &file){ + mFiles.clear(); + mCurIndex = -1; + QPixmap pm = Helper::preview(file); + mLabel->setPixmap(pm); + QString winTitle = QString(tr("%1 Viewer: [Preview %2]")).arg(qApp->applicationName()).arg(file); + setWindowTitle(winTitle); + adjustSize(); +} + + void Viewer::wheelEvent(QWheelEvent *event){ + if(mCurIndex == -1){ + return; + } QPoint numDeg = event->angleDelta() / 8; if(numDeg.y() < 0){ //this is scrolling down -> next! if(mCurIndex + 1 >= mFiles.count()){ -- cgit v1.2.3-70-g09d2