From 8599a42ac13e2af6f085d899380aee7714ae28c2 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Thu, 3 Oct 2019 22:00:24 +0200 Subject: Update searchbox on URL changes (Fix D24369) Summary: In D24369 I introduced a regression: Where now the searchbox is updated on url changes for search urls, it is not updated anymore for regular folders. The effect is that not-indexed folders can have the extra options enabled or vice-versa. This patch fixes it, moving back the updating logic to `setSearchModeEnable`. Test Plan: - Searchbox updates properly when changing between search urls and regular folders, either indexed or nor-indexed. Reviewers: #dolphin, elvisangelaccio Subscribers: kfm-devel, elvisangelaccio Tags: #dolphin Differential Revision: https://phabricator.kde.org/D24376 --- src/dolphinviewcontainer.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 8e821d8aa..c6d9d89ad 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -385,6 +385,11 @@ bool DolphinViewContainer::isFilterBarVisible() const void DolphinViewContainer::setSearchModeEnabled(bool enabled) { + if (enabled) { + const QUrl& locationUrl = m_urlNavigator->locationUrl(); + m_searchBox->fromSearchUrl(locationUrl); + } + if (enabled == isSearchModeEnabled()) { if (enabled && !m_searchBox->hasFocus()) { m_searchBox->setFocus(); @@ -671,15 +676,11 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url) slotReturnPressed(); if (KProtocolManager::supportsListing(url)) { - const bool searchUrl = isSearchUrl(url); - if (searchUrl) { - m_searchBox->fromSearchUrl(url); - } - setSearchModeEnabled(searchUrl); + setSearchModeEnabled(isSearchUrl(url)); m_view->setUrl(url); tryRestoreViewState(); - if (m_autoGrabFocus && isActive() && !searchUrl) { + if (m_autoGrabFocus && isActive() && !isSearchUrl(url)) { // When an URL has been entered, the view should get the focus. // The focus must be requested asynchronously, as changing the URL might create // a new view widget. -- cgit v1.3 From 31fd775f368f61f6dde54c0c3a2e83d65599c3c2 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Sun, 6 Oct 2019 11:34:30 +0200 Subject: Fix crash when lauching dolphin with a search scheme Summary: Widget objects are initialized in `DolphinSearchBox::init()`, which is called on `QEvent::Polish`, so we must set it visible before calling `fromSearchUrl`. Test Plan: `dolphin --new-window baloosearch://` Reviewers: #dolphin, elvisangelaccio Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D24432 --- src/dolphinviewcontainer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index c6d9d89ad..536ab0fa8 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -385,6 +385,9 @@ bool DolphinViewContainer::isFilterBarVisible() const void DolphinViewContainer::setSearchModeEnabled(bool enabled) { + m_searchBox->setVisible(enabled); + m_navigatorWidget->setVisible(!enabled); + if (enabled) { const QUrl& locationUrl = m_urlNavigator->locationUrl(); m_searchBox->fromSearchUrl(locationUrl); @@ -398,9 +401,6 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) return; } - m_searchBox->setVisible(enabled); - m_navigatorWidget->setVisible(!enabled); - if (!enabled) { m_view->setViewPropertiesContext(QString()); -- cgit v1.3