From: Juergen Spitzmueller Date: Thu, 11 Feb 2021 08:05:42 +0000 (+0100) Subject: Set GUI name for local greyedouttext color (#12130) X-Git-Tag: 2.4.0-alpha3~53 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9721a5cc6bce43543f6c9e7e4baa5a09f3a6d6d6;p=lyx.git Set GUI name for local greyedouttext color (#12130) --- diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index a4756ec24e..7004a9211f 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1056,6 +1056,7 @@ string BufferParams::readToken(Lexer & lex, string const & token, notefontcolor = lyx::rgbFromHexName(color); lcolor.setColor("notefontcolor", color); lcolor.setLaTeXName("notefontcolor", "note_fontcolor"); + lcolor.setGUIName("notefontcolor", N_("greyedout inset text")); // set a local name for the painter lcolor.setColor("notefontcolor@" + filename.absFileName(), color); isnotefontcolor = true; diff --git a/src/Color.cpp b/src/Color.cpp index c3d3f493d8..cf297e909b 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -462,7 +462,7 @@ bool ColorSet::setLaTeXName(string const & lyxname, string const & latexname) { string const lcname = ascii_lowercase(lyxname); if (lyxcolors.find(lcname) == lyxcolors.end()) { - LYXERR(Debug::GUI, "ColorSet::setColor: Unknown color \"" + LYXERR(Debug::GUI, "ColorSet::setLaTeXName: Unknown color \"" << lyxname << '"'); addColor(static_cast(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) { ColorEntry ce = { c, "", "", "", "", lyxname.c_str() }; diff --git a/src/ColorSet.h b/src/ColorSet.h index b1a984427f..c1de480f4f 100644 --- a/src/ColorSet.h +++ b/src/ColorSet.h @@ -69,6 +69,11 @@ public: */ 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. docstring const getGUIName(ColorCode c) const; diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index 1cbff7554d..413169d643 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -3524,6 +3524,11 @@ void GuiDocument::applyView() bp_.isfontcolor = is_fontcolor; bp_.notefontcolor = set_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_.isboxbgcolor = is_boxbgcolor;