From 674632104f92cac0a13670f2ddc00a37bc135d75 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 23 Aug 2007 12:21:47 +0000 Subject: [PATCH] Put LyXView on a diet, step 1: get rid of toolbars direct access from the core. Toolbar handling is a frontend thing; the goal is to progressively transfer that to the frontend. * LyXView: - getToolbars(): deleted. - toolbars_: now protected. The goal is to transfer that to GuiView. - openLayoutList(): new method. The core should not know how this list is displayed. - showMiniBuffer(): new pure virtual method to show the mini-buffer. - focus_command_buffer: deleted. * GuiView: - focus_command_widget(): deleted. - showMiniBuffer(): implemented. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19748 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 7 +++---- src/frontends/LyXView.cpp | 12 +++++++++++ src/frontends/LyXView.h | 15 +++++++------ .../controllers/ControlCommandBuffer.cpp | 2 +- src/frontends/qt4/GuiView.cpp | 21 ++++++++++--------- src/frontends/qt4/GuiView.h | 4 +--- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 92e83f05cf..c1ec1ae590 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -666,7 +666,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const break; case LFUN_TOOLBAR_TOGGLE: { - bool const current = lyx_view_->getToolbars().visible(cmd.getArg(0)); + bool const current = lyx_view_->isToolbarVisible(cmd.getArg(0)); flag.setOnOff(current); break; } @@ -888,8 +888,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_COMMAND_EXECUTE: BOOST_ASSERT(lyx_view_); - lyx_view_->getToolbars().display("minibuffer", true); - lyx_view_->focus_command_buffer(); + lyx_view_->showMiniBuffer(true); break; case LFUN_CANCEL: @@ -1294,7 +1293,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) case LFUN_DROP_LAYOUTS_CHOICE: BOOST_ASSERT(lyx_view_); - lyx_view_->getToolbars().openLayoutList(); + lyx_view_->openLayoutList(); break; case LFUN_MENU_OPEN: diff --git a/src/frontends/LyXView.cpp b/src/frontends/LyXView.cpp index af322ba092..895704aa8e 100644 --- a/src/frontends/LyXView.cpp +++ b/src/frontends/LyXView.cpp @@ -431,5 +431,17 @@ Buffer const * const LyXView::updateInset(Inset const * inset) return &work_area->bufferView().buffer(); } + +void LyXView::openLayoutList() +{ + toolbars_->openLayoutList(); +} + + +bool LyXView::isToolbarVisible(std::string const & id) +{ + return toolbars_->visible(id); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 7bf5ae9245..912e3880be 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -124,10 +124,12 @@ public: Buffer * buffer(); Buffer const * buffer() const; - /// return the toolbar for this view - Toolbars & getToolbars() { return *toolbars_.get(); } /// - Toolbars const & getToolbars() const { return *toolbars_.get(); } + void openLayoutList(); + /// + bool isToolbarVisible(std::string const & id); + /// + virtual void showMiniBuffer(bool visible) = 0; /// return the menubar for this view Menubar & getMenubar() { return *menubar_.get(); } @@ -162,9 +164,6 @@ public: /// update the status bar virtual void updateStatusBar() = 0; - /// focus the command buffer (minibuffer) - boost::signal focus_command_buffer; - /// display a message in the view virtual void message(docstring const &) = 0; @@ -203,6 +202,8 @@ protected: /// view's menubar boost::scoped_ptr menubar_; + /// view's toolbar + boost::scoped_ptr toolbars_; private: /** @@ -215,8 +216,6 @@ private: /// called on timeout void autoSave(); - /// view's toolbar - boost::scoped_ptr toolbars_; /// auto-saving of buffers boost::scoped_ptr const autosave_timeout_; /// our function handler diff --git a/src/frontends/controllers/ControlCommandBuffer.cpp b/src/frontends/controllers/ControlCommandBuffer.cpp index 959bfb7326..6ed5a51a78 100644 --- a/src/frontends/controllers/ControlCommandBuffer.cpp +++ b/src/frontends/controllers/ControlCommandBuffer.cpp @@ -87,7 +87,7 @@ docstring const ControlCommandBuffer::getCurrentState() const void ControlCommandBuffer::hide() const { - lv_.getToolbars().display("minibuffer", false); + lv_.showMiniBuffer(false); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index cb9114f1c7..ab3307068d 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -310,7 +310,7 @@ void GuiView::init() QObject::connect(menuBar(), SIGNAL(triggered(QAction *)), this, SLOT(updateMenu(QAction *))); - getToolbars().init(); + toolbars_->init(); statusBar()->setSizeGripEnabled(true); @@ -445,7 +445,7 @@ void GuiView::saveGeometry() session.sessionInfo().save("WindowPosX", convert(normal_geometry.x() + d.posx_offset)); session.sessionInfo().save("WindowPosY", convert(normal_geometry.y() + d.posy_offset)); } - getToolbars().saveToolbarInfo(); + toolbars_->saveToolbarInfo(); } @@ -579,7 +579,6 @@ void GuiView::setWindowTitle(docstring const & t, docstring const & it) void GuiView::addCommandBuffer(QToolBar * toolbar) { commandbuffer_ = new QCommandBuffer(this, *controlcommand_); - focus_command_buffer.connect(boost::bind(&GuiView::focus_command_widget, this)); toolbar->addWidget(commandbuffer_); } @@ -623,13 +622,6 @@ void GuiView::bigSizedIcons() } -void GuiView::focus_command_widget() -{ - if (commandbuffer_) - commandbuffer_->focus_command(); -} - - void GuiView::update_view_state_qt() { if (!hasFocus()) @@ -946,6 +938,15 @@ void GuiView::removeWorkArea(WorkArea * work_area) } +void GuiView::showMiniBuffer(bool visible) +{ + if (!commandbuffer_) + return; + + toolbars_->display("minibuffer", visible); + commandbuffer_->focus_command(); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index dd5a425de0..0c67e34073 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -71,6 +71,7 @@ public: virtual void message(docstring const & str); virtual void clearMessage(); virtual bool hasFocus() const; + void showMiniBuffer(bool); /// show - display the top-level window void show(); @@ -130,9 +131,6 @@ private: /// void dropEvent(QDropEvent * ev); - /// focus the command buffer widget - void focus_command_widget(); - /** * setWindowTitle - set title of window * @param t main window title -- 2.39.2