Abdelrazak Younes schreef:
On 13/08/2009 21:20, Vincent van Ravesteijn wrote:
Vincent van Ravesteijn schreef:
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
Never mind, it doesn't seem to work.
As I said in my last commit message, we need a LayoutModel class. The
LayoutBox combo can of course be reused but it's difficult to see
where you are going to make it appear without a toolbar. But with a
LayoutModel, you can reuse that for pretty much anything: tol-level
menu, context menu, dockwidget, or a stand-alone toolbar 'a la'
GuiCommandBuffer via a toolbar.
Abdel.
Now it works!..
Yes, it's a bit random I guess where it will be placed, but the
popup-box also appeared when the toolbar was not there before, so... it
seem to work. I had to repair a little thing that was creeped in during
the refactoring, but now it doesn't crash anymore.
I'm sorry, I've no knowledge about Model-classes.. :S
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,14 @@
case ToolbarItem::SEPARATOR:
addSeparator();
break;
- case ToolbarItem::LAYOUTS:
- layout_ = new LayoutBox(this, owner_);
- addWidget(layout_);
+ case ToolbarItem::LAYOUTS: {
+ LayoutBox * layout = owner_.getLayoutDialog();
+ if (layout) {
+ layout->setToolbar(this);
+ addWidget(layout);
+ }
break;
+ }
case ToolbarItem::MINIBUFFER:
command_buffer_ = new GuiCommandBuffer(&owner_);
addWidget(command_buffer_);
@@ -294,8 +298,9 @@
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: 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)
@@ -183,6 +183,8 @@
delete splitter_;
delete bg_widget_;
delete stack_widget_;
+ if (layout_)
+ delete layout_;
}
QMenu * toolBarPopup(GuiView * parent)
@@ -433,8 +435,11 @@
for (; it != d.toolbars_.end(); ++it)
delete it->second;
d.toolbars_.clear();
- d.layout_ = 0;
+ d.layout_ = new LayoutBox(0, *this);
+ d.stack_widget_->addWidget(d.layout_);
+ d.layout_->hide();
+
// extracts the toolbars from the backend
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
Toolbars::Infos::iterator end = guiApp->toolbars().end();
@@ -1068,9 +1073,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 31020)
+++ 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.