[LyX/master] Adjust selection color of delimiter icons
Juergen Spitzmueller
spitz at lyx.org
Sun Feb 7 11:29:42 UTC 2021
commit fa56a5eb98d8568b036d66b391735181d6c451a0
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sun Feb 7 12:32:11 2021 +0100
Adjust selection color of delimiter icons
---
src/frontends/qt/GuiDelimiter.cpp | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt/GuiDelimiter.cpp b/src/frontends/qt/GuiDelimiter.cpp
index 9043974..5b23804 100644
--- a/src/frontends/qt/GuiDelimiter.cpp
+++ b/src/frontends/qt/GuiDelimiter.cpp
@@ -90,21 +90,27 @@ struct MathSymbol {
};
-QPixmap getSelectedPixmap(QPixmap pixmap)
+QPixmap getSelectedPixmap(QPixmap pixmap, QSize const icon_size)
{
QPalette palette = QPalette();
QColor text_color = (guiApp->isInDarkMode())
? palette.color(QPalette::Active, QPalette::WindowText)
: Qt::black;
QColor highlight_color = palette.color(QPalette::Active, QPalette::HighlightedText);
+ QColor highlight_bg = palette.color(QPalette::Active, QPalette::Highlight);
// create a layer with black text turned to QPalette::HighlightedText
QPixmap hl_overlay(pixmap.size());
hl_overlay.fill(highlight_color);
hl_overlay.setMask(pixmap.createMaskFromColor(text_color, Qt::MaskOutColor));
+ // Create highlighted background
+ QPixmap hl_background(icon_size);
+ hl_background.fill(highlight_bg);
+
// put layers on top of existing pixmap
QPainter painter(&pixmap);
+ painter.drawPixmap(pixmap.rect(), hl_background);
painter.drawPixmap(pixmap.rect(), hl_overlay);
return pixmap;
@@ -240,7 +246,7 @@ GuiDelimiter::GuiDelimiter(GuiView & lv)
// get pixmap with bullets
QPixmap pixmap = getPixmap("images/math/", toqstr(ms.icon), "svgz,png");
QIcon icon(pixmap);
- icon.addPixmap(getSelectedPixmap(pixmap), QIcon::Selected);
+ icon.addPixmap(getSelectedPixmap(pixmap, icon_size), QIcon::Selected);
QListWidgetItem * lwi = new QListWidgetItem(icon, QString());
setDelimiterName(lwi, delim);
left_list_items_[ms.unicode] = lwi;
More information about the lyx-cvs
mailing list