From 024980cf437efc1c25f5d5724c6752ad68989ed0 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 20 Jan 2021 13:58:24 +0100 Subject: [PATCH] Do not rely on hardcoded color when determining notefontcolor --- src/Buffer.cpp | 1 + src/BufferParams.cpp | 4 +++- src/BufferParams.h | 2 ++ src/frontends/qt/GuiDocument.cpp | 5 +++++ src/insets/InsetNote.cpp | 3 +-- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 9b910ca59e..c59d73a062 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -946,6 +946,7 @@ int Buffer::readHeader(Lexer & lex) params().fontcolor = RGBColor(0, 0, 0); params().isfontcolor = false; params().notefontcolor = RGBColor(0xCC, 0xCC, 0xCC); + params().isnotefontcolor = false; params().boxbgcolor = RGBColor(0xFF, 0, 0); params().html_latex_start.clear(); params().html_latex_end.clear(); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 4ce387d1df..d044fabb8e 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -461,6 +461,7 @@ BufferParams::BufferParams() fontcolor = lyx::rgbFromHexName("#000000"); isfontcolor = false; // light gray is the default font color for greyed-out notes + isnotefontcolor = false; notefontcolor = lyx::rgbFromHexName("#cccccc"); boxbgcolor = lyx::rgbFromHexName("#ff0000"); compressed = lyxrc.save_compressed; @@ -1053,6 +1054,7 @@ string BufferParams::readToken(Lexer & lex, string const & token, notefontcolor = lyx::rgbFromHexName(color); lcolor.setColor("notefontcolor", color); lcolor.setLaTeXName("notefontcolor", "note_fontcolor"); + isnotefontcolor = true; } else if (token == "\\boxbgcolor") { lex.eatLine(); string color = lex.getString(); @@ -1378,7 +1380,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; if (isfontcolor) os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n'; - if (notefontcolor != lyx::rgbFromHexName("#cccccc")) + if (isnotefontcolor) os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n'; if (boxbgcolor != lyx::rgbFromHexName("#ff0000")) os << "\\boxbgcolor " << lyx::X11hexname(boxbgcolor) << '\n'; diff --git a/src/BufferParams.h b/src/BufferParams.h index 4980f212b7..9b12575b14 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -396,6 +396,8 @@ public: /// RGBColor notefontcolor; /// + bool isnotefontcolor; + /// RGBColor boxbgcolor; /// \param index should lie in the range 0 <= \c index <= 3. Bullet & temp_bullet(size_type index); diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index 538dcbf3b3..81d251c0a7 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -162,6 +162,7 @@ bool is_backgroundcolor; lyx::RGBColor set_fontcolor; bool is_fontcolor; lyx::RGBColor set_notefontcolor; +bool is_notefontcolor; lyx::RGBColor set_boxbgcolor; bool forced_fontspec_activation; @@ -2264,6 +2265,7 @@ void GuiDocument::changeNoteFontColor() colorButtonStyleSheet(newColor)); // save color set_notefontcolor = rgbFromHexName(fromqstr(newColor.name())); + is_notefontcolor = true; change_adaptor(); } @@ -2274,6 +2276,7 @@ void GuiDocument::deleteNoteFontColor() theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor); colorModule->noteFontColorPB->setStyleSheet( colorButtonStyleSheet(rgb2qcolor(set_notefontcolor))); + is_notefontcolor = false; change_adaptor(); } @@ -3516,6 +3519,7 @@ void GuiDocument::applyView() bp_.fontcolor = set_fontcolor; bp_.isfontcolor = is_fontcolor; bp_.notefontcolor = set_notefontcolor; + bp_.isnotefontcolor = is_notefontcolor; bp_.boxbgcolor = set_boxbgcolor; // numbering @@ -4034,6 +4038,7 @@ void GuiDocument::paramsToDialog() colorModule->noteFontColorPB->setStyleSheet( colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor))); set_notefontcolor = bp_.notefontcolor; + is_notefontcolor = bp_.isnotefontcolor; if (bp_.isbackgroundcolor) { colorModule->backgroundPB->setStyleSheet( diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 28d8db18e5..c9b0b8823a 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -327,9 +327,8 @@ bool InsetNote::allowSpellCheck() const FontInfo InsetNote::getFont() const { FontInfo font = getLayout().font(); - // FIXME: This hardcoded color is a hack! if (params_.type == InsetNoteParams::Greyedout - && buffer().params().notefontcolor != lyx::rgbFromHexName("#cccccc")) { + && buffer().params().isnotefontcolor) { ColorCode c = lcolor.getFromLyXName("notefontcolor"); if (c != Color_none) font.setColor(c);