From: Vincent van Ravesteijn Date: Fri, 14 Aug 2009 22:58:57 +0000 (+0000) Subject: Move layout from GuiToolbar to GuiView. Now, it is possible to use the popup also... X-Git-Tag: 2.0.0~5729 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=81554c90f109c29458095f1cc1be6a5acc427987;p=features.git Move layout from GuiToolbar to GuiView. Now, it is possible to use the popup also when the Toolbar has not been visible before. see: http://www.mail-archive.com/lyx-users@lists.lyx.org/msg75503.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31042 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 3d5722c75e..13dbd9ca80 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -53,7 +53,7 @@ namespace frontend { GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner) : QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0), - allowauto_(false), owner_(owner), layout_(0), command_buffer_(0), + allowauto_(false), owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false) { setIconSize(owner.iconSize()); @@ -226,12 +226,14 @@ void GuiToolbar::add(ToolbarItem const & item) case ToolbarItem::SEPARATOR: addSeparator(); break; - case ToolbarItem::LAYOUTS: - layout_ = new LayoutBox(this, owner_); + case ToolbarItem::LAYOUTS: { + LayoutBox * layout = owner_.getLayoutDialog(); QObject::connect(this, SIGNAL(iconSizeChanged(QSize)), - layout_, SLOT(setIconSize(QSize))); - addWidget(layout_); + layout, SLOT(setIconSize(QSize))); + QAction * action = addWidget(layout); + action->setVisible(true); break; + } case ToolbarItem::MINIBUFFER: command_buffer_ = new GuiCommandBuffer(&owner_); addWidget(command_buffer_); @@ -296,8 +298,9 @@ void GuiToolbar::update(bool in_math, bool in_table, bool in_review, for (int i = 0; i < actions_.size(); ++i) actions_[i]->update(); - if (layout_) - layout_->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled()); + LayoutBox * layout = owner_.getLayoutDialog(); + if (layout) + layout->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled()); // emit signal updated(); diff --git a/src/frontends/qt4/GuiToolbar.h b/src/frontends/qt4/GuiToolbar.h index 3802e4adbc..31146ee399 100644 --- a/src/frontends/qt4/GuiToolbar.h +++ b/src/frontends/qt4/GuiToolbar.h @@ -122,8 +122,6 @@ private: /// GuiView & owner_; /// - LayoutBox * layout_; - /// GuiCommandBuffer * command_buffer_; /// ToolbarInfo const & tbinfo_; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index d933786088..0f7adbda8a 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -296,6 +296,8 @@ GuiView::GuiView(int id) // GuiToolbars *must* be initialised before the menu bar. normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge constructToolbars(); + d.layout_ = new LayoutBox(*this); + d.stack_widget_->addWidget(d.layout_); // set ourself as the current view. This is needed for the menu bar // filling, at least for the static special menu item on Mac. Otherwise @@ -433,7 +435,6 @@ void GuiView::constructToolbars() for (; it != d.toolbars_.end(); ++it) delete it->second; d.toolbars_.clear(); - d.layout_ = 0; // extracts the toolbars from the backend Toolbars::Infos::iterator cit = guiApp->toolbars().begin(); @@ -1068,9 +1069,9 @@ void GuiView::removeWorkArea(GuiWorkArea * wa) } -void GuiView::setLayoutDialog(LayoutBox * layout) +LayoutBox * GuiView::getLayoutDialog() const { - d.layout_ = layout; + return d.layout_; } @@ -2070,8 +2071,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) break; } case LFUN_DROP_LAYOUTS_CHOICE: - if (d.layout_) - d.layout_->showPopup(); + d.layout_->showPopup(); break; case LFUN_MENU_OPEN: @@ -2480,8 +2480,7 @@ void GuiView::resetDialogs() menuBar()->clear(); constructToolbars(); guiApp->menus().fillMenuBar(menuBar(), this, false); - if (d.layout_) - d.layout_->updateContents(true); + d.layout_->updateContents(true); // Now update controls with current buffer. theLyXFunc().setLyXView(this); restoreLayout(); diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 079a46fb7f..fe57bd1e75 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -82,7 +82,7 @@ public: bool dispatch(FuncRequest const & cmd); /// - void setLayoutDialog(LayoutBox *); + LayoutBox * getLayoutDialog() const; /// \return the buffer currently shown in this window Buffer * buffer(); diff --git a/src/frontends/qt4/LayoutBox.cpp b/src/frontends/qt4/LayoutBox.cpp index 27e19c4dbb..d99787853a 100644 --- a/src/frontends/qt4/LayoutBox.cpp +++ b/src/frontends/qt4/LayoutBox.cpp @@ -414,7 +414,6 @@ LayoutBox::LayoutBox(GuiView & owner) QObject::connect(this, SIGNAL(activated(int)), this, SLOT(selected(int))); - d->owner_.setLayoutDialog(this); updateContents(true); }