From 50ca5af7e0ec460f9f004a3660efa10bb1dd8cb1 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 19 Nov 2020 21:22:27 +0000 Subject: Allow having the UrlNavigators below the tab bar This commit restores the possibility to have the UrlNavigators below the tab bar. This will happen automatically whenever the UrlNavigator is removed from the toolbar. It is also now again possible to have the toolbar on the side. This option is disabled while the toolbar contains the UrlNavigators. This commit makes no changes to the new default which is having the UrlNavigators in the toolbar but makes sure that upgrading users won't be affected. --- src/dolphintabpage.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/dolphintabpage.cpp') diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index 7f945dce2..138822cfd 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -10,7 +10,8 @@ #include "dolphinviewcontainer.h" #include -#include +#include +#include DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) : QWidget(parent), @@ -18,7 +19,7 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, m_splitViewEnabled(false), m_active(true) { - QVBoxLayout* layout = new QVBoxLayout(this); + QGridLayout *layout = new QGridLayout(this); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); @@ -26,7 +27,8 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, m_splitter->setChildrenCollapsible(false); connect(m_splitter, &QSplitter::splitterMoved, this, &DolphinTabPage::splitterMoved); - layout->addWidget(m_splitter); + layout->addWidget(m_splitter, 1, 0); + layout->setRowStretch(1, 1); // Create a new primary view m_primaryViewContainer = createViewContainer(primaryUrl); @@ -157,6 +159,7 @@ int DolphinTabPage::selectedItemsCount() const void DolphinTabPage::connectNavigators(DolphinNavigatorsWidgetAction *navigatorsWidget) { + insertNavigatorsWidget(navigatorsWidget); m_navigatorsWidget = navigatorsWidget; auto primaryNavigator = navigatorsWidget->primaryUrlNavigator(); m_primaryViewContainer->connectUrlNavigator(primaryNavigator); @@ -185,6 +188,20 @@ bool DolphinTabPage::eventFilter(QObject *watched, QEvent *event) return QWidget::eventFilter(watched, event); } +void DolphinTabPage::insertNavigatorsWidget(DolphinNavigatorsWidgetAction* navigatorsWidget) +{ + QGridLayout *gridLayout = static_cast(layout()); + if (navigatorsWidget->isInToolbar()) { + gridLayout->setRowMinimumHeight(0, 0); + } else { + // We set a row minimum height, so the height does not visibly change whenever + // navigatorsWidget is inserted which happens every time the current tab is changed. + gridLayout->setRowMinimumHeight(0, navigatorsWidget->primaryUrlNavigator()->height()); + gridLayout->addWidget(navigatorsWidget->requestWidget(this), 0, 0); + } +} + + void DolphinTabPage::resizeNavigators() const { if (!m_splitViewEnabled) { -- cgit v1.3