]> git.lyx.org Git - features.git/commitdiff
Compute the highlighting color from AlternateBase and Highlight roles (#10073)
authorGuillaume Munch <gm@lyx.org>
Thu, 14 Apr 2016 15:24:18 +0000 (16:24 +0100)
committerGuillaume Munch <gm@lyx.org>
Fri, 15 Apr 2016 13:13:50 +0000 (14:13 +0100)
src/frontends/qt4/GuiViewSource.cpp

index 192a163faf203dfe9b341fa3a67463ec21732749..d5838976a9fd013b9e0b71e80ac4740866d66f93 100644 (file)
@@ -277,15 +277,18 @@ void ViewSourceWidget::realUpdateView()
 
                //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();
-               //Alternative:
-               //  QColor bg = palette.color(QPalette::Active,QPalette::Highlight);
-               //  bg.setAlpha(64);
-               //  format.setBackground(QBrush(bg));
-               //Other alternatives:
-               //format.setBackground(palette.light());
-               //format.setBackground(palette.alternateBase());
-               format.setBackground(palette.toolTipBase());
+               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);
+               }
                format.setProperty(QTextFormat::FullWidthSelection, true);
                QTextEdit::ExtraSelection sel;
                sel.format = format;