mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Adjust selection color of delimiter icons
This commit is contained in:
parent
f330682a0c
commit
fa56a5eb98
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user