diff options
| author | Nate Graham <[email protected]> | 2018-12-16 13:49:57 -0700 |
|---|---|---|
| committer | Nate Graham <[email protected]> | 2018-12-16 13:57:19 -0700 |
| commit | 34ebf8e0e8a3827f213f310d94c93a81c6f80cdb (patch) | |
| tree | 9bff7402470ca1eeeedd6e01fcd72689f0828d01 /src/dolphinmainwindow.cpp | |
| parent | 2050fe17811c2a176db0aee872a9ba25939c6f86 (diff) | |
Return editable URL navigator to breadcrumb mode if it has focus and everything is selected and when Ctrl+L is pressed
Summary:
This patch makes an editable location bar return to breadcrumb mode when {key Ctrl L} is pressed, but only if the location bar currently has focus and everything is selected. Otherwise, it will simply return focus to it as before.
This provides a slightly easier way to make the location bar return to breadcrumbs mode
Test Plan:
- Compile and deploy and make the location bar be breadcrumbs
- Hit {key Ctrl L} twice in a row -> location field turns to being in breadcrumb mode. Focus is correctly returned to the main view.
- Hit {key Ctrl L}, move focus elsewhere, then hit {key Ctrl L} again -> Location bar is editable and focused with everything selected.
- Hit {key Ctrl L}, deselect some of the text, then hit {key Ctrl L} again -> Location bar selects everything.
Reviewers: #dolphin, elvisangelaccio, dhaumann
Reviewed By: elvisangelaccio, dhaumann
Subscribers: elvisangelaccio, dhaumann, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16980
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index ff2ea900c..98920c001 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -621,12 +621,19 @@ void DolphinMainWindow::toggleEditLocation() void DolphinMainWindow::replaceLocation() { KUrlNavigator* navigator = m_activeViewContainer->urlNavigator(); - navigator->setUrlEditable(true); - navigator->setFocus(); - - // select the whole text of the combo box editor QLineEdit* lineEdit = navigator->editor()->lineEdit(); - lineEdit->selectAll(); + + // If the text field currently has focus and everything is selected, + // pressing the keyboard shortcut returns the whole thing to breadcrumb mode + if (navigator->isUrlEditable() + && lineEdit->hasFocus() + && lineEdit->selectedText() == lineEdit->text() ) { + navigator->setUrlEditable(false); + } else { + navigator->setUrlEditable(true); + navigator->setFocus(); + lineEdit->selectAll(); + } } void DolphinMainWindow::togglePanelLockState() |
