Do not rely on hardcoded color when determining notefontcolor

This commit is contained in:
Juergen Spitzmueller 2021-01-20 13:58:24 +01:00
parent 3375dccef6
commit 024980cf43
5 changed files with 12 additions and 3 deletions

View File

@ -946,6 +946,7 @@ int Buffer::readHeader(Lexer & lex)
params().fontcolor = RGBColor(0, 0, 0); params().fontcolor = RGBColor(0, 0, 0);
params().isfontcolor = false; params().isfontcolor = false;
params().notefontcolor = RGBColor(0xCC, 0xCC, 0xCC); params().notefontcolor = RGBColor(0xCC, 0xCC, 0xCC);
params().isnotefontcolor = false;
params().boxbgcolor = RGBColor(0xFF, 0, 0); params().boxbgcolor = RGBColor(0xFF, 0, 0);
params().html_latex_start.clear(); params().html_latex_start.clear();
params().html_latex_end.clear(); params().html_latex_end.clear();

View File

@ -461,6 +461,7 @@ BufferParams::BufferParams()
fontcolor = lyx::rgbFromHexName("#000000"); fontcolor = lyx::rgbFromHexName("#000000");
isfontcolor = false; isfontcolor = false;
// light gray is the default font color for greyed-out notes // light gray is the default font color for greyed-out notes
isnotefontcolor = false;
notefontcolor = lyx::rgbFromHexName("#cccccc"); notefontcolor = lyx::rgbFromHexName("#cccccc");
boxbgcolor = lyx::rgbFromHexName("#ff0000"); boxbgcolor = lyx::rgbFromHexName("#ff0000");
compressed = lyxrc.save_compressed; compressed = lyxrc.save_compressed;
@ -1053,6 +1054,7 @@ string BufferParams::readToken(Lexer & lex, string const & token,
notefontcolor = lyx::rgbFromHexName(color); notefontcolor = lyx::rgbFromHexName(color);
lcolor.setColor("notefontcolor", color); lcolor.setColor("notefontcolor", color);
lcolor.setLaTeXName("notefontcolor", "note_fontcolor"); lcolor.setLaTeXName("notefontcolor", "note_fontcolor");
isnotefontcolor = true;
} else if (token == "\\boxbgcolor") { } else if (token == "\\boxbgcolor") {
lex.eatLine(); lex.eatLine();
string color = lex.getString(); string color = lex.getString();
@ -1378,7 +1380,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
if (isfontcolor) if (isfontcolor)
os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n'; os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
if (notefontcolor != lyx::rgbFromHexName("#cccccc")) if (isnotefontcolor)
os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n'; os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
if (boxbgcolor != lyx::rgbFromHexName("#ff0000")) if (boxbgcolor != lyx::rgbFromHexName("#ff0000"))
os << "\\boxbgcolor " << lyx::X11hexname(boxbgcolor) << '\n'; os << "\\boxbgcolor " << lyx::X11hexname(boxbgcolor) << '\n';

View File

@ -396,6 +396,8 @@ public:
/// ///
RGBColor notefontcolor; RGBColor notefontcolor;
/// ///
bool isnotefontcolor;
///
RGBColor boxbgcolor; RGBColor boxbgcolor;
/// \param index should lie in the range 0 <= \c index <= 3. /// \param index should lie in the range 0 <= \c index <= 3.
Bullet & temp_bullet(size_type index); Bullet & temp_bullet(size_type index);

View File

@ -162,6 +162,7 @@ bool is_backgroundcolor;
lyx::RGBColor set_fontcolor; lyx::RGBColor set_fontcolor;
bool is_fontcolor; bool is_fontcolor;
lyx::RGBColor set_notefontcolor; lyx::RGBColor set_notefontcolor;
bool is_notefontcolor;
lyx::RGBColor set_boxbgcolor; lyx::RGBColor set_boxbgcolor;
bool forced_fontspec_activation; bool forced_fontspec_activation;
@ -2264,6 +2265,7 @@ void GuiDocument::changeNoteFontColor()
colorButtonStyleSheet(newColor)); colorButtonStyleSheet(newColor));
// save color // save color
set_notefontcolor = rgbFromHexName(fromqstr(newColor.name())); set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
is_notefontcolor = true;
change_adaptor(); change_adaptor();
} }
@ -2274,6 +2276,7 @@ void GuiDocument::deleteNoteFontColor()
theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor); theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
colorModule->noteFontColorPB->setStyleSheet( colorModule->noteFontColorPB->setStyleSheet(
colorButtonStyleSheet(rgb2qcolor(set_notefontcolor))); colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
is_notefontcolor = false;
change_adaptor(); change_adaptor();
} }
@ -3516,6 +3519,7 @@ void GuiDocument::applyView()
bp_.fontcolor = set_fontcolor; bp_.fontcolor = set_fontcolor;
bp_.isfontcolor = is_fontcolor; bp_.isfontcolor = is_fontcolor;
bp_.notefontcolor = set_notefontcolor; bp_.notefontcolor = set_notefontcolor;
bp_.isnotefontcolor = is_notefontcolor;
bp_.boxbgcolor = set_boxbgcolor; bp_.boxbgcolor = set_boxbgcolor;
// numbering // numbering
@ -4034,6 +4038,7 @@ void GuiDocument::paramsToDialog()
colorModule->noteFontColorPB->setStyleSheet( colorModule->noteFontColorPB->setStyleSheet(
colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor))); colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
set_notefontcolor = bp_.notefontcolor; set_notefontcolor = bp_.notefontcolor;
is_notefontcolor = bp_.isnotefontcolor;
if (bp_.isbackgroundcolor) { if (bp_.isbackgroundcolor) {
colorModule->backgroundPB->setStyleSheet( colorModule->backgroundPB->setStyleSheet(

View File

@ -327,9 +327,8 @@ bool InsetNote::allowSpellCheck() const
FontInfo InsetNote::getFont() const FontInfo InsetNote::getFont() const
{ {
FontInfo font = getLayout().font(); FontInfo font = getLayout().font();
// FIXME: This hardcoded color is a hack!
if (params_.type == InsetNoteParams::Greyedout if (params_.type == InsetNoteParams::Greyedout
&& buffer().params().notefontcolor != lyx::rgbFromHexName("#cccccc")) { && buffer().params().isnotefontcolor) {
ColorCode c = lcolor.getFromLyXName("notefontcolor"); ColorCode c = lcolor.getFromLyXName("notefontcolor");
if (c != Color_none) if (c != Color_none)
font.setColor(c); font.setColor(c);