From 22b8d52311a404a272c8d7d06b0fefe1ef083bc8 Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Thu, 11 Jun 2026 00:56:28 +0700 Subject: [PATCH] Qt/GameListBackground: Auto adjust gamelist type icon color --- pcsx2-qt/GameList/GameListWidget.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pcsx2-qt/GameList/GameListWidget.cpp b/pcsx2-qt/GameList/GameListWidget.cpp index 73fdef8a5c..a0dc82f986 100644 --- a/pcsx2-qt/GameList/GameListWidget.cpp +++ b/pcsx2-qt/GameList/GameListWidget.cpp @@ -194,6 +194,29 @@ namespace painter->drawPixmap(rect.topLeft() + icon_top_left, highlighted_icon); } + // Recolor the icon based on the custom background color + else if (index.column() == GameListModel::Column_Type) + { + // Fetch pixmap from cache or construct a new one. + const QColor color = option.palette.color(QPalette::Text); + const QString key = QString::fromStdString(fmt::format("type-{:016X}-{:08X}", icon.cacheKey(), color.rgba())); + + QPixmap tinted_icon; + if (!QPixmapCache::find(key, &tinted_icon)) + { + QImage img = icon.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); + + QPainter tinted_painter(&img); + tinted_painter.setCompositionMode(QPainter::CompositionMode_SourceAtop); + tinted_painter.fillRect(0, 0, img.width(), img.height(), color); + tinted_painter.end(); + + tinted_icon = QPixmap(QPixmap::fromImage(img)); + QPixmapCache::insert(key, tinted_icon); + } + + painter->drawPixmap(rect.topLeft() + icon_top_left, tinted_icon); + } else { painter->drawPixmap(rect.topLeft() + icon_top_left, icon);