From cf0052c2968a7c3e110e24134dbe7ef13c835995 Mon Sep 17 00:00:00 2001 From: Nathaniel Graham Date: Thu, 6 Sep 2018 22:46:17 +0200 Subject: [PATCH] Make thumbnail frame-and-shadow drawing criteria match those of the file dialog Summary: KIO's file dialog already has logic to avoid drawing frames around images detected as likely to be icons, which is improved with D15071. Since Dolphin doesn't use KIO for any of this (boo) we have to pull it over here too; this patch brings the same feature to Dolphin, as well as the feature to disable frames and shadows for all thumbnails at very small sizes, which improves clarity. With this patch, Dolphin's frame drawing behavior becomes consistent with that of the file dialog (as of D15071). BUG: 295526 FIXED-IN: 18.12.0 Test Plan: Icons no longer have frames: {F6214279} Images without transparency still have frames: {F6214280} Nicer presentation for folders with mixed image types (images without transparency get frames; images without it don't): {F6214278} At small sizes, thumbnail clarity is improved by omitting the frame and shadow. Before: {F6214296} After: {F6214294} Reviewers: #dolphin, broulik, elvisangelaccio Reviewed By: #dolphin, broulik, elvisangelaccio Subscribers: markg, anthonyfieroni, elvisangelaccio, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D15069 --- src/kitemviews/kfileitemmodelrolesupdater.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index abc5f176a3..f4d69dec27 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -495,14 +495,9 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi QPixmap scaledPixmap = pixmap; - const QString mimeType = item.mimetype(); - const int slashIndex = mimeType.indexOf(QLatin1Char('/')); - const bool isFontPreview = mimeType.rightRef(slashIndex).contains(QLatin1String("font")); - const bool isFolderPreview = item.isDir(); - const bool isWindowsExePreview = mimeType == QLatin1String("application/x-ms-dos-executable") || - mimeType == QLatin1String("application/x-msdownload"); - - if (!isFolderPreview && !isFontPreview && !isWindowsExePreview) { + if (!pixmap.hasAlpha() + && m_iconSize.width() > KIconLoader::SizeSmallMedium + && m_iconSize.height() > KIconLoader::SizeSmallMedium) { if (m_enlargeSmallPreviews) { KPixmapModifier::applyFrame(scaledPixmap, m_iconSize); } else {