+ const int urlNavigatorsAmount = m_splitter->count() > 1 && m_splitter->widget(1)->isVisible() ? 2 : 1;
+ setText(i18ncp("@action:inmenu", "Location Bar", "Location Bars", urlNavigatorsAmount));
+}
+
+DolphinNavigatorsWidgetAction::ViewGeometriesHelper::ViewGeometriesHelper(QWidget *navigatorsWidget, DolphinNavigatorsWidgetAction *navigatorsWidgetAction)
+ : m_navigatorsWidget{navigatorsWidget}
+ , m_navigatorsWidgetAction{navigatorsWidgetAction}
+{
+ Q_CHECK_PTR(navigatorsWidget);
+ Q_CHECK_PTR(navigatorsWidgetAction);
+}
+
+bool DolphinNavigatorsWidgetAction::ViewGeometriesHelper::eventFilter(QObject *watched, QEvent *event)
+{
+ if (event->type() == QEvent::Resize) {
+ if (qobject_cast<QWidget*>(m_navigatorsWidgetAction->parent())->window()->width() != m_navigatorsWidgetAction->m_previousWindowWidth) {
+ // The window is being resized which means not all widgets have gotten their new sizes yet.
+ // Let's wait a bit so the sizes of the navigatorsWidget and the viewContainers have all
+ // had a chance to be updated.
+ m_navigatorsWidgetAction->m_adjustSpacingTimer->start();
+ } else {
+ m_navigatorsWidgetAction->adjustSpacing();
+ // We could always use the m_adjustSpacingTimer instead of calling adjustSpacing() directly
+ // here but then the navigatorsWidget doesn't fluently align with the viewContainers when
+ // the DolphinTabPage::m_expandViewAnimation is animating.
+ }
+ return false;
+ }
+ return QObject::eventFilter(watched, event);
+}
+
+void DolphinNavigatorsWidgetAction::ViewGeometriesHelper::setViewContainers(QWidget *primaryViewContainer, QWidget *secondaryViewContainer)
+{
+ Q_CHECK_PTR(primaryViewContainer);
+ if (m_primaryViewContainer) {
+ m_primaryViewContainer->removeEventFilter(this);
+ }
+ primaryViewContainer->installEventFilter(this);
+ m_primaryViewContainer = primaryViewContainer;
+
+ // It is not possible to resize the secondaryViewContainer without simultaneously
+ // resizing the primaryViewContainer so we don't have to installEventFilter() here.
+ m_secondaryViewContainer = secondaryViewContainer;