[LyX/master] Set GUI name for local greyedouttext color (#12130)

Juergen Spitzmueller spitz at lyx.org
Thu Feb 11 08:03:18 UTC 2021


commit 9721a5cc6bce43543f6c9e7e4baa5a09f3a6d6d6
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Thu Feb 11 09:05:42 2021 +0100

    Set GUI name for local greyedouttext color (#12130)
---
 src/BufferParams.cpp             |    1 +
 src/Color.cpp                    |   31 ++++++++++++++++++++++++++++++-
 src/ColorSet.h                   |    5 +++++
 src/frontends/qt/GuiDocument.cpp |    5 +++++
 4 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index a4756ec..7004a92 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 c3d3f49..cf297e9 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<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() };
diff --git a/src/ColorSet.h b/src/ColorSet.h
index b1a9844..c1de480 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 1cbff75..413169d 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;
 


More information about the lyx-cvs mailing list