Commit 23fa3698 authored by Marco Martin's avatar Marco Martin

color monochrome icons to tooltip colors

Summary:
when the tooltips are dark, monochrome icons can be black on black
use kiconloader with a custom palette to color any eventual monochrome icon

Test Plan: monochrome icons appear white

Reviewers: #plasma, sitter

Reviewed By: sitter

Subscribers: broulik, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19596
parent e1f29e14
......@@ -31,9 +31,20 @@
#include <QAbstractItemView>
#include <QIcon>
#include <KIconLoader>
#include <KColorScheme>
#include <KToolTipWidget>
class IconLoaderSingleton
{
public:
IconLoaderSingleton() = default;
KIconLoader self;
};
Q_GLOBAL_STATIC(IconLoaderSingleton, privateIconLoaderSelf)
class ToolTipManager::Private
{
public:
......@@ -173,7 +184,15 @@ QLayout * ToolTipManager::generateToolTipLine( const QModelIndex & item, QWidget
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 );
......
......@@ -164,7 +164,7 @@ QVariant InfoKcmModel::data(const QModelIndex &index, int role) const
case Qt::UserRole:
return item->weight();
case Qt::DecorationRole:
return item->icon();
return QIcon::fromTheme(item->iconName());
default:
return QVariant();
}
......
......@@ -65,13 +65,13 @@ int KcmCategoryItem::weight() const
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
......
......@@ -77,7 +77,7 @@ class KcmCategoryItem : public KcmTreeItem
/**
* Get icon tied to KCM
*/
QIcon icon() const override;
QString iconName() const override;
/**
* Get whatsThis information from KCM
......
......@@ -125,9 +125,9 @@ int KcmTreeItem::weight() const
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
......
......@@ -135,7 +135,7 @@ class KcmTreeItem
/**
* Get icon tied to KCM
*/
virtual QIcon icon() const;
virtual QString iconName() const;
/**
* Get whatsThis information from KCM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment