This patch moves the LayoutBox * member from GuiToolbar to GuiView.

As a result, the LayoutDialog will also be shown when the user requests it. Previously it was only shown if the toolbar was visible, or has been visible before.

Objections ?

Vincent
Index: src/frontends/qt4/GuiToolbar.cpp
===================================================================
--- src/frontends/qt4/GuiToolbar.cpp    (revision 31014)
+++ src/frontends/qt4/GuiToolbar.cpp    (working copy)
@@ -53,7 +53,7 @@
 
 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,10 +226,12 @@
        case ToolbarItem::SEPARATOR:
                addSeparator();
                break;
-       case ToolbarItem::LAYOUTS:
-               layout_ = new LayoutBox(this, owner_);
-               addWidget(layout_);
+       case ToolbarItem::LAYOUTS: {
+               LayoutBox * layout = owner_.getLayoutDialog();
+               layout->setToolbar(this);
+               addWidget(layout);
                break;
+       }
        case ToolbarItem::MINIBUFFER:
                command_buffer_ = new GuiCommandBuffer(&owner_);
                addWidget(command_buffer_);
@@ -294,8 +296,8 @@
        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();
+       layout->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
 
        // emit signal
        updated();
Index: src/frontends/qt4/GuiToolbar.h
===================================================================
--- src/frontends/qt4/GuiToolbar.h      (revision 31014)
+++ src/frontends/qt4/GuiToolbar.h      (working copy)
@@ -122,8 +122,6 @@
        ///
        GuiView & owner_;
        ///
-       LayoutBox * layout_;
-       ///
        GuiCommandBuffer * command_buffer_;
        ///
        ToolbarInfo const & tbinfo_;
Index: src/frontends/qt4/GuiView.cpp
===================================================================
--- src/frontends/qt4/GuiView.cpp       (revision 31014)
+++ src/frontends/qt4/GuiView.cpp       (working copy)
@@ -330,6 +330,8 @@
 
        statusBar()->setSizeGripEnabled(true);
 
+       d.layout_ = new LayoutBox(0, *this);
+
        // Forbid too small unresizable window because it can happen
        // with some window manager under X11.
        setMinimumSize(300, 200);
@@ -1068,9 +1070,9 @@
 }
 
 
-void GuiView::setLayoutDialog(LayoutBox * layout)
+LayoutBox * GuiView::getLayoutDialog() const
 {
-       d.layout_ = layout;
+       return d.layout_;
 }
 
 
Index: src/frontends/qt4/GuiView.h
===================================================================
--- src/frontends/qt4/GuiView.h (revision 31014)
+++ src/frontends/qt4/GuiView.h (working copy)
@@ -82,7 +82,7 @@
        bool dispatch(FuncRequest const & cmd);
 
        ///
-       void setLayoutDialog(LayoutBox *);
+       LayoutBox * getLayoutDialog() const;
 
        /// \return the buffer currently shown in this window
        Buffer * buffer();
Index: src/frontends/qt4/LayoutBox.cpp
===================================================================
--- src/frontends/qt4/LayoutBox.cpp     (revision 31014)
+++ src/frontends/qt4/LayoutBox.cpp     (working copy)
@@ -414,10 +414,9 @@
        
        QObject::connect(this, SIGNAL(activated(int)),
                this, SLOT(selected(int)));
-       QObject::connect(bar, SIGNAL(iconSizeChanged(QSize)),
-               this, SLOT(setIconSize(QSize)));
+       
+       setToolbar(bar);
 
-       d->owner_.setLayoutDialog(this);
        updateContents(true);
 }
 
@@ -442,6 +441,16 @@
 }
 
 
+void LayoutBox::setToolbar(QToolBar * bar)
+{
+       if (!bar)
+               return;
+
+       QObject::connect(bar, SIGNAL(iconSizeChanged(QSize)),
+               this, SLOT(setIconSize(QSize)));
+}
+
+
 void LayoutBox::showPopup()
 {
        d->owner_.message(_("Enter characters to filter the layout list."));
Index: src/frontends/qt4/LayoutBox.h
===================================================================
--- src/frontends/qt4/LayoutBox.h       (revision 31014)
+++ src/frontends/qt4/LayoutBox.h       (working copy)
@@ -38,6 +38,9 @@
 public:
        LayoutBox(QToolBar *, GuiView &);
 
+       /// set the toolbar that hosts this box
+       void setToolbar(QToolBar * bar);
+
        /// select the right layout in the combobox.
        void set(docstring const & layout);
        /// Populate the layout combobox.

Reply via email to