From 6c7c04718b573ed9c382e289c361acbe6bd456b9 Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Thu, 28 Nov 2024 10:46:33 +0000 Subject: [PATCH] DolphinTabPage: Update container view url on redirection On url redirect, we should check which container url is being changed and then update it accordingly. This makes sure the tab name is updated. We also should not disconnect redirection on view activation since the redirection might be used by the other split. The disconnection is done in `setSplitViewEnabled` instead. This allows us to update the tab name every time the url changes, even inside a splitview where the split which name is changed is not active. BUG:496414 --- src/dolphintabpage.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index 1aacf4351..dbc1ff147 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -45,6 +45,7 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, m_splitViewEnabled = true; const QUrl &url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl; m_secondaryViewContainer = createViewContainer(url); + connect(m_secondaryViewContainer->view(), &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection); m_splitter->addWidget(m_secondaryViewContainer); m_secondaryViewContainer->show(); } @@ -88,6 +89,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const secondaryNavigator = m_navigatorsWidget->secondaryUrlNavigator(); } m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator); + connect(m_secondaryViewContainer->view(), &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection); m_navigatorsWidget->setSecondaryNavigatorVisible(true); m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, m_secondaryViewContainer); @@ -104,6 +106,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const } else { m_navigatorsWidget->setSecondaryNavigatorVisible(false); m_secondaryViewContainer->disconnectUrlNavigator(); + disconnect(m_secondaryViewContainer->view(), &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection); DolphinViewContainer *view; if (GeneralSettings::closeActiveSplitView()) { @@ -427,17 +430,24 @@ void DolphinTabPage::slotViewActivated() } disconnect(oldActiveView, &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged); - disconnect(oldActiveView, &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection); connect(newActiveView, &DolphinView::urlChanged, this, &DolphinTabPage::activeViewUrlChanged); - connect(newActiveView, &DolphinView::redirection, this, &DolphinTabPage::slotViewUrlRedirection); Q_EMIT activeViewChanged(activeViewContainer()); Q_EMIT activeViewUrlChanged(activeViewContainer()->url()); } void DolphinTabPage::slotViewUrlRedirection(const QUrl &oldUrl, const QUrl &newUrl) { - Q_UNUSED(oldUrl) - + // Make sure the url of the view is updated. BUG:496414 + if (splitViewEnabled()) { + if (primaryViewContainer()->view()->url() == oldUrl) { + primaryViewContainer()->view()->setUrl(newUrl); + } + if (secondaryViewContainer()->view()->url() == oldUrl) { + secondaryViewContainer()->view()->setUrl(newUrl); + } + } else { + activeViewContainer()->view()->setUrl(newUrl); + } Q_EMIT activeViewUrlChanged(newUrl); } -- 2.47.3