color monochrome icons to tooltip colors
ClosedPublic

Authored by mart on Mar 7 2019, 3:32 PM.

Details

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

Diff Detail

Repository
R102 KInfoCenter
Branch
phab/iconColor
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 9499
Build 9517: arc lint + arc unit
mart created this revision.Mar 7 2019, 3:32 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 7 2019, 3:32 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
mart requested review of this revision.Mar 7 2019, 3:32 PM
sitter requested changes to this revision.Mar 7 2019, 4:16 PM

That seems to break the category icons because KDE::icon(menuItem->kcm().icon() is only working on Kcm entries, while KcmCategory entries overload ::icon with divergent behavior.

I think what we need is to change KcmTreeItem::icon() (and its derived class KcmCategoryItem) to QString KcmTreeItem::iconName() and use that on the KDE::icon call. And InfoKcmModel::data needs changing to QIcon::fromTheme(item->iconName()) I guess.

This revision now requires changes to proceed.Mar 7 2019, 4:16 PM
ngraham added a subscriber: ngraham.Mar 7 2019, 4:22 PM

Sweet, could you do the same thing for System Settings' tooltip too? It's a fork of this code (or maybe the reverse is true).

mart added a comment.Mar 7 2019, 4:29 PM

I think what we need is to change KcmTreeItem::icon() (and its derived class KcmCategoryItem) to QString KcmTreeItem::iconName() and use that on the KDE::icon call. And InfoKcmModel::data needs changing to QIcon::fromTheme(item->iconName()) I guess.

hmm, not sure?
that ::icon() call would be used also on the main view, in which you need *not* to change the colors

sitter added a comment.Mar 7 2019, 5:16 PM

The sidepanel (which I guess is the mainview) gets the icon from InfoKcmModel::data from what I can tell. ::data and ::generateToolTipLine are the only places where I see ::icon get called. So what I am thinking is these changes:

::icon goes away in favor of

QString KcmTreeItem::iconName() { return m_kcm.icon() }

and

QString KcmCategoryItem::iconName() { return m_category.icon() }

and the model creates a regular unaltered QIcon

QVariant InfoKcmModel::data(const QModelIndex &index, int role) const
{
...
    case Qt::DecorationRole:
        return QIcon::fromTheme(item->iconName());
...
}
mart added a comment.Mar 7 2019, 5:34 PM

The sidepanel (which I guess is the mainview) gets the icon from InfoKcmModel::data from what I can tell. ::data and ::generateToolTipLine are the only places where I see ::icon get called. So what I am thinking is these changes:

::icon goes away in favor of

QString KcmTreeItem::iconName() { return m_kcm.icon() }

and

QString KcmCategoryItem::iconName() { return m_category.icon() }

and the model creates a regular unaltered QIcon

QVariant InfoKcmModel::data(const QModelIndex &index, int role) const
{
...
    case Qt::DecorationRole:
        return QIcon::fromTheme(item->iconName());
...
}

+1
can give a try tomorrow

broulik added a subscriber: broulik.Mar 8 2019, 8:37 AM

What's the need for this wrapper class rather than just making the KIconLoader global static?

Following Kai's question... wouldn't KIconLoader::global make the entire static obsolete?

mart added a comment.Mar 8 2019, 2:38 PM

Following Kai's question... wouldn't KIconLoader::global make the entire static obsolete?

we need a second one, not the one used by the app, because we are altering how it colores the icons

mart updated this revision to Diff 53724.Mar 12 2019, 12:02 PM
  • icon()->iconName()
mart updated this revision to Diff 53725.Mar 12 2019, 12:05 PM
  • unbreak category icons
sitter accepted this revision.Mar 12 2019, 12:07 PM

It's gorgeous!

sheepit

This revision is now accepted and ready to land.Mar 12 2019, 12:07 PM
This revision was automatically updated to reflect the committed changes.

Nice! Would you mind doing the same for System Settings, which has the same code?

Dolphin's Tooltip could use the same treatment too, see https://bugs.kde.org/show_bug.cgi?id=404858