diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include "fadingnode_p.h" #include +#include "theme.h" #include "units.h" IconItem::IconItem(QQuickItem *parent) @@ -595,7 +597,9 @@ result = m_svgIcon->pixmap(); } } else if (!m_icon.isNull()) { + KIconLoader::global()->setCustomPalette(Plasma::Theme().palette()); result = m_icon.pixmap(QSize(size, size) * (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio())); + KIconLoader::global()->resetPalette(); } else if (!m_imageIcon.isNull()) { result = QPixmap::fromImage(m_imageIcon); } else { diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -119,6 +119,7 @@ KColorScheme buttonColorScheme; KColorScheme viewColorScheme; KColorScheme complementaryColorScheme; + QPalette palette; bool eventFilter(QObject *watched, QEvent *event) override; KConfigGroup cfg; QString defaultWallpaperTheme; diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -400,6 +400,7 @@ buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors); viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors); selectionColorScheme = KColorScheme(QPalette::Active, KColorScheme::Selection, colors); + palette = KColorScheme::createApplicationPalette(colors); scheduleThemeChangeNotification(PixmapCache | SvgElementsCache); emit applicationPaletteChange(); } @@ -802,6 +803,7 @@ buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors); viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors); complementaryColorScheme = KColorScheme(QPalette::Active, KColorScheme::Complementary, colors); + palette = KColorScheme::createApplicationPalette(colors); const QString wallpaperPath = QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/wallpapers/"); hasWallpapers = !QStandardPaths::locate(QStandardPaths::GenericDataLocation, wallpaperPath, QStandardPaths::LocateDirectory).isEmpty(); diff --git a/src/plasma/theme.h b/src/plasma/theme.h --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -67,6 +67,8 @@ // stylesheet Q_PROPERTY(QString styleSheet READ styleSheet NOTIFY themeChanged) + Q_PROPERTY(QPalette palette READ palette NOTIFY themeChanged) + public: enum ColorRole { TextColor = 0, /**< the text color to be used by items resting on the background */ @@ -215,6 +217,12 @@ */ QString styleSheet(const QString &css = QString()) const; + /** + * Returns a QPalette with the colors set as defined by the theme. + * @since 5.68 + */ + QPalette palette() const; + /** * This is an overloaded member provided to check with file timestamp * where cache is still valid. diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -194,6 +194,12 @@ return d->processStyleSheet(css, Svg::Status::Normal); } + +QPalette Theme::palette() const +{ + return d->palette; +} + QString Theme::wallpaperPath(const QSize &size) const { QString fullPath;