diff --git a/ToolTips/tooltipmanager.cpp b/ToolTips/tooltipmanager.cpp --- a/ToolTips/tooltipmanager.cpp +++ b/ToolTips/tooltipmanager.cpp @@ -31,9 +31,20 @@ #include #include +#include #include #include +class IconLoaderSingleton +{ +public: + IconLoaderSingleton() = default; + + KIconLoader self; +}; + +Q_GLOBAL_STATIC(IconLoaderSingleton, privateIconLoaderSelf) + class ToolTipManager::Private { public: @@ -173,7 +184,15 @@ textLabel->setText( text ); // Get icon - QIcon icon( menuItem->icon() ); + QPalette pal = textLabel->palette(); + for (auto state : { QPalette::Active, QPalette::Inactive, QPalette::Disabled }) { + pal.setBrush(state, QPalette::WindowText, pal.toolTipText()); + pal.setBrush(state, QPalette::Window, pal.toolTipBase()); + } + + privateIconLoaderSelf->self.setCustomPalette(pal); + + QIcon icon = KDE::icon(menuItem->iconName(), &privateIconLoaderSelf->self); QLabel * iconLabel = new QLabel( toolTip ); iconLabel->setPixmap( icon.pixmap(iconSize) ); iconLabel->setMaximumSize( iconSize ); diff --git a/infokcmmodel.cpp b/infokcmmodel.cpp --- a/infokcmmodel.cpp +++ b/infokcmmodel.cpp @@ -164,7 +164,7 @@ case Qt::UserRole: return item->weight(); case Qt::DecorationRole: - return item->icon(); + return QIcon::fromTheme(item->iconName()); default: return QVariant(); } diff --git a/kcmcategoryitem.h b/kcmcategoryitem.h --- a/kcmcategoryitem.h +++ b/kcmcategoryitem.h @@ -77,7 +77,7 @@ /** * Get icon tied to KCM */ - QIcon icon() const override; + QString iconName() const override; /** * Get whatsThis information from KCM diff --git a/kcmcategoryitem.cpp b/kcmcategoryitem.cpp --- a/kcmcategoryitem.cpp +++ b/kcmcategoryitem.cpp @@ -65,13 +65,13 @@ return (category().count() + 1000); } -QIcon KcmCategoryItem::icon() const +QString KcmCategoryItem::iconName() const { if(m_category.isEmpty()) { - return QIcon::fromTheme(m_moduleInfo->icon()); + return m_moduleInfo->icon(); } - return QIcon(); + return QString(); } QString KcmCategoryItem::whatsThis() const diff --git a/kcmtreeitem.h b/kcmtreeitem.h --- a/kcmtreeitem.h +++ b/kcmtreeitem.h @@ -135,7 +135,7 @@ /** * Get icon tied to KCM */ - virtual QIcon icon() const; + virtual QString iconName() const; /** * Get whatsThis information from KCM diff --git a/kcmtreeitem.cpp b/kcmtreeitem.cpp --- a/kcmtreeitem.cpp +++ b/kcmtreeitem.cpp @@ -125,9 +125,9 @@ return m_moduleInfo->weight(); } -QIcon KcmTreeItem::icon() const +QString KcmTreeItem::iconName() const { - return QIcon::fromTheme(m_moduleInfo->icon()); + return m_moduleInfo->icon(); } QString KcmTreeItem::whatsThis() const