]> git.lyx.org Git - features.git/commitdiff
Move layout from GuiToolbar to GuiView. Now, it is possible to use the popup also...
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 14 Aug 2009 22:58:57 +0000 (22:58 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 14 Aug 2009 22:58:57 +0000 (22:58 +0000)
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

src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiToolbar.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/LayoutBox.cpp

index 3d5722c75e4f76a3648c1c242df529be2219a891..13dbd9ca80755880f0cfec31dbeb78de10d44765 100644 (file)
@@ -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();
index 3802e4adbc618bd63038cc9f066bb094ef0f663a..31146ee3999c7fff26c43d695a62e35bf0c5010e 100644 (file)
@@ -122,8 +122,6 @@ private:
        ///
        GuiView & owner_;
        ///
-       LayoutBox * layout_;
-       ///
        GuiCommandBuffer * command_buffer_;
        ///
        ToolbarInfo const & tbinfo_;
index d933786088851dbac143c897d0024242da352949..0f7adbda8a67509ccfd179b53f5142f9d380da2f 100644 (file)
@@ -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();
index 079a46fb7ff64f837c8d936d7f66c1608961b29b..fe57bd1e75b55628abfc0c96ec62a4081cb1760f 100644 (file)
@@ -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();
index 27e19c4dbb663f1c1599b155289b405a864ed7d1..d99787853a22a674024f24f88bfb96cb82be34fd 100644 (file)
@@ -414,7 +414,6 @@ LayoutBox::LayoutBox(GuiView & owner)
        QObject::connect(this, SIGNAL(activated(int)),
                this, SLOT(selected(int)));
 
-       d->owner_.setLayoutDialog(this);
        updateContents(true);
 }