1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

LocationBar: Show search icon as site icon when completion popup is open

This commit is contained in:
David Rosca 2018-01-26 10:55:27 +01:00
parent 4ad5900604
commit 948e623f9e
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 18 additions and 4 deletions

View File

@ -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;

View File

@ -41,6 +41,7 @@ public:
void setMainWindow(BrowserWindow* window);
void setLocationBar(LocationBar* locationBar);
bool isVisible() const;
void closePopup();
public slots:

View File

@ -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)