From 3ec4d96f74a1615f2bc329dd74c37e8d5f506fc5 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 26 Jan 2018 10:13:10 +0100 Subject: [PATCH] LocationCompleter: Properly close popup when showing search engines dialog --- src/lib/navigation/completer/locationcompleter.cpp | 12 ++++++++++++ src/lib/navigation/completer/locationcompleter.h | 1 + .../navigation/completer/locationcompleterview.cpp | 9 +-------- src/lib/navigation/completer/locationcompleterview.h | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/navigation/completer/locationcompleter.cpp b/src/lib/navigation/completer/locationcompleter.cpp index a47e436ad..9098fb590 100644 --- a/src/lib/navigation/completer/locationcompleter.cpp +++ b/src/lib/navigation/completer/locationcompleter.cpp @@ -30,6 +30,7 @@ #include "qzsettings.h" #include "opensearchengine.h" #include "networkmanager.h" +#include "searchenginesdialog.h" #include @@ -142,6 +143,7 @@ void LocationCompleter::slotPopupClosed() disconnect(s_view, SIGNAL(indexShiftActivated(QModelIndex)), this, SLOT(indexShiftActivated(QModelIndex))); disconnect(s_view, SIGNAL(indexDeleteRequested(QModelIndex)), this, SLOT(indexDeleteRequested(QModelIndex))); disconnect(s_view, &LocationCompleterView::loadRequested, this, &LocationCompleter::loadRequested); + disconnect(s_view, &LocationCompleterView::searchEnginesDialogRequested, this, &LocationCompleter::openSearchEnginesDialog); disconnect(s_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex))); emit popupClosed(); @@ -348,6 +350,15 @@ void LocationCompleter::loadRequest(const LoadRequest &request) emit loadRequested(request); } +void LocationCompleter::openSearchEnginesDialog() +{ + // Clear locationbar + emit clearCompletion(); + + SearchEnginesDialog *dialog = new SearchEnginesDialog(m_window); + dialog->open(); +} + void LocationCompleter::showPopup() { Q_ASSERT(m_window); @@ -376,6 +387,7 @@ void LocationCompleter::showPopup() connect(s_view, SIGNAL(indexShiftActivated(QModelIndex)), this, SLOT(indexShiftActivated(QModelIndex))); connect(s_view, SIGNAL(indexDeleteRequested(QModelIndex)), this, SLOT(indexDeleteRequested(QModelIndex))); connect(s_view, &LocationCompleterView::loadRequested, this, &LocationCompleter::loadRequested); + connect(s_view, &LocationCompleterView::searchEnginesDialogRequested, this, &LocationCompleter::openSearchEnginesDialog); connect(s_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex))); s_view->createWinId(); diff --git a/src/lib/navigation/completer/locationcompleter.h b/src/lib/navigation/completer/locationcompleter.h index bea9f5812..ca0ef57b0 100644 --- a/src/lib/navigation/completer/locationcompleter.h +++ b/src/lib/navigation/completer/locationcompleter.h @@ -70,6 +70,7 @@ private: LoadRequest createLoadRequest(const QModelIndex &index); void switchToTab(BrowserWindow* window, int tab); void loadRequest(const LoadRequest &reqeust); + void openSearchEnginesDialog(); void showPopup(); void adjustPopupSize(); diff --git a/src/lib/navigation/completer/locationcompleterview.cpp b/src/lib/navigation/completer/locationcompleterview.cpp index 38b5622d4..eca96165c 100644 --- a/src/lib/navigation/completer/locationcompleterview.cpp +++ b/src/lib/navigation/completer/locationcompleterview.cpp @@ -21,7 +21,6 @@ #include "toolbutton.h" #include "iconprovider.h" #include "mainapplication.h" -#include "searchenginesdialog.h" #include "searchenginesmanager.h" #include "loadrequest.h" @@ -73,7 +72,7 @@ LocationCompleterView::LocationCompleterView() searchSettingsButton->setToolTip(tr("Manage Search Engines")); searchSettingsButton->setAutoRaise(true); searchSettingsButton->setIconSize(QSize(16, 16)); - connect(searchSettingsButton, &ToolButton::clicked, this, &LocationCompleterView::openSearchEnginesDialog); + connect(searchSettingsButton, &ToolButton::clicked, this, &LocationCompleterView::searchEnginesDialogRequested); QLabel *searchLabel = new QLabel(tr("Search with:")); m_searchEnginesLayout = new QHBoxLayout(); @@ -396,9 +395,3 @@ void LocationCompleterView::setupSearchEngines() m_searchEnginesLayout->addWidget(button); } } - -void LocationCompleterView::openSearchEnginesDialog() -{ - SearchEnginesDialog *dialog = new SearchEnginesDialog(focusProxy()); - dialog->open(); -} diff --git a/src/lib/navigation/completer/locationcompleterview.h b/src/lib/navigation/completer/locationcompleterview.h index 18c35d03b..c593c19b0 100644 --- a/src/lib/navigation/completer/locationcompleterview.h +++ b/src/lib/navigation/completer/locationcompleterview.h @@ -50,6 +50,7 @@ public: signals: void closed(); + void searchEnginesDialogRequested(); void loadRequested(const LoadRequest &request); void indexActivated(const QModelIndex &index);