Qt: Add workaround for incorrectly tinted icons after theme switch

This commit is contained in:
TheLastRar 2025-06-02 18:20:48 +01:00
parent 658e98ba62
commit 4a99dbc7ee
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtGui/QPalette> #include <QtGui/QPalette>
#include <QtGui/QPixmapCache>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtWidgets/QStyle> #include <QtWidgets/QStyle>
#include <QtWidgets/QStyleFactory> #include <QtWidgets/QStyleFactory>
@ -43,6 +44,12 @@ void QtHost::UpdateApplicationTheme()
SetStyleFromSettings(); SetStyleFromSettings();
SetIconThemeFromStyle(); SetIconThemeFromStyle();
// Qt generates tinted versions of icons and stores them in QPixmapCache
// The key used does not seem to include the theme (or tint colour).
// This can cause icons tinted for wrong theme to be used for selected/disabled.
// As a workaround, reset the pixmap cache to clear icons tinted for the old theme.
QPixmapCache::clear();
} }
bool QtHost::IsDarkApplicationTheme() bool QtHost::IsDarkApplicationTheme()