From 12b4a8a91e0b9b8dd00816b5fb84e8e09000afcd Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Tue, 16 Jun 2026 22:08:24 +0200 Subject: Add "Focus Other View" action Replace the setting "Switch between views with Tab key" with a dedicated "Focus Other View" action (which can be bound to the Tab key if the user wants to). The "Focus Other View" action moves the keyboard focus to the inactive split view. When there is no other view, split view is triggered instead. The action is located in `Menubar>View`. ### Motivation The Tab key is essential for keyboard navigation within an application. The old "Switch between views with Tab key" setting forces users to give up on the intended purpose of the Tab key, which means many keyboard-bound users currently do not have a way to switch between views when using the "Split" feature. The dedicated "Focus Other View" action gives users more control, and they can change the keyboard shortcut as they are used to. --- src/tests/dolphinmainwindowtest.cpp | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/tests/dolphinmainwindowtest.cpp') diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 534ac4654..a629268c1 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -65,6 +65,7 @@ private Q_SLOTS: void testWindowTitle(); void testFocusLocationBar(); void testFocusPlacesPanel(); + void testFocusOtherView(); void testPlacesPanelWidthResistance(); void testGoActions(); void testOpenFiles(); @@ -576,6 +577,44 @@ void DolphinMainWindowTest::testFocusPlacesPanel() "Activating a place should move focus to the view even if the view already has that place loaded."); } +void DolphinMainWindowTest::testFocusOtherView() +{ + m_mainWindow->openDirectories({QUrl::fromLocalFile(QDir::homePath())}, false); + m_mainWindow->show(); + QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data())); + QVERIFY(m_mainWindow->isVisible()); + QTRY_VERIFY_WITH_TIMEOUT(QApplication::activeWindow() != nullptr, 100); + + QAction *const focusOtherViewAction = m_mainWindow->actionCollection()->action(QStringLiteral("focus_inactive_split_view")); + + /** Triggering the "Focus Other View" action when there is no other view should create such a view and focus it. */ + QVERIFY(!m_mainWindow->m_tabWidget->currentTabPage()->splitViewEnabled()); + const DolphinViewContainer *const previouslyActiveView = m_mainWindow->activeViewContainer(); + QVERIFY(previouslyActiveView->isAncestorOf(QApplication::focusWidget())); + focusOtherViewAction->trigger(); + QVERIFY(m_mainWindow->m_tabWidget->currentTabPage()->splitViewEnabled()); + QVERIFY(!previouslyActiveView->isAncestorOf(QApplication::focusWidget())); + + const DolphinViewContainer *const otherView = m_mainWindow->activeViewContainer(); + QVERIFY(previouslyActiveView != otherView); + QVERIFY(otherView->isAncestorOf(QApplication::focusWidget())); + + /** "Focus Other View" and "Split" have the same behaviour when there is only one view. Make sure their default keyboard shortcuts stay similar. */ + QVERIFY(focusOtherViewAction->shortcut().toString().contains(m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->shortcut().toString()) + || focusOtherViewAction->shortcut().toString().contains( + m_mainWindow->actionCollection()->action(QStringLiteral("split_view_menu"))->shortcut().toString())); + + /** Test the typical usage of "Focus Other View" */ + QVERIFY(previouslyActiveView != otherView); + QVERIFY(otherView->isAncestorOf(QApplication::focusWidget())); + focusOtherViewAction->trigger(); + QVERIFY(previouslyActiveView->isAncestorOf(QApplication::focusWidget())); + focusOtherViewAction->trigger(); + QVERIFY(otherView->isAncestorOf(QApplication::focusWidget())); + focusOtherViewAction->trigger(); + QVERIFY(previouslyActiveView->isAncestorOf(QApplication::focusWidget())); +} + /** * The places panel will resize itself if any of the other widgets requires too much horizontal space * but a user never wants the size of the places panel to change unless they resized it themselves explicitly. -- cgit v1.3.1