From: Jean-Marc Lasgouttes Date: Mon, 6 May 2013 21:50:23 +0000 (+0200) Subject: Another try at making the source view dock arrange itself. X-Git-Tag: 2.1.0beta1~294 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=151960440e89f5afa3bb8cad07ed42f3088b4de3;p=lyx.git 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. --- diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 0875c82df3..edc1deaa1b 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -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))); } diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 1722ac94fc..5e19fe2520 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -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: ///