Free GuiPopupMenu from GuiMenubar.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22301 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-25 20:51:05 +00:00
parent 02110a3d5b
commit 3ffd3f51a1
3 changed files with 12 additions and 13 deletions

View File

@ -87,7 +87,7 @@ void GuiMenubar::init()
Menu menu; Menu menu;
menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer()); menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
GuiPopupMenu * qMenu = new GuiPopupMenu(this, *m, true); GuiPopupMenu * qMenu = new GuiPopupMenu(owner_, *m, true);
owner_->menuBar()->addMenu(qMenu); owner_->menuBar()->addMenu(qMenu);
name_map_[toqstr(name)] = qMenu; name_map_[toqstr(name)] = qMenu;

View File

@ -15,7 +15,6 @@
#include "Action.h" #include "Action.h"
#include "GuiPopupMenu.h" #include "GuiPopupMenu.h"
#include "GuiMenubar.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "LyXFunc.h" #include "LyXFunc.h"
#include "MenuBackend.h" #include "MenuBackend.h"
@ -28,9 +27,9 @@
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
GuiPopupMenu::GuiPopupMenu(GuiMenubar * owner, MenuItem const & mi, GuiPopupMenu::GuiPopupMenu(GuiView * owner, MenuItem const & mi,
bool topLevelMenu) bool topLevelMenu)
: QMenu(owner->menuBar()), owner_(owner) : QMenu(owner), owner_(owner)
{ {
name_ = mi.submenuname(); name_ = mi.submenuname();
@ -52,12 +51,12 @@ void GuiPopupMenu::updateView()
return; return;
// Here, We make sure that theLyXFunc points to the correct LyXView. // 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_); Menu const & fromLyxMenu = menubackend.getMenu(name_);
owner_->backend().expand(fromLyxMenu, topLevelMenu_, owner_->view()->buffer()); menubackend.expand(fromLyxMenu, topLevelMenu_, owner_->buffer());
if (!owner_->backend().hasMenu(topLevelMenu_.name())) { if (!menubackend.hasMenu(topLevelMenu_.name())) {
LYXERR(Debug::GUI, "\tWARNING: menu seems empty" LYXERR(Debug::GUI, "\tWARNING: menu seems empty"
<< to_utf8(topLevelMenu_.name())); << to_utf8(topLevelMenu_.name()));
} }
@ -99,7 +98,7 @@ void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu)
docstring label = getLabel(*m); docstring label = getLabel(*m);
addBinding(label, *m); addBinding(label, *m);
Action * action = new Action(*(owner_->view()), Action * action = new Action(*(owner_),
QIcon(), toqstr(label), m->func(), QString()); QIcon(), toqstr(label), m->func(), QString());
qMenu->addAction(action); qMenu->addAction(action);
} }

View File

@ -20,7 +20,7 @@
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class GuiMenubar; class GuiView;
/// a submenu /// a submenu
class GuiPopupMenu : public QMenu class GuiPopupMenu : public QMenu
@ -28,7 +28,7 @@ class GuiPopupMenu : public QMenu
Q_OBJECT Q_OBJECT
public: public:
/// ///
GuiPopupMenu(GuiMenubar * owner, MenuItem const & mi, GuiPopupMenu(GuiView * owner, MenuItem const & mi,
bool topLevelMenu = false); bool topLevelMenu = false);
/// populates the menu or one of its submenu /// populates the menu or one of its submenu
@ -45,8 +45,8 @@ private:
/// add binding keys a the menu item label. /// add binding keys a the menu item label.
void addBinding(docstring & label, MenuItem const & mi); void addBinding(docstring & label, MenuItem const & mi);
/// our owning menubar /// our owning view
GuiMenubar * owner_; GuiView * owner_;
/// the name of this menu /// the name of this menu
docstring name_; docstring name_;
/// Top Level Menu /// Top Level Menu