Set GUI name for local greyedouttext color (#12130)

This commit is contained in:
Juergen Spitzmueller 2021-02-11 09:05:42 +01:00
parent 456b2b0e8b
commit 9721a5cc6b
4 changed files with 41 additions and 1 deletions

View File

@ -1056,6 +1056,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");
lcolor.setGUIName("notefontcolor", N_("greyedout inset text"));
// set a local name for the painter // set a local name for the painter
lcolor.setColor("notefontcolor@" + filename.absFileName(), color); lcolor.setColor("notefontcolor@" + filename.absFileName(), color);
isnotefontcolor = true; isnotefontcolor = true;

View File

@ -462,7 +462,7 @@ bool ColorSet::setLaTeXName(string const & lyxname, string const & latexname)
{ {
string const lcname = ascii_lowercase(lyxname); string const lcname = ascii_lowercase(lyxname);
if (lyxcolors.find(lcname) == lyxcolors.end()) { if (lyxcolors.find(lcname) == lyxcolors.end()) {
LYXERR(Debug::GUI, "ColorSet::setColor: Unknown color \"" LYXERR(Debug::GUI, "ColorSet::setLaTeXName: Unknown color \""
<< lyxname << '"'); << lyxname << '"');
addColor(static_cast<ColorCode>(infotab.size()), lcname); addColor(static_cast<ColorCode>(infotab.size()), lcname);
} }
@ -487,6 +487,35 @@ bool ColorSet::setLaTeXName(string const & lyxname, string const & latexname)
} }
bool ColorSet::setGUIName(string const & lyxname, string const & guiname)
{
string const lcname = ascii_lowercase(lyxname);
if (lyxcolors.find(lcname) == lyxcolors.end()) {
LYXERR(Debug::GUI, "ColorSet::setGUIName: Unknown color \""
<< lyxname << '"');
return false;
}
ColorCode col = lyxcolors[lcname];
InfoTab::iterator it = infotab.find(col);
if (it == infotab.end()) {
LYXERR0("Color " << col << " not found in database.");
return false;
}
// "inherit" is returned for colors not in the database
// (and anyway should not be redefined)
if (col == Color_none || col == Color_inherit || col == Color_ignore) {
LYXERR0("Color " << getLyXName(col) << " may not be redefined.");
return false;
}
if (!guiname.empty())
it->second.guiname = guiname;
return true;
}
void ColorSet::addColor(ColorCode c, string const & lyxname) void ColorSet::addColor(ColorCode c, string const & lyxname)
{ {
ColorEntry ce = { c, "", "", "", "", lyxname.c_str() }; ColorEntry ce = { c, "", "", "", "", lyxname.c_str() };

View File

@ -69,6 +69,11 @@ public:
*/ */
bool setLaTeXName(std::string const & lyxname, std::string const & latexname); bool setLaTeXName(std::string const & lyxname, std::string const & latexname);
/** set the GUI name of a given LyX color to a guiname if not yet defined
* \returns true if successful.
*/
bool setGUIName(std::string const & lyxname, std::string const & guiname);
/// Get the GUI name of \c color. /// Get the GUI name of \c color.
docstring const getGUIName(ColorCode c) const; docstring const getGUIName(ColorCode c) const;

View File

@ -3524,6 +3524,11 @@ void GuiDocument::applyView()
bp_.isfontcolor = is_fontcolor; bp_.isfontcolor = is_fontcolor;
bp_.notefontcolor = set_notefontcolor; bp_.notefontcolor = set_notefontcolor;
bp_.isnotefontcolor = is_notefontcolor; bp_.isnotefontcolor = is_notefontcolor;
if (is_notefontcolor) {
// Set information used in statusbar (#12130)
lcolor.setColor("notefontcolor", lyx::X11hexname(set_notefontcolor));
lcolor.setGUIName("notefontcolor", N_("greyedout inset text"));
}
bp_.boxbgcolor = set_boxbgcolor; bp_.boxbgcolor = set_boxbgcolor;
bp_.isboxbgcolor = is_boxbgcolor; bp_.isboxbgcolor = is_boxbgcolor;