diff options
| author | Arno <am@disconnect.de> | 2010-12-11 13:06:20 +0100 | 
|---|---|---|
| committer | Arno <am@disconnect.de> | 2010-12-11 13:06:20 +0100 | 
| commit | c3b7144f5aef2906d85339d3b9c5bf8eaa3a6356 (patch) | |
| tree | cb5c3d8d6ad572148f36cfc8b75307fdea386b9f /helper.cpp | |
| parent | a87e4d8c3c2102e9728dd5df303acca7ae08b343 (diff) | |
| download | SheMov-c3b7144f5aef2906d85339d3b9c5bf8eaa3a6356.tar.gz SheMov-c3b7144f5aef2906d85339d3b9c5bf8eaa3a6356.tar.bz2 SheMov-c3b7144f5aef2906d85339d3b9c5bf8eaa3a6356.zip | |
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
Diffstat (limited to 'helper.cpp')
| -rw-r--r-- | helper.cpp | 26 | 
1 files changed, 25 insertions, 1 deletions
| @@ -14,6 +14,9 @@  #include <QHash>  #include <QSettings>  #include <QDir> +#include <QPixmap> +#include <QTemporaryFile> +#include <QProcess>  #include <stdio.h> @@ -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();  	} | 
