// no theApp() with command line export
if (theApp())
theApp()->getRgbColor(Color_background, color_);
+ else
+ frontend::Application::getRgbColorUncached(Color_background, color_);
}
{
if (str.size() == 7 && str[0] == '#')
color_ = rgbFromHexName(str);
- else
+ else {
// no color set or invalid color - use normal background
- theApp()->getRgbColor(Color_background, color_);
+ // no theApp() with command line export
+ if (theApp())
+ theApp()->getRgbColor(Color_background, color_);
+ else
+ frontend::Application::getRgbColorUncached(Color_background, color_);
+ }
}
// no theApp() with command line export
if (theApp())
theApp()->getRgbColor(Color_indexlabel, color_);
+ else
+ frontend::Application::getRgbColorUncached(Color_indexlabel, color_);
}
{
if (str.size() == 7 && str[0] == '#')
color_ = rgbFromHexName(str);
- else
+ else {
// no color set or invalid color -- use predefined color
- theApp()->getRgbColor(Color_indexlabel, color_);
+ // no theApp() with command line export
+ if (theApp())
+ theApp()->getRgbColor(Color_indexlabel, color_);
+ else
+ frontend::Application::getRgbColorUncached(Color_indexlabel, color_);
+ }
}
* It returns false on failure and sets r, g, b to 0.
*/
virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol) = 0;
+ /// Like getRgbColor(), but static and slower
+ static bool getRgbColorUncached(ColorCode col, RGBColor & rgbcol);
/** Eg, passing Color_black returns "000000",
* passing Color_white returns "ffffff".
docstring_list & names) const = 0;
/// \return the icon file name for the given action.
- virtual docstring iconName(FuncRequest const & f, bool unknown) = 0;
+ static docstring iconName(FuncRequest const & f, bool unknown);
/// Handle a accented char key sequence
/// FIXME: this is only needed for LFUN_ACCENT_* in Text::dispatch()
}
-docstring GuiApplication::iconName(FuncRequest const & f, bool unknown)
+docstring Application::iconName(FuncRequest const & f, bool unknown)
{
return qstring_to_ucs4(lyx::frontend::iconName(f, unknown));
}
}
+bool Application::getRgbColorUncached(ColorCode col, RGBColor & rgbcol)
+{
+ QColor const qcol(lcolor.getX11Name(col).c_str());
+ if (!qcol.isValid()) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ rgbcol.r = qcol.red();
+ rgbcol.g = qcol.green();
+ rgbcol.b = qcol.blue();
+ return true;
+}
+
+
string const GuiApplication::hexName(ColorCode col)
{
return ltrim(fromqstr(d->color_cache_.get(col).name()), "#");
void registerSocketCallback(int fd, SocketCallback func);
void unregisterSocketCallback(int fd);
bool searchMenu(FuncRequest const & func, docstring_list & names) const;
- docstring iconName(FuncRequest const & f, bool unknown);
void handleKeyFunc(FuncCode action);
//@}
break;
}
// iterate through the menubackend to find it
+ if (!theApp()) {
+ error("Can't determine menu entry for action %1$s in batch mode");
+ break;
+ }
if (!theApp()->searchMenu(func, names)) {
error("No menu entry for action %1$s");
break;
}
case ICON_INFO: {
FuncRequest func = lyxaction.lookupFunc(name_);
- docstring icon_name = theApp()->iconName(func, true);
+ docstring icon_name = frontend::Application::iconName(func, true);
//FIXME: We should use the icon directly instead of
// going through FileName. The code below won't work
// if the icon is embedded in the executable through
// the Qt resource system.
+ // This is only a negligible performance problem:
+ // If the installed icon differs from the resource icon the
+ // installed one is preferred anyway, and all icons that are
+ // embedded in the resources are installed as well.
FileName file(to_utf8(icon_name));
if (!file.exists())
break;