From 4a32f8b806cc6659dea79569a2e280ff62093711 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 31 Oct 2023 19:29:03 +0100 Subject: [PATCH] QStyle: cleanup iconFromApplicationTheme() Cleanup iconFromApplicationTheme() by merging the code paths for SP_DirLinkIcon and SP_FileLinkIcon. Change-Id: If4c8c850516971a80dffcc59cff7cabdace94585 Reviewed-by: Axel Spoerl --- src/widgets/styles/qcommonstyle.cpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 5859b0e6d3..b4e414ce4e 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5751,11 +5751,13 @@ QIcon QCommonStylePrivate::iconFromApplicationTheme(QCommonStyle::StandardPixmap return iconFromApplicationTheme(rtl(option) ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, option, widget); + case QStyle::SP_DirLinkIcon: case QStyle::SP_FileLinkIcon: { + const auto si = (standardIcon == QStyle::SP_DirLinkIcon) + ? QStyle::SP_DirIcon : QStyle::SP_FileIcon; QIcon icon; const QIcon linkIcon = QIcon::fromTheme("emblem-symbolic-link"_L1); - const QIcon baseIcon = iconFromApplicationTheme(QStyle::SP_FileIcon, - option, widget); + const QIcon baseIcon = iconFromApplicationTheme(si, option, widget); if (!linkIcon.isNull() || !baseIcon.isNull()) { const auto sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off); const auto dpr = qt_getDevicePixelRatio(widget); @@ -5771,26 +5773,6 @@ QIcon QCommonStylePrivate::iconFromApplicationTheme(QCommonStyle::StandardPixmap return icon; } break; - case QStyle::SP_DirLinkIcon: { - QIcon icon; - const QIcon linkIcon = QIcon::fromTheme("emblem-symbolic-link"_L1); - const QIcon baseIcon = iconFromApplicationTheme(QStyle::SP_DirIcon, - option, widget); - if (!linkIcon.isNull() || !baseIcon.isNull()) { - const auto sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off); - const auto dpr = qt_getDevicePixelRatio(widget); - for (const auto size : sizes) { - QPixmap basePixmap = baseIcon.pixmap(size, dpr); - QPixmap linkPixmap = linkIcon.pixmap(size / 2, dpr); - QPainter painter(&basePixmap); - const auto w = size.width() / 2; - painter.drawPixmap(w, w, linkPixmap); - icon.addPixmap(basePixmap); - } - } - return icon; - } - break; case QStyle::SP_LineEditClearButton: { const QString directionalThemeName = rtl(option) ? QStringLiteral("edit-clear-locationbar-ltr") : QStringLiteral("edit-clear-locationbar-rtl");