From 0cee94ce82ccb82afd0c4e22d77e251276e7a447 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Wed, 6 Jan 2021 01:38:45 +0000 Subject: Fix location bar being wrongly aligned on first startup When starting Dolphin the very first time, the spacing in front of the location bar is wrong. This commit fixes this by completely updating all cached geometry every time adjustSpacing() is called. Because this happens once on a timer 100 ms after every url change, it will happen once shortly after the window is shown. At that point all geometry is where it should be and spacing calculation works as expected. The ViewContainer geometry retrieval is refactored into a small nested helper class in DolphinNavigatorsWidgetAction by the name ViewGeometriesHelper. Previously the logic of that class was divided between DolphinTabPage and DolphinNavigatorsWidgetAction. BUG: 429447 FIXED-IN: 21.04.0 --- src/dolphintabpage.cpp | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src/dolphintabpage.cpp') diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index a90e8e7f0..36049fa97 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -43,7 +43,6 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, this, &DolphinTabPage::slotViewUrlRedirection); m_splitter->addWidget(m_primaryViewContainer); - m_primaryViewContainer->installEventFilter(this); m_primaryViewContainer->show(); if (secondaryUrl.isValid() || GeneralSettings::splitView()) { @@ -53,7 +52,6 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, const QUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl; m_secondaryViewContainer = createViewContainer(url); m_splitter->addWidget(m_secondaryViewContainer); - m_secondaryViewContainer->installEventFilter(this); m_secondaryViewContainer->show(); } @@ -98,9 +96,10 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const } m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator); m_navigatorsWidget->setSecondaryNavigatorVisible(true); + m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, + m_secondaryViewContainer); m_splitter->addWidget(m_secondaryViewContainer); - m_secondaryViewContainer->installEventFilter(this); m_secondaryViewContainer->setActive(true); if (animated == WithAnimation) { @@ -141,6 +140,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const } } m_primaryViewContainer->setActive(true); + m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, nullptr); if (animated == WithoutAnimation) { view->close(); @@ -201,7 +201,8 @@ void DolphinTabPage::connectNavigators(DolphinNavigatorsWidgetAction *navigators auto secondaryNavigator = navigatorsWidget->secondaryUrlNavigator(); m_secondaryViewContainer->connectUrlNavigator(secondaryNavigator); } - resizeNavigators(); + m_navigatorsWidget->followViewContainersGeometry(m_primaryViewContainer, + m_secondaryViewContainer); } void DolphinTabPage::disconnectNavigators() @@ -213,15 +214,6 @@ void DolphinTabPage::disconnectNavigators() } } -bool DolphinTabPage::eventFilter(QObject *watched, QEvent *event) -{ - if (event->type() == QEvent::Resize && m_navigatorsWidget) { - resizeNavigators(); - return false; - } - return QWidget::eventFilter(watched, event); -} - void DolphinTabPage::insertNavigatorsWidget(DolphinNavigatorsWidgetAction* navigatorsWidget) { QGridLayout *gridLayout = static_cast(layout()); @@ -235,22 +227,6 @@ void DolphinTabPage::insertNavigatorsWidget(DolphinNavigatorsWidgetAction* navig } } - -void DolphinTabPage::resizeNavigators() const -{ - if (!m_secondaryViewContainer) { - m_navigatorsWidget->followViewContainerGeometry( - m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x(), - m_primaryViewContainer->width()); - } else { - m_navigatorsWidget->followViewContainersGeometry( - m_primaryViewContainer->mapToGlobal(QPoint(0,0)).x(), - m_primaryViewContainer->width(), - m_secondaryViewContainer->mapToGlobal(QPoint(0,0)).x(), - m_secondaryViewContainer->width()); - } -} - void DolphinTabPage::markUrlsAsSelected(const QList& urls) { m_primaryViewContainer->view()->markUrlsAsSelected(urls); -- cgit v1.3