From 37327c9b0aae112c5890703cba1f0157043007e0 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Sun, 20 Sep 2020 18:53:59 +0200 Subject: Make UrlNavigators in the toolbar the only option The UrlNavigators will be automatically added to the toolbar. The Sort By action is removed from the default toolbar to make space. Remove all options to have UrlNavigators outside the toolbar and remove those code paths. Make it so the new NavigatorsWidgetAction contains two UrlNavigators when in split view mode. Spacing was also added to align these UrlNavigators with the ViewContainers when enough space is available. Force the toolbar to be either at the top or bottom of the window. Set a sane sizeHint for DolphinUrlNavigator. It would be better to do this in KUrlNavigator in the future. This commit also contains a changes which should be moved to a separate merge requests before this gets merged: - Add an expansion animation when split view is enabled by the user --- src/dolphintabwidget.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'src/dolphintabwidget.cpp') diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index 3ce8229f9..a09a769d3 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -20,9 +20,10 @@ #include #include -DolphinTabWidget::DolphinTabWidget(QWidget* parent) : +DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget* parent) : QTabWidget(parent), - m_lastViewedTab(0) + m_lastViewedTab(nullptr), + m_navigatorsWidget{navigatorsWidget} { KAcceleratorManager::setNoAccel(this); @@ -126,11 +127,19 @@ bool DolphinTabWidget::isUrlOpen(const QUrl &url) const void DolphinTabWidget::openNewActivatedTab() { + std::unique_ptr oldNavigatorState; + if (currentTabPage()->primaryViewActive()) { + oldNavigatorState = m_navigatorsWidget->primaryUrlNavigator()->visualState(); + } else { + if (!m_navigatorsWidget->secondaryUrlNavigator()) { + m_navigatorsWidget->createSecondaryUrlNavigator(); + } + oldNavigatorState = m_navigatorsWidget->secondaryUrlNavigator()->visualState(); + } + const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer(); Q_ASSERT(oldActiveViewContainer); - const bool isUrlEditable = oldActiveViewContainer->urlNavigator()->isUrlEditable(); - openNewActivatedTab(oldActiveViewContainer->url()); DolphinViewContainer* newActiveViewContainer = currentTabPage()->activeViewContainer(); @@ -138,7 +147,7 @@ void DolphinTabWidget::openNewActivatedTab() // The URL navigator of the new tab should have the same editable state // as the current tab - newActiveViewContainer->urlNavigator()->setUrlEditable(isUrlEditable); + newActiveViewContainer->urlNavigator()->setVisualState(*oldNavigatorState.get()); // Always focus the new tab's view newActiveViewContainer->view()->setFocus(); @@ -384,16 +393,21 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url) void DolphinTabWidget::currentTabChanged(int index) { - // last-viewed tab deactivation - if (DolphinTabPage* tabPage = tabPageAt(m_lastViewedTab)) { - tabPage->setActive(false); + DolphinTabPage *tabPage = tabPageAt(index); + if (tabPage == m_lastViewedTab) { + return; + } + if (m_lastViewedTab) { + m_lastViewedTab->disconnectNavigators(); + m_lastViewedTab->setActive(false); } - DolphinTabPage* tabPage = tabPageAt(index); DolphinViewContainer* viewContainer = tabPage->activeViewContainer(); Q_EMIT activeViewChanged(viewContainer); Q_EMIT currentUrlChanged(viewContainer->url()); tabPage->setActive(true); - m_lastViewedTab = index; + tabPage->connectNavigators(m_navigatorsWidget); + m_navigatorsWidget->setSecondaryNavigatorVisible(tabPage->splitViewEnabled()); + m_lastViewedTab = tabPageAt(index); } void DolphinTabWidget::tabInserted(int index) -- cgit v1.3