diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-09 14:49:23 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-09 14:49:23 +0200 |
commit | 060b735c50dc968d8d6b074c4aa31409fcae0b5e (patch) | |
tree | 29e9dcb718d957637ac5e2fbbe0e1cfe54e04580 /lib | |
parent | Move load profile menu to page menu from tab menu (diff) | |
download | smolbote-060b735c50dc968d8d6b074c4aa31409fcae0b5e.tar.xz |
Focus view when URL bar loses focus
Diffstat (limited to 'lib')
-rw-r--r-- | lib/addressbar/addressbar.cpp | 6 | ||||
-rw-r--r-- | lib/addressbar/addressbar.h | 1 | ||||
-rw-r--r-- | lib/addressbar/urllineedit.cpp | 1 | ||||
-rw-r--r-- | lib/addressbar/urllineedit.h | 3 |
4 files changed, 11 insertions, 0 deletions
diff --git a/lib/addressbar/addressbar.cpp b/lib/addressbar/addressbar.cpp index 3768aeb..2409cb9 100644 --- a/lib/addressbar/addressbar.cpp +++ b/lib/addressbar/addressbar.cpp @@ -47,6 +47,7 @@ AddressBar::~AddressBar() disconnect(urlChangedConnection); disconnect(loadUrlConnection); disconnect(progressBarConnection); + disconnect(focusConnection); } void AddressBar::setView(QWebEngineView *view) @@ -54,6 +55,7 @@ void AddressBar::setView(QWebEngineView *view) disconnect(urlChangedConnection); disconnect(loadUrlConnection); disconnect(progressBarConnection); + disconnect(focusConnection); progressBar->setValue(100); @@ -78,6 +80,10 @@ void AddressBar::setView(QWebEngineView *view) progressBar->setValue(100); progressBarConnection = connect(view, &QWebEngineView::loadProgress, progressBar, &QProgressBar::setValue); + + focusConnection = connect(urlBar, &UrlLineEdit::focusView, view, [view]() { + view->setFocus(); + }); } void AddressBar::setPageMenu(QMenu *menu) diff --git a/lib/addressbar/addressbar.h b/lib/addressbar/addressbar.h index 861f985..d035d8d 100644 --- a/lib/addressbar/addressbar.h +++ b/lib/addressbar/addressbar.h @@ -39,6 +39,7 @@ private: QMetaObject::Connection urlChangedConnection, loadUrlConnection; QMetaObject::Connection progressBarConnection; + QMetaObject::Connection focusConnection; }; #endif // SMOLBOTE_ADDRESSBAR_H diff --git a/lib/addressbar/urllineedit.cpp b/lib/addressbar/urllineedit.cpp index 79d7bf8..21f88eb 100644 --- a/lib/addressbar/urllineedit.cpp +++ b/lib/addressbar/urllineedit.cpp @@ -113,6 +113,7 @@ void UrlLineEdit::focusOutEvent(QFocusEvent *event) if(url.isValid()) setUrl(url); + emit focusView(); QLineEdit::focusOutEvent(event); } diff --git a/lib/addressbar/urllineedit.h b/lib/addressbar/urllineedit.h index f28983d..2198a0e 100644 --- a/lib/addressbar/urllineedit.h +++ b/lib/addressbar/urllineedit.h @@ -27,6 +27,9 @@ public slots: void updateCompleter(const QStringList &l); +signals: + void focusView(); + public: QAction *menuAction = nullptr; // pageMenu action: zoom, print |