From: Pavel Sanda Date: Sun, 5 May 2013 06:05:51 +0000 (-0700) Subject: Add layout intelligence to View Source pane (bug #8653). X-Git-Tag: 2.1.0beta1~302 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=49c2450f3f6cb67a36f8fa987ad287a8bff11d79;p=features.git Add layout intelligence to View Source pane (bug #8653). View Source pane layout now automatically switches between horizontal and vertical design when docked in vertical or horizontal way. Original idea and patch from Edwin. http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg178801.html Note: the long standing-fight with too bulky minimal QTextEdit size is now solved via ViewSourceUi.sizePolicy=Ignored. --- diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 70d932466e..0875c82df3 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -227,12 +228,24 @@ void ViewSourceWidget::updateDefaultFormat() } +void ViewSourceWidget::dockLocationChanged(Qt::DockWidgetArea area) +{ + if (area == Qt::RightDockWidgetArea || area == Qt::LeftDockWidgetArea) { + layout_->setDirection(QBoxLayout::TopToBottom); + } else { + layout_->setDirection(QBoxLayout::LeftToRight); + } +} + + GuiViewSource::GuiViewSource(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags) : DockView(parent, "view-source", qt_("LaTeX Source"), area, flags) { 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 6d16142249..1722ac94fc 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -49,6 +49,8 @@ public Q_SLOTS: void updateDefaultFormat(); /// void contentsChanged(); + /// + void dockLocationChanged(Qt::DockWidgetArea area); private: /// diff --git a/src/frontends/qt4/ui/ViewSourceUi.ui b/src/frontends/qt4/ui/ViewSourceUi.ui index 3255234e2b..cc413e025f 100644 --- a/src/frontends/qt4/ui/ViewSourceUi.ui +++ b/src/frontends/qt4/ui/ViewSourceUi.ui @@ -6,12 +6,12 @@ 0 0 - 430 - 131 + 665 + 144 - + 0 0 @@ -19,10 +19,7 @@ - - - 9 - + 3 @@ -30,61 +27,96 @@ 3 - - - - 0 - 0 - - - - - - - - - + - QLayout::SetDefaultConstraint - - - QFormLayout::ExpandingFieldsGrow + QLayout::SetMaximumSize - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - -1 - - - 2 - - - - - 3 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + - QLayout::SetMinAndMaxSize + QLayout::SetDefaultConstraint - - 3 + + QFormLayout::ExpandingFieldsGrow - - - - F&ormat: + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + -1 + + + 4 + + + + + 3 - - outputFormatCO + + QLayout::SetMinAndMaxSize - - - - - - true + + 3 + + + + F&ormat: + + + outputFormatCO + + + + + + + true + + + + 0 + 0 + + + + Select the output format + + + QComboBox::AdjustToContents + + + + + + + 0 @@ -92,80 +124,64 @@ - Select the output format + Show the source as the master document gets it - - QComboBox::AdjustToContents + + &Master's perspective - - - - - - - 0 - 0 - - - - Show the source as the master document gets it - - - &Master's perspective - - - - - - - Automatic update - - - true - - - - - - - false - - - &Update - - - - - - - - 0 - 0 - - - - - Current Paragraph - - - - - Complete Source - + + + + Automatic update + + + true + + - - - Preamble Only - + + + + false + + + &Update + + - - - Body Only - + + + + + 0 + 0 + + + + + Current Paragraph + + + + + Complete Source + + + + + Preamble Only + + + + + Body Only + + + - +