From 948e623f9e9ab9a1caa5d0cf7de3ed53aae578d7 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 26 Jan 2018 10:55:27 +0100 Subject: [PATCH] LocationBar: Show search icon as site icon when completion popup is open --- .../navigation/completer/locationcompleter.cpp | 5 +++++ src/lib/navigation/completer/locationcompleter.h | 1 + src/lib/navigation/locationbar.cpp | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/lib/navigation/completer/locationcompleter.cpp b/src/lib/navigation/completer/locationcompleter.cpp index 53ddb5060..becfe5955 100644 --- a/src/lib/navigation/completer/locationcompleter.cpp +++ b/src/lib/navigation/completer/locationcompleter.cpp @@ -61,6 +61,11 @@ void LocationCompleter::setLocationBar(LocationBar* locationBar) m_locationBar = locationBar; } +bool LocationCompleter::isVisible() const +{ + return s_view->isVisible(); +} + void LocationCompleter::closePopup() { m_popupClosed = true; diff --git a/src/lib/navigation/completer/locationcompleter.h b/src/lib/navigation/completer/locationcompleter.h index ca0ef57b0..9ba1b6a56 100644 --- a/src/lib/navigation/completer/locationcompleter.h +++ b/src/lib/navigation/completer/locationcompleter.h @@ -41,6 +41,7 @@ public: void setMainWindow(BrowserWindow* window); void setLocationBar(LocationBar* locationBar); + bool isVisible() const; void closePopup(); public slots: diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index ea0240a11..87511e456 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -77,6 +77,7 @@ LocationBar::LocationBar(BrowserWindow* window) connect(m_completer, SIGNAL(showDomainCompletion(QString)), this, SLOT(showDomainCompletion(QString))); connect(m_completer, SIGNAL(clearCompletion()), this, SLOT(clearCompletion())); connect(m_completer, &LocationCompleter::loadRequested, this, &LocationBar::loadRequest); + connect(m_completer, &LocationCompleter::popupClosed, this, &LocationBar::updateSiteIcon); m_domainCompleterModel = new QStringListModel(this); QCompleter* domainCompleter = new QCompleter(this); @@ -160,6 +161,8 @@ void LocationBar::showCompletion(const QString &completion, bool completeDomain) if (completeDomain) { completer()->complete(); } + + updateSiteIcon(); } void LocationBar::clearCompletion() @@ -311,6 +314,7 @@ void LocationBar::textEdited(const QString &text) if (!text.isEmpty()) { m_completer->complete(text); + m_siteIcon->setIcon(QIcon::fromTheme(QSL("edit-find"), QIcon(QSL(":icons/menu/search-icon.svg")))); } else { m_completer->closePopup(); @@ -375,10 +379,14 @@ void LocationBar::loadRequest(const LoadRequest &request) void LocationBar::updateSiteIcon() { - QIcon icon = m_webView ? m_webView->icon() : IconProvider::emptyWebIcon(); - if (m_webView && m_webView->url().scheme() == QL1S("https")) - icon = QIcon::fromTheme(QSL("document-encrypted"), icon); - m_siteIcon->setIcon(QIcon(icon.pixmap(16))); + if (m_completer->isVisible()) { + m_siteIcon->setIcon(QIcon::fromTheme(QSL("edit-find"), QIcon(QSL(":icons/menu/search-icon.svg")))); + } else { + QIcon icon = m_webView ? m_webView->icon() : IconProvider::emptyWebIcon(); + if (m_webView && m_webView->url().scheme() == QL1S("https")) + icon = QIcon::fromTheme(QSL("document-encrypted"), icon); + m_siteIcon->setIcon(QIcon(icon.pixmap(16))); + } } void LocationBar::setPrivacyState(bool state)