]> git.lyx.org Git - lyx.git/commitdiff
Set GUI name for local greyedouttext color (#12130)
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 11 Feb 2021 08:05:42 +0000 (09:05 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 11 Feb 2021 08:05:42 +0000 (09:05 +0100)
src/BufferParams.cpp
src/Color.cpp
src/ColorSet.h
src/frontends/qt/GuiDocument.cpp

index a4756ec24eaf7cadb7e610eb872c07910a1dea46..7004a9211f2e176ceed5c65ace6641b75eb204c5 100644 (file)
@@ -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;
index c3d3f493d80b9d3234ba061e450afb40111721b0..cf297e909b5a3629d39ca8de0d3beb2c8c5a72b4 100644 (file)
@@ -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<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)
 {
        ColorEntry ce = { c, "", "", "", "", lyxname.c_str() };
index b1a984427fbe8fe2671e3ee7096abf6f5cfc4b5c..c1de480f4f0b66dd8a2f0cba2572627a110b0e04 100644 (file)
@@ -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;
 
index 1cbff7554d61d2657a4d61e2abb181f1a23e3cce..413169d6434778a52a7c3eea3927c9e241e5e925 100644 (file)
@@ -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;