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
This commit is contained in:
Juergen Spitzmueller 2023-10-04 13:10:07 +02:00
parent 65cb9fa4df
commit 5cb53606b6
5 changed files with 6 additions and 4 deletions

View File

@ -264,6 +264,7 @@ ColorSet::ColorSet()
{ Color_background, N_("background"), "background", Linen, black, "background" }, { Color_background, N_("background"), "background", Linen, black, "background" },
{ Color_foreground, N_("text"), "foreground", black, Linen, "foreground" }, { Color_foreground, N_("text"), "foreground", black, Linen, "foreground" },
{ Color_selection, N_("selection"), "selection", "#add8e6", "#add8e6", "selection" }, { 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_selectiontext, N_("selected text"), "selectiontext", black, black, "selectiontext" },
{ Color_latex, N_("LaTeX text"), "latex", DarkRed, "#D66613", "latex" }, { Color_latex, N_("LaTeX text"), "latex", DarkRed, "#D66613", "latex" },
{ Color_textlabel1, N_("Text label 1"), "textlabel1", blue, "#86a4ff", "textlabel1" }, { Color_textlabel1, N_("Text label 1"), "textlabel1", blue, "#86a4ff", "textlabel1" },

View File

@ -65,6 +65,8 @@ enum ColorCode {
Color_foreground, Color_foreground,
/// Background color of selected text /// Background color of selected text
Color_selection, Color_selection,
/// Foreground color of selected math
Color_selectionmath,
/// Foreground color of selected text /// Foreground color of selected text
Color_selectiontext, Color_selectiontext,
/// Text color in LaTeX mode /// Text color in LaTeX mode

View File

@ -45,6 +45,7 @@ QPalette::ColorRole role(ColorCode col)
case Color_selection: case Color_selection:
return QPalette::Highlight; return QPalette::Highlight;
break; break;
case Color_selectionmath:
case Color_selectiontext: case Color_selectiontext:
return QPalette::HighlightedText; return QPalette::HighlightedText;
break; break;

View File

@ -697,8 +697,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
} }
// Then the equations // Then the equations
ColorCode color = pi.selected && lyxrc.use_system_colors ColorCode color = pi.selected ? Color_selectionmath : standardColor();
? Color_selectiontext : standardColor();
bool const really_change_color = pi.base.font.color() == Color_none; bool const really_change_color = pi.base.font.color() == Color_none;
Changer dummy0 = really_change_color ? pi.base.font.changeColor(color) Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
: noChange(); : noChange();

View File

@ -356,8 +356,7 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) const
x += e.before + e.after; x += e.before + e.after;
break; break;
case BEGIN_SEL: case BEGIN_SEL:
if (lyxrc.use_system_colors) change_color = pi.base.font.changeColor(Color_selectionmath);
change_color = pi.base.font.changeColor(Color_selectiontext);
break; break;
case END_SEL: case END_SEL:
change_color = noChange(); change_color = noChange();