diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-07 13:01:36 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-07 13:10:10 +0200 |
commit | 8091212801c82bbbcf2ef6e22f948c71b39f0f54 (patch) | |
tree | 471953ed5992b796300506aed20bc3dd4634561c /lib/addressbar/urllineedit.cpp | |
parent | Add move tab left/right shortcut (diff) | |
download | smolbote-8091212801c82bbbcf2ef6e22f948c71b39f0f54.tar.xz |
AddressBar: prevent URL formatting caused by context menu
Diffstat (limited to 'lib/addressbar/urllineedit.cpp')
-rw-r--r-- | lib/addressbar/urllineedit.cpp | 14 |
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); |