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
This commit is contained in:
Abdelrazak Younes 2007-08-23 12:21:47 +00:00
parent a2022b1950
commit 674632104f
6 changed files with 35 additions and 26 deletions

View File

@ -666,7 +666,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
break; break;
case LFUN_TOOLBAR_TOGGLE: { 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); flag.setOnOff(current);
break; break;
} }
@ -888,8 +888,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_COMMAND_EXECUTE: case LFUN_COMMAND_EXECUTE:
BOOST_ASSERT(lyx_view_); BOOST_ASSERT(lyx_view_);
lyx_view_->getToolbars().display("minibuffer", true); lyx_view_->showMiniBuffer(true);
lyx_view_->focus_command_buffer();
break; break;
case LFUN_CANCEL: case LFUN_CANCEL:
@ -1294,7 +1293,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_DROP_LAYOUTS_CHOICE: case LFUN_DROP_LAYOUTS_CHOICE:
BOOST_ASSERT(lyx_view_); BOOST_ASSERT(lyx_view_);
lyx_view_->getToolbars().openLayoutList(); lyx_view_->openLayoutList();
break; break;
case LFUN_MENU_OPEN: case LFUN_MENU_OPEN:

View File

@ -431,5 +431,17 @@ Buffer const * const LyXView::updateInset(Inset const * inset)
return &work_area->bufferView().buffer(); return &work_area->bufferView().buffer();
} }
void LyXView::openLayoutList()
{
toolbars_->openLayoutList();
}
bool LyXView::isToolbarVisible(std::string const & id)
{
return toolbars_->visible(id);
}
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -124,10 +124,12 @@ public:
Buffer * buffer(); Buffer * buffer();
Buffer const * buffer() const; 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 /// return the menubar for this view
Menubar & getMenubar() { return *menubar_.get(); } Menubar & getMenubar() { return *menubar_.get(); }
@ -162,9 +164,6 @@ public:
/// update the status bar /// update the status bar
virtual void updateStatusBar() = 0; virtual void updateStatusBar() = 0;
/// focus the command buffer (minibuffer)
boost::signal<void()> focus_command_buffer;
/// display a message in the view /// display a message in the view
virtual void message(docstring const &) = 0; virtual void message(docstring const &) = 0;
@ -203,6 +202,8 @@ protected:
/// view's menubar /// view's menubar
boost::scoped_ptr<Menubar> menubar_; boost::scoped_ptr<Menubar> menubar_;
/// view's toolbar
boost::scoped_ptr<Toolbars> toolbars_;
private: private:
/** /**
@ -215,8 +216,6 @@ private:
/// called on timeout /// called on timeout
void autoSave(); void autoSave();
/// view's toolbar
boost::scoped_ptr<Toolbars> toolbars_;
/// auto-saving of buffers /// auto-saving of buffers
boost::scoped_ptr<Timeout> const autosave_timeout_; boost::scoped_ptr<Timeout> const autosave_timeout_;
/// our function handler /// our function handler

View File

@ -87,7 +87,7 @@ docstring const ControlCommandBuffer::getCurrentState() const
void ControlCommandBuffer::hide() const void ControlCommandBuffer::hide() const
{ {
lv_.getToolbars().display("minibuffer", false); lv_.showMiniBuffer(false);
} }

View File

@ -310,7 +310,7 @@ void GuiView::init()
QObject::connect(menuBar(), SIGNAL(triggered(QAction *)), QObject::connect(menuBar(), SIGNAL(triggered(QAction *)),
this, SLOT(updateMenu(QAction *))); this, SLOT(updateMenu(QAction *)));
getToolbars().init(); toolbars_->init();
statusBar()->setSizeGripEnabled(true); statusBar()->setSizeGripEnabled(true);
@ -445,7 +445,7 @@ void GuiView::saveGeometry()
session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset)); session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset)); session.sessionInfo().save("WindowPosY", convert<string>(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) void GuiView::addCommandBuffer(QToolBar * toolbar)
{ {
commandbuffer_ = new QCommandBuffer(this, *controlcommand_); commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
focus_command_buffer.connect(boost::bind(&GuiView::focus_command_widget, this));
toolbar->addWidget(commandbuffer_); 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() void GuiView::update_view_state_qt()
{ {
if (!hasFocus()) 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 frontend
} // namespace lyx } // namespace lyx

View File

@ -71,6 +71,7 @@ public:
virtual void message(docstring const & str); virtual void message(docstring const & str);
virtual void clearMessage(); virtual void clearMessage();
virtual bool hasFocus() const; virtual bool hasFocus() const;
void showMiniBuffer(bool);
/// show - display the top-level window /// show - display the top-level window
void show(); void show();
@ -130,9 +131,6 @@ private:
/// ///
void dropEvent(QDropEvent * ev); void dropEvent(QDropEvent * ev);
/// focus the command buffer widget
void focus_command_widget();
/** /**
* setWindowTitle - set title of window * setWindowTitle - set title of window
* @param t main window title * @param t main window title