]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPopupMenu.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiPopupMenu.cpp
index 6a37dc896f7c2a7226f2a646f4431fe3d0eee6d6..b4ff3ae51775454d4a59cce282135cf5fa8331db 100644 (file)
 #include "GuiView.h"
 
 #include "Action.h"
+#include "GuiApplication.h"
 #include "GuiPopupMenu.h"
 #include "qt_helpers.h"
+
 #include "LyXFunc.h"
 #include "MenuBackend.h"
 
-#include "support/lstrings.h"
 #include "support/debug.h"
-
-#include <QMenuBar>
+#include "support/lstrings.h"
 
 namespace lyx {
 namespace frontend {
@@ -53,6 +53,7 @@ void GuiPopupMenu::updateView()
        // Here, We make sure that theLyXFunc points to the correct LyXView.
        theLyXFunc().setLyXView(owner_);
 
+       MenuBackend const & menubackend = guiApp->menuBackend();
        Menu const & fromLyxMenu = menubackend.getMenu(name_);
        menubackend.expand(fromLyxMenu, topLevelMenu_, owner_->buffer());
 
@@ -95,8 +96,7 @@ void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu)
                        LYXERR(Debug::GUI, "creating Menu Item "
                                << to_utf8(m->label()));
 
-                       docstring label = getLabel(*m);
-                       addBinding(label, *m);
+                       docstring const label = getLabel(*m);
 
                        Action * action = new Action(*(owner_),
                                QIcon(), toqstr(label), m->func(), QString());
@@ -108,29 +108,21 @@ void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu)
 
 docstring const GuiPopupMenu::getLabel(MenuItem const & mi)
 {
-       docstring const shortcut = mi.shortcut();
-       docstring label = support::subst(mi.label(),
-       from_ascii("&"), from_ascii("&&"));
+       docstring label = support::subst(mi.label(), 
+                                        from_ascii("&"), from_ascii("&&"));
 
+       docstring const shortcut = mi.shortcut();
        if (!shortcut.empty()) {
                size_t pos = label.find(shortcut);
                if (pos != docstring::npos)
                        label.insert(pos, 1, char_type('&'));
        }
 
-       return label;
-}
-
-
-void GuiPopupMenu::addBinding(docstring & label, MenuItem const & mi)
-{
-#ifdef Q_WS_MACX
-       docstring const binding = mi.binding(false);
-#else
-       docstring const binding = mi.binding(true);
-#endif
+       docstring const binding = mi.binding();
        if (!binding.empty())
                label += '\t' + binding;
+
+       return label;
 }