diff --git a/plugins/platformtheme/themed-icon-engine.cpp b/plugins/platformtheme/themed-icon-engine.cpp index 4d61344956a4715de4babe4d38d2971f34802457..de84ba69064450976429139e5b99ac2b959e5e72 100644 --- a/plugins/platformtheme/themed-icon-engine.cpp +++ b/plugins/platformtheme/themed-icon-engine.cpp @@ -22,6 +22,8 @@ #include #include #include +#include "lib/theme/palette.h" +#include "plugins/platformtheme/appearance-monitor.h" namespace Kiran { @@ -29,15 +31,35 @@ namespace Platformtheme { ThemedIconEngine::ThemedIconEngine(const QString &themeSvgIconName, const SvgConvertType type) : QIconEngine(), + m_svgColor(Kiran::Theme::Palette::getDefault()->getBaseColors().baseForeground), m_iconName(themeSvgIconName), m_svgConvertType(type) { m_settingsMonitor = Kiran::Platformtheme::AppearanceMonitor::instance(); - QObject::connect(m_settingsMonitor, &Kiran::Platformtheme::AppearanceMonitor::gtkThemeChanged, [this]() - { changeSvgIconColor(); }); + m_themeChangedConn = QObject::connect(m_settingsMonitor, &AppearanceMonitor::gtkThemeChanged, [this]() + { changeSvgIconColor(); }); } -ThemedIconEngine::~ThemedIconEngine() = default; +ThemedIconEngine::ThemedIconEngine(const ThemedIconEngine &other) + : QIconEngine(other), + m_svgColor(other.m_svgColor), + m_iconName(other.m_iconName), + m_svgIconPath(other.m_svgIconPath), + m_pixmapCache(other.m_pixmapCache), + m_iconLoaderThemeKey(other.m_iconLoaderThemeKey), + m_settingsMonitor(other.m_settingsMonitor), + m_svgConvertType(other.m_svgConvertType), + m_themeChangedConn(QMetaObject::Connection()) +{ + m_settingsMonitor = Kiran::Platformtheme::AppearanceMonitor::instance(); + m_themeChangedConn = QObject::connect(m_settingsMonitor, &AppearanceMonitor::gtkThemeChanged, [this]() + { changeSvgIconColor(); }); +} + +ThemedIconEngine::~ThemedIconEngine() +{ + QObject::disconnect(m_themeChangedConn); +} bool ThemedIconEngine::isValid(const QString &themeSvgIconName) { diff --git a/plugins/platformtheme/themed-icon-engine.h b/plugins/platformtheme/themed-icon-engine.h index 0c1a735ef69d565c0db133be53415f9d6ca3b6e8..6d74997abb4fbfff8c9d3cf34b410974dd03f98b 100644 --- a/plugins/platformtheme/themed-icon-engine.h +++ b/plugins/platformtheme/themed-icon-engine.h @@ -17,14 +17,12 @@ #include #include #include -#include -#include "lib/theme/palette.h" -#include "plugins/platformtheme/appearance-monitor.h" namespace Kiran { namespace Platformtheme { +class AppearanceMonitor; class ThemedIconEngine : public QIconEngine { public: @@ -36,6 +34,7 @@ public: public: explicit ThemedIconEngine(const QString &themeSvgIconName, const SvgConvertType type); + ThemedIconEngine(const ThemedIconEngine& other); ~ThemedIconEngine() override; static bool isValid(const QString &themeSvgIconName); @@ -54,16 +53,15 @@ private slots: void changeSvgIconColor(); private: - QColor m_svgColor = Kiran::Theme::Palette::getDefault()->getBaseColors().baseForeground; + QColor m_svgColor; QString m_iconName; QString m_svgIconPath; - QMap m_pixmapCache; - uint m_iconLoaderThemeKey = 0; - Platformtheme::AppearanceMonitor *m_settingsMonitor; - + AppearanceMonitor *m_settingsMonitor; SvgConvertType m_svgConvertType; + QMetaObject::Connection m_themeChangedConn; + }; } // namespace Platformtheme } // namespace Kiran