mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
LocationBar: Show go icon when getting focus with edited text
closes #554
This commit is contained in:
parent
a046ec4ece
commit
726b11fab3
@ -149,6 +149,17 @@ QUrl LocationBar::createUrl()
|
||||
return urlToLoad;
|
||||
}
|
||||
|
||||
QString LocationBar::convertUrlToText(const QUrl &url) const
|
||||
{
|
||||
QString stringUrl = qz_urlEncodeQueryString(url);
|
||||
|
||||
if (stringUrl == QLatin1String("qupzilla:speeddial") || stringUrl == QLatin1String("about:blank")) {
|
||||
stringUrl = "";
|
||||
}
|
||||
|
||||
return stringUrl;
|
||||
}
|
||||
|
||||
void LocationBar::urlEnter()
|
||||
{
|
||||
if (m_completerBookmarkId != -1) {
|
||||
@ -241,11 +252,7 @@ void LocationBar::showUrl(const QUrl &url)
|
||||
return;
|
||||
}
|
||||
|
||||
QString stringUrl = qz_urlEncodeQueryString(url);
|
||||
|
||||
if (stringUrl == QLatin1String("qupzilla:speeddial") || stringUrl == QLatin1String("about:blank")) {
|
||||
stringUrl = "";
|
||||
}
|
||||
const QString &stringUrl = convertUrlToText(url);
|
||||
|
||||
if (stringUrl == text()) {
|
||||
return;
|
||||
@ -356,6 +363,18 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event)
|
||||
m_menu->popup(p);
|
||||
}
|
||||
|
||||
void LocationBar::focusInEvent(QFocusEvent* event)
|
||||
{
|
||||
const QString &stringUrl = convertUrlToText(m_webView->url());
|
||||
|
||||
// Text has been edited, let's show go button
|
||||
if (stringUrl != text()) {
|
||||
showGoButton();
|
||||
}
|
||||
|
||||
LineEdit::focusInEvent(event);
|
||||
}
|
||||
|
||||
void LocationBar::dropEvent(QDropEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
@ -388,10 +407,12 @@ void LocationBar::dropEvent(QDropEvent* event)
|
||||
QLineEdit::dropEvent(event);
|
||||
}
|
||||
|
||||
void LocationBar::focusOutEvent(QFocusEvent* e)
|
||||
void LocationBar::focusOutEvent(QFocusEvent* event)
|
||||
{
|
||||
QLineEdit::focusOutEvent(e);
|
||||
if (e->reason() == Qt::PopupFocusReason || (!selectedText().isEmpty() && e->reason() != Qt::TabFocusReason)) {
|
||||
QLineEdit::focusOutEvent(event);
|
||||
|
||||
if (event->reason() == Qt::PopupFocusReason
|
||||
|| (!selectedText().isEmpty() && event->reason() != Qt::TabFocusReason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,8 @@ private slots:
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
void focusOutEvent(QFocusEvent* e);
|
||||
void focusInEvent(QFocusEvent* event);
|
||||
void focusOutEvent(QFocusEvent* event);
|
||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
@ -87,6 +88,7 @@ private:
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
QUrl createUrl();
|
||||
QString convertUrlToText(const QUrl &url) const;
|
||||
|
||||
void showGoButton();
|
||||
void hideGoButton();
|
||||
|
Loading…
Reference in New Issue
Block a user