Another try at making the source view dock arrange itself.

The idea is to minimize the size of the form that contains the buttons.

Since I do not really know what I am doing, I will revert if problems occur.
This commit is contained in:
Jean-Marc Lasgouttes 2013-05-06 23:50:23 +02:00
parent 249d96ed94
commit 151960440e
2 changed files with 9 additions and 6 deletions

View File

@ -228,13 +228,16 @@ void ViewSourceWidget::updateDefaultFormat()
}
void ViewSourceWidget::dockLocationChanged(Qt::DockWidgetArea area)
void ViewSourceWidget::resizeEvent (QResizeEvent * event)
{
if (area == Qt::RightDockWidgetArea || area == Qt::LeftDockWidgetArea) {
QSize const & formSize = formLayout->sizeHint();
// minimize the size of the part that contains the buttons
if (width() * formSize.height() < height() * formSize.width()) {
layout_->setDirection(QBoxLayout::TopToBottom);
} else {
layout_->setDirection(QBoxLayout::LeftToRight);
}
QWidget::resizeEvent(event);
}
@ -244,8 +247,6 @@ GuiViewSource::GuiViewSource(GuiView & parent,
{
widget_ = new ViewSourceWidget;
setWidget(widget_);
connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
widget_, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
}

View File

@ -40,6 +40,10 @@ public:
///
void setBufferView(BufferView const * bv);
protected:
///
void resizeEvent (QResizeEvent * event);
public Q_SLOTS:
/// update content
void updateView();
@ -49,8 +53,6 @@ public Q_SLOTS:
void updateDefaultFormat();
///
void contentsChanged();
///
void dockLocationChanged(Qt::DockWidgetArea area);
private:
///