summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/imagedownloader.cpp17
-rw-r--r--core/imagedownloader.h10
2 files changed, 23 insertions, 4 deletions
diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp
index d78409a3c..1559b129b 100644
--- a/core/imagedownloader.cpp
+++ b/core/imagedownloader.cpp
@@ -456,8 +456,23 @@ void Thumbnailer::imageDownloadFailed(QString filename)
workingOn.remove(filename);
}
-QImage Thumbnailer::fetchThumbnail(const QString &filename)
+QImage Thumbnailer::fetchThumbnail(const QString &filename, bool synchronous)
{
+ if (synchronous) {
+ // In synchronous mode, first try the thumbnail cache.
+ Thumbnail thumbnail = getThumbnailFromCache(filename);
+ if (!thumbnail.img.isNull())
+ return thumbnail.img;
+
+ // If that didn't work, try to thumbnail the image.
+ thumbnail = getHashedImage(filename, false);
+ if (thumbnail.type == MEDIATYPE_STILL_LOADING || thumbnail.img.isNull())
+ return failImage; // No support for delayed thumbnails (web).
+
+ int size = maxThumbnailSize();
+ return thumbnail.img.scaled(size, size, Qt::KeepAspectRatio);
+ }
+
QMutexLocker l(&lock);
// We are not currently fetching this thumbnail - add it to the list.
diff --git a/core/imagedownloader.h b/core/imagedownloader.h
index e0d70f59f..280383250 100644
--- a/core/imagedownloader.h
+++ b/core/imagedownloader.h
@@ -31,9 +31,13 @@ public:
static Thumbnailer *instance();
// Schedule a thumbnail for fetching or calculation.
- // Returns a placeholder thumbnail. The actual thumbnail will be sent
- // via a signal later.
- QImage fetchThumbnail(const QString &filename);
+ // If synchronous is false, returns a placeholder thumbnail.
+ // The actual thumbnail will be sent via a signal later.
+ // If synchronous is true, try to fetch the actual thumbnail.
+ // In this mode only precalculated thumbnails or thumbnails
+ // from pictures are returned. Video extraction and remote
+ // images are not supported.
+ QImage fetchThumbnail(const QString &filename, bool synchronous);
// Schedule multiple thumbnails for forced recalculation
void calculateThumbnails(const QVector<QString> &filenames);