diff options
| author | Felix Ernst <[email protected]> | 2024-10-28 03:58:45 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2024-10-31 16:28:02 +0000 |
| commit | 67695c1b01ea241b359e456dad44488e5cd9fdce (patch) | |
| tree | 0403a76dbf1d62fe3c3e331731e67838c8445417 /src/tests | |
| parent | f6d90c92b9c3f53c57313931fd8b92e9fcd44d1c (diff) | |
Make Escape move focus from location bar to view
Pressing Escape on the location bar while in breadcrumb mode has no
effect at all. This commit changes this to instead move the focus
to the active view. This is more logical because a user pressing
escape while having focus on the location bar is no longer
interested in interacting and changing the location in the location
bar. They most likely want to act on the current location instead.
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/dolphinmainwindowtest.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 8fd5be7cb..a57632a1d 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -48,6 +48,7 @@ private Q_SLOTS: void testNewFileMenuEnabled(); void testWindowTitle_data(); void testWindowTitle(); + void testFocusLocationBar(); void testFocusPlacesPanel(); void testPlacesPanelWidthResistance(); void testGoActions(); @@ -389,6 +390,36 @@ void DolphinMainWindowTest::testWindowTitle() QCOMPARE(m_mainWindow->windowTitle(), expectedWindowTitle); } +void DolphinMainWindowTest::testFocusLocationBar() +{ + const QUrl homePathUrl{QUrl::fromLocalFile(QDir::homePath())}; + m_mainWindow->openDirectories({homePathUrl}, false); + m_mainWindow->show(); + QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data())); + QVERIFY(m_mainWindow->isVisible()); + + QAction *replaceLocationAction = m_mainWindow->actionCollection()->action(QStringLiteral("replace_location")); + replaceLocationAction->trigger(); + QVERIFY(m_mainWindow->activeViewContainer()->urlNavigator()->isAncestorOf(QApplication::focusWidget())); + replaceLocationAction->trigger(); + QVERIFY(m_mainWindow->activeViewContainer()->view()->hasFocus()); + + QAction *editableLocationAction = m_mainWindow->actionCollection()->action(QStringLiteral("editable_location")); + editableLocationAction->trigger(); + QVERIFY(m_mainWindow->activeViewContainer()->urlNavigator()->isAncestorOf(QApplication::focusWidget())); + QVERIFY(m_mainWindow->activeViewContainer()->urlNavigator()->isUrlEditable()); + editableLocationAction->trigger(); + QVERIFY(!m_mainWindow->activeViewContainer()->urlNavigator()->isUrlEditable()); + + replaceLocationAction->trigger(); + QVERIFY(m_mainWindow->activeViewContainer()->urlNavigator()->isAncestorOf(QApplication::focusWidget())); + + // Pressing Escape multiple times should eventually move the focus back to the active view. + QTest::keyClick(QApplication::focusWidget(), Qt::Key_Escape); // Focus might not go the view yet because it toggles the editable state of the location bar. + QTest::keyClick(QApplication::focusWidget(), Qt::Key_Escape); + QVERIFY(m_mainWindow->activeViewContainer()->view()->hasFocus()); +} + void DolphinMainWindowTest::testFocusPlacesPanel() { m_mainWindow->openDirectories({QUrl::fromLocalFile(QDir::homePath())}, false); |
