aboutsummaryrefslogtreecommitdiff
path: root/lib/addressbar/urllineedit.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-08-07 13:01:36 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-08-07 13:10:10 +0200
commit8091212801c82bbbcf2ef6e22f948c71b39f0f54 (patch)
tree471953ed5992b796300506aed20bc3dd4634561c /lib/addressbar/urllineedit.cpp
parentAdd move tab left/right shortcut (diff)
downloadsmolbote-8091212801c82bbbcf2ef6e22f948c71b39f0f54.tar.xz
AddressBar: prevent URL formatting caused by context menu
Diffstat (limited to 'lib/addressbar/urllineedit.cpp')
-rw-r--r--lib/addressbar/urllineedit.cpp14
1 files changed, 14 insertions, 0 deletions
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);