#include "GuiView.h"
#include "Action.h"
+#include "GuiApplication.h"
#include "GuiPopupMenu.h"
-#include "GuiMenubar.h"
#include "qt_helpers.h"
+
#include "LyXFunc.h"
#include "MenuBackend.h"
-#include "support/lstrings.h"
#include "support/debug.h"
-
+#include "support/lstrings.h"
namespace lyx {
namespace frontend {
-GuiPopupMenu::GuiPopupMenu(GuiMenubar * owner, MenuItem const & mi,
+GuiPopupMenu::GuiPopupMenu(GuiView * owner, MenuItem const & mi,
bool topLevelMenu)
- : owner_(owner)
+ : QMenu(owner), owner_(owner)
{
name_ = mi.submenuname();
return;
// Here, We make sure that theLyXFunc points to the correct LyXView.
- theLyXFunc().setLyXView(owner_->view());
+ theLyXFunc().setLyXView(owner_);
- Menu const & fromLyxMenu = owner_->backend().getMenu(name_);
- owner_->backend().expand(fromLyxMenu, topLevelMenu_, owner_->view()->buffer());
+ MenuBackend const & menubackend = guiApp->menuBackend();
+ Menu const & fromLyxMenu = menubackend.getMenu(name_);
+ menubackend.expand(fromLyxMenu, topLevelMenu_, owner_->buffer());
- if (!owner_->backend().hasMenu(topLevelMenu_.name())) {
+ if (!menubackend.hasMenu(topLevelMenu_.name())) {
LYXERR(Debug::GUI, "\tWARNING: menu seems empty"
<< to_utf8(topLevelMenu_.name()));
}
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_->view()),
+ Action * action = new Action(*(owner_),
QIcon(), toqstr(label), m->func(), QString());
qMenu->addAction(action);
}
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;
}