From: Georg Baum Date: Sat, 14 Feb 2015 19:32:25 +0000 (+0100) Subject: Fix missing symbols in math completer X-Git-Tag: 2.2.0alpha1~1303 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7adc6125f7515741410b5bfe9fada2a3d3eb5af0;p=features.git Fix missing symbols in math completer The math icons for the symbol image in the math completer were hardcoded to the command names. This is wrong for some icons for various reasons, e.g. the case insensitivity of windows file systems. Therefore we have to use the replacement list which is also used for the toolbar icons. Bug #3538 is not closed because of this problem, but IMHO it has nothing to do with this bug, it is a more general one. --- diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 0fe4d9101d..ca5ea4493a 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -235,6 +235,8 @@ public: /// \return the icon file name for the given action. static docstring iconName(FuncRequest const & f, bool unknown); + /// \return the math icon name for the given command. + static docstring mathIcon(docstring const & c); /// Handle a accented char key sequence /// FIXME: this is only needed for LFUN_ACCENT_* in Text::dispatch() diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index d58c9c94bb..6812a2df58 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1079,6 +1079,12 @@ docstring Application::iconName(FuncRequest const & f, bool unknown) } +docstring Application::mathIcon(docstring const & c) +{ + return qstring_to_ucs4(findPng(toqstr(c))); +} + + FuncStatus GuiApplication::getStatus(FuncRequest const & cmd) const { FuncStatus status; diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index 87c5aa9007..7c3c2ff2c8 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -137,6 +137,8 @@ public: // get icon from cache QPixmap scaled; QString const name = ":" + toqstr(list_->icon(index.row())); + if (name == ":") + return scaled; if (!QPixmapCache::find("completion" + name, scaled)) { // load icon from disk QPixmap p = QPixmap(name); diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 179d7775f3..dbc0c7692b 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -54,6 +54,7 @@ #include "OutputParams.h" #include "Text.h" +#include "frontends/Application.h" #include "frontends/Clipboard.h" #include "frontends/Painter.h" #include "frontends/Selection.h" @@ -2240,7 +2241,10 @@ std::string MathCompletionList::icon(size_t idx) const cmd = locals[idx]; // get the icon resource name by stripping the backslash - return "images/math/" + to_utf8(cmd.substr(1)) + ".png"; + docstring icon_name = frontend::Application::mathIcon(cmd.substr(1)); + if (icon_name.empty()) + return std::string(); + return "images/math/" + to_utf8(icon_name); } std::vector MathCompletionList::globals;