From c3b7144f5aef2906d85339d3b9c5bf8eaa3a6356 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 11 Dec 2010 13:06:20 +0100 Subject: Implement hover over movies What started as an attempt to show a frame from a movie when hovering over it, ended in a huge bugfix commit for hover related stuff. This commit is definitely not atomic. When hovering over a movie present on the filesytem a frame is shown. The time frame is configurable. While digging into the code I noticed some bugs. Bugfixes: * fix label for hove archive action. It was labeled for hovering over directories in FSWidget. * Hovering over directories didn't have an action. Also read the appropriate value from QSettings. Other: * add icons for hovering over directories and hovering over movies * replace SheMov::toggleHover(pics|some other) with a QSignalMapper --- helper.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'helper.cpp') diff --git a/helper.cpp b/helper.cpp index fdab083..126b83d 100644 --- a/helper.cpp +++ b/helper.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include @@ -149,7 +152,7 @@ namespace Helper { return qMakePair(programData.value("path").toString(), programData.value("args").toStringList()); } - QString durationFromSecs(qint64 secs){ + const QString durationFromSecs(qint64 secs){ int minutes = secs / 60; int hours = 0; int seconds = 0; @@ -164,6 +167,27 @@ namespace Helper { return retval; } + const QPixmap grabFrame(const QString &file, QString when){ + QSettings s; + QString ffMpegPath = s.value("paths/ffmpeg").toString(); + if(when.isEmpty()){ + when = s.value("ui/grabframe", "00:00:00").toString(); + } + QString tmptmp = QString("%1/smhover-XXXXXX.png").arg(QDir::tempPath()); + QTemporaryFile tmpPic(tmptmp); + if(tmpPic.open()){ + QStringList ffMpegArgs = QStringList() << "-vframes" << "1" << "-ss" << when << "-i" << file << "-y" << tmpPic.fileName(); + QProcess ffmpeg; + ffmpeg.start(ffMpegPath, ffMpegArgs); + if(!ffmpeg.waitForStarted()){ + return QPixmap(); + } + ffmpeg.waitForFinished(); + return QPixmap(tmpPic.fileName()); + } + return QPixmap(); + } + bool SortFileInfoList::operator ()(const QFileInfo &lhs, const QFileInfo &rhs) const { return lhs.fileName().toLower() < rhs.fileName().toLower(); } -- cgit v1.2.3-70-g09d2