From 5cb53606b61cf5fc5953d0889797feed5734d58b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 4 Oct 2023 13:10:07 +0200 Subject: [PATCH] Introduce color_selectionmath To have a distinctive color for selected math which works in both modes Also, link color_selectionmath with QPalette::HighlightedText, so we won't need to special-case on lyxrc.use_system_colors any longer --- src/Color.cpp | 1 + src/ColorCode.h | 2 ++ src/frontends/qt/ColorCache.cpp | 1 + src/mathed/InsetMathHull.cpp | 3 +-- src/mathed/MathRow.cpp | 3 +-- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Color.cpp b/src/Color.cpp index 3b9e68ebd1..23e40a9c94 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -264,6 +264,7 @@ ColorSet::ColorSet() { Color_background, N_("background"), "background", Linen, black, "background" }, { Color_foreground, N_("text"), "foreground", black, Linen, "foreground" }, { Color_selection, N_("selection"), "selection", "#add8e6", "#add8e6", "selection" }, + { Color_selectionmath, N_("selected math"), "selectionmath", "#00008B", "#00008B", "selectionmath" }, { Color_selectiontext, N_("selected text"), "selectiontext", black, black, "selectiontext" }, { Color_latex, N_("LaTeX text"), "latex", DarkRed, "#D66613", "latex" }, { Color_textlabel1, N_("Text label 1"), "textlabel1", blue, "#86a4ff", "textlabel1" }, diff --git a/src/ColorCode.h b/src/ColorCode.h index 3439c28727..9b26e7219c 100644 --- a/src/ColorCode.h +++ b/src/ColorCode.h @@ -65,6 +65,8 @@ enum ColorCode { Color_foreground, /// Background color of selected text Color_selection, + /// Foreground color of selected math + Color_selectionmath, /// Foreground color of selected text Color_selectiontext, /// Text color in LaTeX mode diff --git a/src/frontends/qt/ColorCache.cpp b/src/frontends/qt/ColorCache.cpp index 821494edc1..1c3d68e548 100644 --- a/src/frontends/qt/ColorCache.cpp +++ b/src/frontends/qt/ColorCache.cpp @@ -45,6 +45,7 @@ QPalette::ColorRole role(ColorCode col) case Color_selection: return QPalette::Highlight; break; + case Color_selectionmath: case Color_selectiontext: return QPalette::HighlightedText; break; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index d2c2159167..1cf3be201d 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -697,8 +697,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const } // Then the equations - ColorCode color = pi.selected && lyxrc.use_system_colors - ? Color_selectiontext : standardColor(); + ColorCode color = pi.selected ? Color_selectionmath : standardColor(); bool const really_change_color = pi.base.font.color() == Color_none; Changer dummy0 = really_change_color ? pi.base.font.changeColor(color) : noChange(); diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp index fee869c89a..8e46b59047 100644 --- a/src/mathed/MathRow.cpp +++ b/src/mathed/MathRow.cpp @@ -356,8 +356,7 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) const x += e.before + e.after; break; case BEGIN_SEL: - if (lyxrc.use_system_colors) - change_color = pi.base.font.changeColor(Color_selectiontext); + change_color = pi.base.font.changeColor(Color_selectionmath); break; case END_SEL: change_color = noChange(); -- 2.39.5