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

LocationBar: Complete domain when going back to original text

This commit is contained in:
David Rosca 2016-12-29 12:11:40 +01:00
parent 3e18d17964
commit 82e9d0c0ee
4 changed files with 13 additions and 6 deletions

View File

@ -119,11 +119,14 @@ void LocationCompleter::currentChanged(const QModelIndex &index)
{
QString completion = index.data().toString();
bool isOriginal = false;
if (completion.isEmpty()) {
isOriginal = true;
completion = m_originalText;
}
emit showCompletion(completion);
emit showCompletion(completion, isOriginal);
}
void LocationCompleter::indexActivated(const QModelIndex &index)
@ -256,7 +259,7 @@ void LocationCompleter::loadUrl(const QUrl &url)
closePopup();
// Show url in locationbar
emit showCompletion(url.toEncoded());
emit showCompletion(url.toEncoded(), false);
// Load url
emit loadCompletion();

View File

@ -46,7 +46,7 @@ public slots:
void showMostVisited();
signals:
void showCompletion(const QString &completion);
void showCompletion(const QString &completion, bool isOriginal);
void showDomainCompletion(const QString &completion);
void loadCompletion();
void clearCompletion();

View File

@ -74,7 +74,7 @@ LocationBar::LocationBar(BrowserWindow* window)
m_completer = new LocationCompleter(this);
m_completer->setMainWindow(m_window);
m_completer->setLocationBar(this);
connect(m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString)));
connect(m_completer, SIGNAL(showCompletion(QString,bool)), this, SLOT(showCompletion(QString,bool)));
connect(m_completer, SIGNAL(showDomainCompletion(QString)), this, SLOT(showDomainCompletion(QString)));
connect(m_completer, SIGNAL(loadCompletion()), this, SLOT(requestLoadUrl()));
connect(m_completer, SIGNAL(clearCompletion()), this, SLOT(clearCompletion()));
@ -154,12 +154,16 @@ void LocationBar::updatePlaceHolderText()
setPlaceholderText(tr("Enter URL address"));
}
void LocationBar::showCompletion(const QString &completion)
void LocationBar::showCompletion(const QString &completion, bool isOriginal)
{
LineEdit::setText(completion);
// Move cursor to the end
end(false);
if (isOriginal) {
completer()->complete();
}
}
void LocationBar::clearCompletion()

View File

@ -60,7 +60,7 @@ private slots:
void setPrivacyState(bool state);
void setGoIconVisible(bool state);
void showCompletion(const QString &completion);
void showCompletion(const QString &completion, bool isOriginal);
void showDomainCompletion(const QString &completion);
void clearCompletion();