]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/Toolbar_pimpl.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / Toolbar_pimpl.C
index 80c5de749d01b0c93400485645fbb7f7823c3cb9..330b49cbf3d944416f77852331197b54def55bba 100644 (file)
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
-#include "QtView.h"
-
-#include "Toolbar_pimpl.h"
+#include "ControlMath.h"
 
 #include <boost/tuple/tuple.hpp>
 
+#include "QtView.h"
+#include "Toolbar_pimpl.h"
+
 #include <qtoolbar.h>
 #include <qcombobox.h>
 #include <qtooltip.h>
@@ -47,31 +48,32 @@ QPixmap getIconPixmap(int action)
 {
        FuncRequest f = lyxaction.retrieveActionArg(action);
 
-       string xpm_name;
+       string fullname;
 
        if (f.action == LFUN_INSERT_MATH && !f.argument.empty()) {
-               xpm_name = "math/" + subst(f.argument.substr(1), ' ', '_');
+               fullname = find_xpm(f.argument.substr(1));
        } else {
                string const name = lyxaction.getActionName(f.action);
+               string xpm_name(name);
+
                if (!f.argument.empty())
                        xpm_name = subst(name + ' ' + f.argument, ' ','_');
-               else
-                       xpm_name = name;
+
+               fullname = LibFileSearch("images", xpm_name, "xpm");
        }
 
-       string fullname = LibFileSearch("images", xpm_name, "xpm");
 
        if (!fullname.empty()) {
                lyxerr[Debug::GUI] << "Full icon name is `"
-                                      << fullname << "'" << endl;
+                                  << fullname << '\'' << endl;
                return QPixmap(fullname.c_str());
        }
 
-       lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
+       lyxerr << "Unable to find icon `" << fullname << '\'' << endl;
        fullname = LibFileSearch("images", "unknown", "xpm");
        if (!fullname.empty()) {
                lyxerr[Debug::GUI] << "Using default `unknown' icon"
-                                      << endl;
+                                  << endl;
        }
        return QPixmap(fullname.c_str());
 }
@@ -161,9 +163,8 @@ void Toolbar::Pimpl::setLayout(string const & layout)
 
        string const & name = _(tc[layout]->name());
 
-       int i;
-
-       for (i = 0; i < combo_->count(); ++i) {
+       int i = 0;
+       for (; i < combo_->count(); ++i) {
                if (name == combo_->text(i).latin1())
                        break;
        }