From 8091212801c82bbbcf2ef6e22f948c71b39f0f54 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 7 Aug 2018 13:01:36 +0200 Subject: AddressBar: prevent URL formatting caused by context menu --- lib/addressbar/urllineedit.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/addressbar/urllineedit.cpp') diff --git a/lib/addressbar/urllineedit.cpp b/lib/addressbar/urllineedit.cpp index edbe327..6af6cf5 100644 --- a/lib/addressbar/urllineedit.cpp +++ b/lib/addressbar/urllineedit.cpp @@ -101,12 +101,26 @@ void UrlLineEdit::updateCompleter(const QStringList &l) void UrlLineEdit::focusInEvent(QFocusEvent *event) { + // a context menu event also causes a focusInEvent, so if text is selected + // skip the formatting step + if(event->reason() == Qt::PopupFocusReason) { + QLineEdit::focusInEvent(event); + return; + } + clearTextFormat(); QLineEdit::focusInEvent(event); } void UrlLineEdit::focusOutEvent(QFocusEvent *event) { + // a context menu event causes a focusOutEvent, and setUrl will clear the + // selection, and this would prevent the menu from working properly + if(event->reason() == Qt::PopupFocusReason) { + QLineEdit::focusOutEvent(event); + return; + } + const QUrl url = QUrl::fromUserInput(text()); if(url.isValid()) setUrl(url); -- cgit v1.2.1