Commit 8996c9bb authored by Nate Graham's avatar Nate Graham 🔩

Fix monochrome icons in tooltips

Summary:
This patch is shamelessly stolen from Marco Martin's work in KInfoCenter (23fa369831709f43a3100476b00ced10a1123f7f) and does the same thing for System Settings' tooltips.

Now Monochrome icons are displayed properly.

BUG: F6698413
FIXED-IN: 5.15.4

Test Plan: {F6698413, size=full}

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19834
parent bd832a32
......@@ -23,6 +23,7 @@
#include <QRect>
#include <QIcon>
#include <KIconLoader>
#include <QLabel>
#include <QTimer>
#include <QScrollBar>
......@@ -35,6 +36,16 @@
#include <KLocalizedString>
#include <KToolTipWidget>
class IconLoaderSingleton
{
public:
IconLoaderSingleton() = default;
KIconLoader self;
};
Q_GLOBAL_STATIC(IconLoaderSingleton, privateIconLoaderSelf);
class ToolTipManager::Private
{
public:
......@@ -200,8 +211,17 @@ QLayout * ToolTipManager::generateToolTipLine( QModelIndex * item, QWidget * too
textLabel->setText( text );
// Get 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->service()->icon(), &privateIconLoaderSelf->self);
QLabel * iconLabel = new QLabel( toolTip );
iconLabel->setPixmap( QIcon::fromTheme(menuItem->service()->icon()).pixmap(iconSize) );
iconLabel->setPixmap( icon.pixmap(iconSize) );
iconLabel->setMaximumSize( iconSize );
// Generate layout
......
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