diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1471,6 +1471,9 @@ { QAction* splitAction = actionCollection()->action(QStringLiteral("split_view")); const DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); + if (!tabPage) { + return; + } if (tabPage->splitViewEnabled()) { if (tabPage->primaryViewActive()) { splitAction->setText(i18nc("@action:intoolbar Close left view", "Close")); diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h --- a/src/dolphintabpage.h +++ b/src/dolphintabpage.h @@ -129,6 +129,12 @@ */ void restoreStateV1(const QByteArray& state); + /** + * Set whether the tab page is active + * + */ + void setActive(bool active); + signals: void activeViewChanged(DolphinViewContainer* viewContainer); void activeViewUrlChanged(const QUrl& url); @@ -165,6 +171,7 @@ bool m_primaryViewActive; bool m_splitViewEnabled; + bool m_active; }; #endif // DOLPHIN_TAB_PAGE_H diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -28,7 +28,8 @@ DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) : QWidget(parent), m_primaryViewActive(true), - m_splitViewEnabled(false) + m_splitViewEnabled(false), + m_active(true) { QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(0); @@ -286,17 +287,31 @@ m_splitter->restoreState(splitterState); } +void DolphinTabPage::setActive(bool active) +{ + if (active) { + m_active = active; + } else { + // we should bypass changing active view in split mode + m_active = !m_splitViewEnabled; + } + // we want view to fire activated when goes from false to true + activeViewContainer()->setActive(active); +} + void DolphinTabPage::slotViewActivated() { const DolphinView* oldActiveView = activeViewContainer()->view(); // Set the view, which was active before, to inactive - // and update the active view type. - if (m_splitViewEnabled) { - activeViewContainer()->setActive(false); - m_primaryViewActive = !m_primaryViewActive; - } else { - m_primaryViewActive = true; + // and update the active view type, if tab is active + if (m_active) { + if (m_splitViewEnabled) { + activeViewContainer()->setActive(false); + m_primaryViewActive = !m_primaryViewActive; + } else { + m_primaryViewActive = true; + } } const DolphinView* newActiveView = activeViewContainer()->view(); diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -33,7 +33,7 @@ DolphinTabWidget::DolphinTabWidget(QWidget* parent) : QTabWidget(parent), m_placesSelectorVisible(true), - m_previousTab(-1) + m_previousTab(0) { connect(this, &DolphinTabWidget::tabCloseRequested, this, static_cast(&DolphinTabWidget::closeTab)); @@ -304,15 +304,15 @@ void DolphinTabWidget::currentTabChanged(int index) { - DolphinViewContainer* viewContainer = tabPageAt(index)->activeViewContainer(); - viewContainer->setActive(true); + // previous tab deactivation + if (DolphinTabPage* tabPage = tabPageAt(m_previousTab)) { + tabPage->setActive(false); + } + DolphinTabPage* tabPage = tabPageAt(index); + DolphinViewContainer* viewContainer = tabPage->activeViewContainer(); emit activeViewChanged(viewContainer); emit currentUrlChanged(viewContainer->url()); - viewContainer->view()->setFocus(); - - if (tabPageAt(m_previousTab)) { - tabPageAt(m_previousTab)->activeViewContainer()->setActive(false); - } + tabPage->setActive(true); m_previousTab = index; } diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -230,8 +230,13 @@ { switch (event->type()) { case QEvent::FocusIn: - setActive(true); - setFocus(); + // #379135: we get the FocusIn event when we close a tab but we don't want to emit + // the activated() signal before the removeTab() call in DolphinTabWidget::closeTab() returns. + // To avoid this issue, we delay the activation of the search box. + QTimer::singleShot(0, this, [this] { + setActive(true); + setFocus(); + }); break; default: