#include "insets/InsetText.h"
#include "frontends/alert.h"
+#include "frontends/Application.h"
#include "frontends/Delegates.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
Menu const & BufferView::contextMenu(int x, int y) const
{
// FIXME: Do something more elaborate here.
- return menubackend.getMenu(from_ascii("edit"));
+ return theApp()->menuBackend().getMenu(from_ascii("edit"));
}
break;
}
case ui_menuset:
- menubackend.read(lex);
+ theApp()->menuBackend().read(lex);
break;
case ui_toolbarset:
#include "TocBackend.h"
#include "ToolbarBackend.h"
+#include "frontends/Application.h"
+
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/convert.h"
} // namespace anon
-// This is the global menu definition
-MenuBackend menubackend;
-
-
MenuItem::MenuItem(Kind kind)
: kind_(kind), optional_(false)
{}
return true;
} else if (m->kind() == MenuItem::Submenu) {
names.push(m->label());
- Menu submenu = menubackend.getMenu(m->submenuname());
+ Menu submenu = theApp()->menuBackend().getMenu(m->submenuname());
if (submenu.searchFunc(func, names))
return true;
else
Menu specialmenu_;
};
-///
-extern MenuBackend menubackend;
-
-
} // namespace lyx
#endif // MENUBACKEND_H
class FuncRequest;
class FuncStatus;
class Inset;
+class MenuBackend;
struct RGBColor;
namespace frontend {
* @param fd socket descriptor (file/socket/etc)
*/
virtual void unregisterSocketCallback(int fd) = 0;
+
+ ///
+ virtual MenuBackend const & menuBackend() const = 0;
+ virtual MenuBackend & menuBackend() = 0;
};
} // namespace frontend
#include "frontends/Application.h"
+#include "MenuBackend.h"
+
#include <QObject>
#include <QApplication>
#include <QTranslator>
virtual Clipboard & clipboard();
virtual Selection & selection();
virtual FontLoader & fontLoader() { return font_loader_; }
+ MenuBackend const & menuBackend() const { return menu_backend_; }
+ MenuBackend & menuBackend() { return menu_backend_; }
virtual int exec();
virtual void exit(int status);
virtual bool event(QEvent * e);
QTranslator qt_trans_;
///
std::map<int, SocketNotifier *> socket_notifiers_;
+ ///
+ MenuBackend menu_backend_;
#ifdef Q_WS_X11
public:
#include <config.h>
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-// All is well if the namespace is visible first.
-#include "GuiView.h"
+#include "GuiMenubar.h"
#include "Action.h"
-#include "GuiMenubar.h"
+#include "GuiApplication.h"
#include "GuiPopupMenu.h"
+#include "GuiView.h"
#include "qt_helpers.h"
// MacOSX specific stuff is at the end.
-GuiMenubar::GuiMenubar(GuiView * view, MenuBackend & mbe)
- : owner_(view), menubackend_(mbe)
+GuiMenubar::GuiMenubar(GuiView * view)
+ : owner_(view)
{
init();
}
macxMenuBarInit();
#endif
- LYXERR(Debug::GUI, "populating menu bar" << to_utf8(menubackend_.getMenubar().name()));
+ /// menu controller
+ MenuBackend & menu_backend = guiApp->menuBackend();
+ LYXERR(Debug::GUI, "populating menu bar" << to_utf8(menu_backend.getMenubar().name()));
- if (menubackend_.getMenubar().size() == 0) {
+ if (menu_backend.getMenubar().size() == 0) {
LYXERR(Debug::GUI, "\tERROR: empty menu bar"
- << to_utf8(menubackend_.getMenubar().name()));
+ << to_utf8(menu_backend.getMenubar().name()));
return;
// continue;
}
else {
LYXERR(Debug::GUI, "menu bar entries "
- << menubackend_.getMenubar().size());
+ << menu_backend.getMenubar().size());
}
Menu menu;
- menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
+ menu_backend.expand(menu_backend.getMenubar(), menu, owner_->buffer());
Menu::const_iterator m = menu.begin();
Menu::const_iterator end = menu.end();
<< " is a submenu named " << to_utf8(m->submenuname()));
docstring name = m->submenuname();
- if (!menubackend_.hasMenu(name)) {
+ if (!menu_backend.hasMenu(name)) {
LYXERR(Debug::GUI, "\tERROR: " << to_utf8(name)
<< " submenu has no menu!");
continue;
}
Menu menu;
- menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
+ menu_backend.expand(menu_backend.getMenubar(), menu, owner_->buffer());
GuiPopupMenu * qMenu = new GuiPopupMenu(owner_, *m, true);
owner_->menuBar()->addMenu(qMenu);
name_map_[toqstr(name)] = qMenu;
-/*
- QObject::connect(qMenu, SIGNAL(aboutToShow()), this, SLOT(update()));
- QObject::connect(qMenu, SIGNAL(triggered(QAction *)), this, SLOT(update()));
- QObject::connect(qMenu->menuAction(), SIGNAL(triggered()), this, SLOT(update()));
-*/
}
- //QObject::connect(owner_->menuBar(), SIGNAL(triggered()), this, SLOT(update()));
}
from_utf8(entries[i].label),
func));
}
- menubackend_.specialMenu(special);
+ MenuBackend & menu_backend = guiApp->menuBackend();
+ menu_backend.specialMenu(special);
// add the entries to a QMenu that will eventually be empty
// and therefore invisible.
// we do not use 'special' because it is a temporary variable,
// whereas MenuBackend::specialMenu points to a persistent
// copy.
- Menu::const_iterator cit = menubackend_.specialMenu().begin();
- Menu::const_iterator end = menubackend_.specialMenu().end();
+ Menu::const_iterator cit = menu_backend.specialMenu().begin();
+ Menu::const_iterator end = menu_backend.specialMenu().end();
for (size_t i = 0 ; cit != end ; ++cit, ++i) {
Action * action = new Action(*owner_, QIcon(),
toqstr(cit->label()),
class QMenuBar;
namespace lyx {
-
-class MenuBackend;
-
namespace frontend {
class GuiView;
{
Q_OBJECT
public:
- GuiMenubar(GuiView *, MenuBackend &);
+ GuiMenubar(GuiView *);
~GuiMenubar();
/// return the owning view
GuiView * view() { return owner_; }
- /// return the menu controller
- MenuBackend const & backend() { return menubackend_; }
-
/// update the state of the menuitems - not needed
void updateView();
/// owning view
GuiView * owner_;
- /// menu controller
- MenuBackend & menubackend_;
-
typedef QHash<QString, GuiPopupMenu *> NameMap;
/// name to menu for openByName
#include "GuiView.h"
#include "Action.h"
+#include "GuiApplication.h"
#include "GuiPopupMenu.h"
#include "qt_helpers.h"
// 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());
{
// GuiToolbars *must* be initialised before GuiMenubar.
d.toolbars_ = new GuiToolbars(*this);
- d.menubar_ = new GuiMenubar(this, menubackend);
+ d.menubar_ = new GuiMenubar(this);
setCentralWidget(d.stack_widget_);
#include "BufferView.h"
#include "support/debug.h"
#include "FuncRequest.h"
-#include "support/gettext.h"
#include "InsetSpecialChar.h"
#include "KeyMap.h"
#include "LaTeXFeatures.h"
#include "ParagraphParameters.h"
#include "TextClassList.h"
+#include "frontends/Application.h"
+
#include "support/docstream.h"
#include "support/FileName.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/ExceptionMessage.h"
break;
}
// iterate through the menubackend to find it
- Menu menu = menubackend.getMenubar();
+ Menu menu = theApp()->menuBackend().getMenubar();
if (!menu.searchFunc(func, names)) {
setText(_("No menu entry for "), bp.getFont(), false);
break;