]> git.lyx.org Git - features.git/commitdiff
Fix missing symbols in math completer
authorGeorg Baum <baum@lyx.org>
Sat, 14 Feb 2015 19:32:25 +0000 (20:32 +0100)
committerGeorg Baum <baum@lyx.org>
Sat, 14 Feb 2015 19:32:25 +0000 (20:32 +0100)
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.

src/frontends/Application.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiCompleter.cpp
src/mathed/InsetMathNest.cpp

index 0fe4d9101d8c5d24ca621ad17633f85474b00ed9..ca5ea4493ad774dce66e94d4bb6a2b20c46649c9 100644 (file)
@@ -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()
index d58c9c94bbcf0bec13603752c7a2a190e76d51a5..6812a2df58917bd305cf0b3ac15ce05b5fff1f08 100644 (file)
@@ -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;
index 87c5aa9007790871d43e44128ec337e4b305a4c5..7c3c2ff2c81ad83612ff32b21d6870a960df5854 100644 (file)
@@ -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);
index 179d7775f32015e04c08f234a806957d10fb669b..dbc0c7692b68c76c3e158ea15a3c5ea1132cb187 100644 (file)
@@ -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<docstring> MathCompletionList::globals;