diff --git a/app/advancedconfigpage.ui b/app/advancedconfigpage.ui
--- a/app/advancedconfigpage.ui
+++ b/app/advancedconfigpage.ui
@@ -26,7 +26,7 @@
-
- Delete thumbnail cache folder on exit
+ Low resource usage mode
@@ -48,7 +48,7 @@
-
- Enable this option if you do not have a lot of disk space.<br/><br/><em>Be careful:</em> this will delete the folder named <filename>.thumbnails</filename> in your home folder, deleting all thumbnails previously generated by Gwenview and other applications.
+ Enable this option if you do not have a lot of disk space. This will avoid storing thumbnails on disk and will prefer embedded thumbnails of lower quality that are faster to load, if available.<br/><br/><em>Be careful:</em> this will delete the folder named <filename>.thumbnails</filename> in your home folder, deleting all thumbnails previously generated by Gwenview and other applications.
true
diff --git a/doc/index.docbook b/doc/index.docbook
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -846,7 +846,7 @@
Cache
- Enable the Delete thumbnail cache folder on exit option if you do not have a lot of disk space.
+ Enable the Low resource usage mode option if you do not have a lot of disk space. This will avoid storing thumbnails on disk and will prefer embedded thumbnails of lower quality that are faster to load, if available.
Be careful: This will delete the folder named .thumbnails in your home folder, deleting all thumbnails previously generated by &gwenview; and other applications.
diff --git a/lib/thumbnailprovider/thumbnailgenerator.cpp b/lib/thumbnailprovider/thumbnailgenerator.cpp
--- a/lib/thumbnailprovider/thumbnailgenerator.cpp
+++ b/lib/thumbnailprovider/thumbnailgenerator.cpp
@@ -116,7 +116,11 @@
if (!content.rawData().isEmpty()) {
QImage thumbnail = content.thumbnail();
- if (qMax(thumbnail.width(), thumbnail.height()) >= pixelSize) {
+ // If the user does not care about the generated thumbnails (by deleting them on exit), use ANY
+ // embedded thumnail, even if it's too small.
+ if (!thumbnail.isNull() &&
+ (GwenviewConfig::deleteThumbnailCacheOnExit() || qMax(thumbnail.width(), thumbnail.height()) >= pixelSize)
+ ) {
mImage = std::move(thumbnail);
mOriginalWidth = content.size().width();
mOriginalHeight = content.size().height();
diff --git a/tests/auto/thumbnailprovidertest.cpp b/tests/auto/thumbnailprovidertest.cpp
--- a/tests/auto/thumbnailprovidertest.cpp
+++ b/tests/auto/thumbnailprovidertest.cpp
@@ -34,6 +34,7 @@
// Local
#include "../lib/thumbnailprovider/thumbnailprovider.h"
#include "testutils.h"
+#include "gwenviewconfig.h"
// libc
#include
@@ -212,16 +213,21 @@
QVERIFY(TestUtils::imageCompare(expectedThumbnail, thumbnailPix.toImage()));
}
- // Loading a large thumbnail should bring the red one
+ // Loading a large thumbnail should bring the red one, unless thumbnails are deleted on exit,
+ // which should bring the white one
{
ThumbnailProvider provider;
provider.setThumbnailGroup(ThumbnailGroup::Large);
provider.appendItems(list);
QSignalSpy spy(&provider, SIGNAL(thumbnailLoaded(KFileItem,QPixmap,QSize,qulonglong)));
syncRun(&provider);
QCOMPARE(spy.count(), 1);
- expectedThumbnail = createColoredImage(256, 128, QColor(254, 0, 0));
+ if (GwenviewConfig::deleteThumbnailCacheOnExit()) {
+ expectedThumbnail = createColoredImage(128, 64, Qt::white);
+ } else {
+ expectedThumbnail = createColoredImage(256, 128, QColor(254, 0, 0));
+ }
thumbnailPix = qvariant_cast(spy.at(0).at(1));
QVERIFY(TestUtils::imageCompare(expectedThumbnail, thumbnailPix.toImage()));
}