]> git.lyx.org Git - features.git/commitdiff
Another try at making the source view dock arrange itself.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 6 May 2013 21:50:23 +0000 (23:50 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 7 May 2013 09:30:46 +0000 (11:30 +0200)
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.

src/frontends/qt4/GuiViewSource.cpp
src/frontends/qt4/GuiViewSource.h

index 0875c82df33430c4df6cb98d21d3935f2dbba215..edc1deaa1bb71395b08f9d7fe9d19b9706f404a1 100644 (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)));
 }
 
 
index 1722ac94fcea5bcf3b8346872a221221b0ea4095..5e19fe252063d5b5fbbc166f1b713c36383f2dc1 100644 (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:
        ///