Paste P204

Improve preview overlay for low-res folder icons
ActivePublic

Authored by rkflx on May 5 2018, 1:42 PM.
diff --git a/thumbnail/thumbnail.cpp b/thumbnail/thumbnail.cpp
index 502b2d17..bc3f6aa3 100644
--- a/thumbnail/thumbnail.cpp
+++ b/thumbnail/thumbnail.cpp
@@ -467,11 +467,17 @@ QImage ThumbnailProtocol::thumbForDirectory(const QUrl& directory)
QString localFile = directory.path();
KFileItem item(QUrl::fromLocalFile(localFile));
- const QPixmap folder = QIcon::fromTheme(item.iconName()).pixmap(qMin(m_width, m_height));
+ const int extent = qMin(m_width, m_height);
+ QPixmap folder = QIcon::fromTheme(item.iconName()).pixmap(extent);
+
+ // Scale up base image to ensure overlays are rendered with
+ // the best quality possible even for low-res custom folder icons
+ if (folder.width() < extent || folder.height() < extent) {
+ folder = folder.scaled(extent, extent, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
const int folderWidth = folder.width();
const int folderHeight = folder.height();
-
const int topMargin = folderHeight * 30 / 100;
const int bottomMargin = folderHeight / 6;
const int leftMargin = folderWidth / 13;
rkflx edited the content of this paste. (Show Details)May 5 2018, 1:42 PM
rkflx changed the title of this paste from untitled to Improve preview overlay for low-res folder icons.
rkflx updated the paste's language from autodetect to autodetect.