From 77d4d1256daa6253a69cf222292ad8156cb57c72 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 23 Aug 2007 12:44:21 +0000 Subject: [PATCH] Put LyXView on a diet, step 2: get rid of menubar direct access from the core. Menubar handling is a frontend thing. * LyXView: - getMenubars(): deleted. - menubar_: transfered to GuiView::private. - updateMenubar(): deleted, QLMenubar::update() is a void method anyway (to be deleted soon). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19750 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 3 +-- src/frontends/LyXView.cpp | 10 +--------- src/frontends/LyXView.h | 11 +---------- src/frontends/WorkArea.cpp | 1 - src/frontends/qt4/GuiView.cpp | 15 +++++++++++---- src/frontends/qt4/GuiView.h | 1 + 6 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index c1ec1ae590..b9384260d1 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1298,7 +1298,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_MENU_OPEN: BOOST_ASSERT(lyx_view_); - lyx_view_->getMenubar().openByName(from_utf8(argument)); + lyx_view_->openMenu(from_utf8(argument)); break; // --- lyxserver commands ---------------------------- @@ -1927,7 +1927,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } } if (!quitting && lyx_view_) { - lyx_view_->updateMenubar(); lyx_view_->updateToolbars(); // Some messages may already be translated, so we cannot use _() sendDispatchMessage(translateIfPossible(getMessage()), cmd); diff --git a/src/frontends/LyXView.cpp b/src/frontends/LyXView.cpp index 895704aa8e..5247c3f77d 100644 --- a/src/frontends/LyXView.cpp +++ b/src/frontends/LyXView.cpp @@ -308,9 +308,7 @@ void LyXView::updateToolbars() } else toolbars_->update(false, false, false); - // update redaonly status of open dialogs. This could also be in - // updateMenubar(), but since updateToolbars() and updateMenubar() - // are always called together it is only here. + // update redaonly status of open dialogs. getDialogs().checkStatus(); } @@ -335,12 +333,6 @@ void LyXView::toggleToolbarState(string const & name, bool allowauto) } -void LyXView::updateMenubar() -{ - menubar_->update(); -} - - void LyXView::autoSave() { LYXERR(Debug::INFO) << "Running autoSave()" << endl; diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 912e3880be..19ff3d4751 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -41,7 +41,6 @@ namespace frontend { class ControlCommandBuffer; class Dialogs; -class Menubar; class WorkArea; /** @@ -130,11 +129,7 @@ public: bool isToolbarVisible(std::string const & id); /// virtual void showMiniBuffer(bool visible) = 0; - - /// return the menubar for this view - Menubar & getMenubar() { return *menubar_.get(); } - /// - Menubar const & getMenubar() const { return *menubar_.get(); } + virtual void openMenu(docstring const & name) = 0; /// get access to the dialogs Dialogs & getDialogs() { return *dialogs_.get(); } @@ -159,8 +154,6 @@ public: ToolbarInfo * getToolbarInfo(std::string const & name); /// toggle toolbar state void toggleToolbarState(std::string const & name, bool allowauto); - /// update the menubar - void updateMenubar(); /// update the status bar virtual void updateStatusBar() = 0; @@ -200,8 +193,6 @@ protected: /// disconnect from signals in the given buffer void disconnectBuffer(); - /// view's menubar - boost::scoped_ptr menubar_; /// view's toolbar boost::scoped_ptr toolbars_; diff --git a/src/frontends/WorkArea.cpp b/src/frontends/WorkArea.cpp index d27816a676..3da4e4cfe6 100644 --- a/src/frontends/WorkArea.cpp +++ b/src/frontends/WorkArea.cpp @@ -219,7 +219,6 @@ void WorkArea::dispatch(FuncRequest const & cmd0, key_modifier::state k) // Skip these when selecting if (cmd.action != LFUN_MOUSE_MOTION) { lyx_view_->updateLayoutChoice(); - lyx_view_->updateMenubar(); lyx_view_->updateToolbars(); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ab3307068d..36af40fa7c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -140,6 +140,8 @@ struct GuiView::GuiViewPrivate TabWidget * tab_widget_; QStackedWidget * stack_widget_; BackgroundWidget * bg_widget_; + /// view's menubar + QLMenubar * menubar_; GuiViewPrivate() : posx_offset(0), posy_offset(0) {} @@ -278,7 +280,7 @@ GuiView::GuiView(int id) GuiView::~GuiView() { - menubar_.reset(); + delete d.menubar_; delete &d; } @@ -306,7 +308,7 @@ QMenu* GuiView::createPopupMenu() void GuiView::init() { - menubar_.reset(new QLMenubar(this, menubackend)); + d.menubar_ = new QLMenubar(this, menubackend); QObject::connect(menuBar(), SIGNAL(triggered(QAction *)), this, SLOT(updateMenu(QAction *))); @@ -561,7 +563,7 @@ void GuiView::setGeometry(unsigned int width, void GuiView::updateMenu(QAction * /*action*/) { - menubar_->update(); + d.menubar_->update(); } @@ -658,7 +660,6 @@ void GuiView::currentTabChanged(int i) // hidden. This should go here because some dialogs (eg ToC) // require bv_->text. getDialogs().updateBufferDependent(true); - updateMenubar(); updateToolbars(); updateLayoutChoice(); updateWindowTitle(); @@ -947,6 +948,12 @@ void GuiView::showMiniBuffer(bool visible) commandbuffer_->focus_command(); } + +void GuiView::openMenu(docstring const & name) +{ + d.menubar_->openByName(name); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 0c67e34073..5eb2e32f68 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -72,6 +72,7 @@ public: virtual void clearMessage(); virtual bool hasFocus() const; void showMiniBuffer(bool); + void openMenu(docstring const &); /// show - display the top-level window void show(); -- 2.39.5