Commit bafc90d7 authored by Peter Mühlenpfordt's avatar Peter Mühlenpfordt
Browse files

Scale up folder icon before creating preview overlays

Summary:
If a custom folder icon is smaller than the requested preview size
`KIO::PreviewJob` returns a pixmap of only that size. E.g. `dolphin`
scales this up to its current thumbnail size which results in ugly
overlay icons for very small folder icons. If the folder icon is
scaled up before creating the overlay icons the overall preview
looks much better.

CCBUG: 315983

Test Plan:
# Set a small custom icon (e.g. 32 px) for a folder containing images
# Start dolphin with `Preview` enabled in the parent folder
# Zoom thumbnails to e.g. 128 pixels overlay
# The overlayed preview icons should not be blurry

| Before:    | After:     |
| {F5837958} | {F5837960} |

Reviewers: #frameworks, rkflx

Reviewed By: rkflx

Subscribers: ngraham, rkflx

Differential Revision: https://phabricator.kde.org/D12734
parent 69128259
......@@ -467,7 +467,14 @@ 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 icon to ensure overlays are rendered with
// the best quality possible even for low-res custom folder icons
if (qMax(folder.width(), folder.height()) < extent) {
folder = folder.scaled(extent, extent, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
const int folderWidth = folder.width();
const int folderHeight = folder.height();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment