mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 06:15:16 +00:00
Don't pretend we have multiple menu backends: transfer the singleton to GuiApplication.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22303 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4959040015
commit
518871a52b
@ -59,6 +59,7 @@
|
||||
#include "insets/InsetText.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
#include "frontends/Application.h"
|
||||
#include "frontends/Delegates.h"
|
||||
#include "frontends/FontMetrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
@ -494,7 +495,7 @@ docstring BufferView::toolTip(int x, int y) const
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1109,7 +1109,7 @@ bool LyX::readUIFile(string const & name, bool include)
|
||||
break;
|
||||
}
|
||||
case ui_menuset:
|
||||
menubackend.read(lex);
|
||||
theApp()->menuBackend().read(lex);
|
||||
break;
|
||||
|
||||
case ui_toolbarset:
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "TocBackend.h"
|
||||
#include "ToolbarBackend.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/convert.h"
|
||||
@ -70,10 +72,6 @@ private:
|
||||
} // namespace anon
|
||||
|
||||
|
||||
// This is the global menu definition
|
||||
MenuBackend menubackend;
|
||||
|
||||
|
||||
MenuItem::MenuItem(Kind kind)
|
||||
: kind_(kind), optional_(false)
|
||||
{}
|
||||
@ -416,7 +414,7 @@ bool Menu::searchFunc(FuncRequest & func, stack<docstring> & names)
|
||||
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
|
||||
|
@ -259,10 +259,6 @@ private:
|
||||
Menu specialmenu_;
|
||||
};
|
||||
|
||||
///
|
||||
extern MenuBackend menubackend;
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // MENUBACKEND_H
|
||||
|
@ -25,6 +25,7 @@ class Buffer;
|
||||
class FuncRequest;
|
||||
class FuncStatus;
|
||||
class Inset;
|
||||
class MenuBackend;
|
||||
struct RGBColor;
|
||||
|
||||
namespace frontend {
|
||||
@ -208,6 +209,10 @@ public:
|
||||
* @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
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "frontends/Application.h"
|
||||
|
||||
#include "MenuBackend.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
@ -62,6 +64,8 @@ public:
|
||||
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);
|
||||
@ -135,6 +139,8 @@ private:
|
||||
QTranslator qt_trans_;
|
||||
///
|
||||
std::map<int, SocketNotifier *> socket_notifiers_;
|
||||
///
|
||||
MenuBackend menu_backend_;
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
public:
|
||||
|
@ -10,13 +10,12 @@
|
||||
|
||||
#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"
|
||||
|
||||
@ -33,8 +32,8 @@ namespace frontend {
|
||||
|
||||
// MacOSX specific stuff is at the end.
|
||||
|
||||
GuiMenubar::GuiMenubar(GuiView * view, MenuBackend & mbe)
|
||||
: owner_(view), menubackend_(mbe)
|
||||
GuiMenubar::GuiMenubar(GuiView * view)
|
||||
: owner_(view)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@ -50,21 +49,23 @@ void GuiMenubar::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();
|
||||
@ -80,26 +81,20 @@ void GuiMenubar::init()
|
||||
<< " 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()));
|
||||
}
|
||||
|
||||
|
||||
@ -185,7 +180,8 @@ void GuiMenubar::macxMenuBarInit()
|
||||
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.
|
||||
@ -194,8 +190,8 @@ void GuiMenubar::macxMenuBarInit()
|
||||
// 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()),
|
||||
|
@ -19,9 +19,6 @@
|
||||
class QMenuBar;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class MenuBackend;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
class GuiView;
|
||||
@ -32,7 +29,7 @@ class GuiMenubar : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiMenubar(GuiView *, MenuBackend &);
|
||||
GuiMenubar(GuiView *);
|
||||
|
||||
~GuiMenubar();
|
||||
|
||||
@ -45,9 +42,6 @@ public:
|
||||
/// 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();
|
||||
|
||||
@ -58,9 +52,6 @@ private:
|
||||
/// owning view
|
||||
GuiView * owner_;
|
||||
|
||||
/// menu controller
|
||||
MenuBackend & menubackend_;
|
||||
|
||||
typedef QHash<QString, GuiPopupMenu *> NameMap;
|
||||
|
||||
/// name to menu for openByName
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "GuiView.h"
|
||||
|
||||
#include "Action.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "GuiPopupMenu.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
@ -52,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());
|
||||
|
||||
|
@ -282,7 +282,7 @@ GuiView::GuiView(int id)
|
||||
{
|
||||
// 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_);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "BufferView.h"
|
||||
#include "support/debug.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "support/gettext.h"
|
||||
#include "InsetSpecialChar.h"
|
||||
#include "KeyMap.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
@ -31,8 +30,11 @@
|
||||
#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"
|
||||
|
||||
@ -214,7 +216,7 @@ void InsetInfo::updateInfo(Buffer const & buf)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user