commit 1bc7e73c74b35e2175b3e3cb0686b16451b9922c
Author: Juergen Spitzmueller <[email protected]>
Date:   Sun Jan 31 17:54:54 2021 +0100

    Fix highlighting of cursor context in View Source (#12099)
    
    This also considers dark mode,
---
 src/frontends/qt/GuiViewSource.cpp |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/frontends/qt/GuiViewSource.cpp 
b/src/frontends/qt/GuiViewSource.cpp
index d26a55c..f1938c5 100644
--- a/src/frontends/qt/GuiViewSource.cpp
+++ b/src/frontends/qt/GuiViewSource.cpp
@@ -272,16 +272,20 @@ void ViewSourceWidget::updateView(BufferView const * bv)
                //the real highlighting is done with an ExtraSelection
                QTextCharFormat format;
                {
-               // We create a new color with the lightness of AlternateBase and
-               // the hue and saturation of Highlight
-               QPalette palette = viewSourceTV->palette();
-               QBrush alt = palette.alternateBase();
-               QColor high = palette.highlight().color().toHsl();
-               QColor col = QColor::fromHsl(high.hue(),
-                                            high.hslSaturation(),
-                                            alt.color().lightness());
-               alt.setColor(col);
-               format.setBackground(alt);
+               // We create a new color with the slightly altered lightness
+               // of the Base and the hue and saturation of the Highlight brush
+               QPalette const palette = viewSourceTV->palette();
+               QBrush extraselbrush = palette.base();
+               int const extrasellightness =
+                               (palette.text().color().black() > 
palette.window().color().black()) ?
+                                       
extraselbrush.color().darker(107).lightness()// light mode
+                                     : 
extraselbrush.color().darker().lightness();// dark mode
+               QColor const highlight = palette.highlight().color().toHsl();
+               QColor const extraselcol = QColor::fromHsl(highlight.hue(),
+                                                          
highlight.hslSaturation(),
+                                                          extrasellightness);
+               extraselbrush.setColor(extraselcol);
+               format.setBackground(extraselbrush);
                }
                format.setProperty(QTextFormat::FullWidthSelection, true);
                QTextEdit::ExtraSelection sel;
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to