summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Gâteau <agateau@kde.org>2012-08-29 13:42:44 (GMT)
committerAurélien Gâteau <agateau@kde.org>2012-08-29 13:42:50 (GMT)
commitef544ad919e62f6eeabef45da14f9ba2f67a02f3 (patch)
tree15b87e7d8dc591906772fbb882d81c8394880b81
parent1ceb719538891a06e4f61b73b9b341910fc3fa88 (diff)
parent7f380c578085d32ab8ae93d4f6fdada9cb359323 (diff)
Merge branch 'gen-normal-thumbnails-from-large'
REVIEW: 105916
-rw-r--r--lib/thumbnailloadjob.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/thumbnailloadjob.cpp b/lib/thumbnailloadjob.cpp
index dbe7817..4d1a995 100644
--- a/lib/thumbnailloadjob.cpp
+++ b/lib/thumbnailloadjob.cpp
@@ -588,7 +588,25 @@ QImage ThumbnailLoadJob::loadThumbnailFromCache() const
if (!image.isNull()) {
return image;
}
- return QImage(mThumbnailPath);
+
+ image = QImage(mThumbnailPath);
+ if (image.isNull() && mThumbnailGroup == ThumbnailGroup::Normal) {
+ // If there is a large-sized thumbnail, generate the normal-sized version from it
+ QString largeThumbnailPath = generateThumbnailPath(mOriginalUri, ThumbnailGroup::Large);
+ QImage largeImage(largeThumbnailPath);
+ if (largeImage.isNull()) {
+ return image;
+ }
+ int size = ThumbnailGroup::pixelSize(ThumbnailGroup::Normal);
+ image = largeImage.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ Q_FOREACH(const QString& key, largeImage.textKeys()) {
+ QString text = largeImage.text(key);
+ image.setText(key, text);
+ }
+ sThumbnailCache->queueThumbnail(mThumbnailPath, image);
+ }
+
+ return image;
}
void ThumbnailLoadJob::checkThumbnail()