From: Soren Stoutner Date: Fri, 12 Aug 2022 22:00:44 +0000 (-0700) Subject: Clear the focus of the URL line edit when opening a new tab from the context menu... X-Git-Tag: v0.1~16 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=8689d74c8a97cbeb81b69bed8e195ed68bca2ee1;p=PrivacyBrowserPC.git Clear the focus of the URL line edit when opening a new tab from the context menu so that it will populate correctly. --- diff --git a/src/widgets/PrivacyWebEngineView.cpp b/src/widgets/PrivacyWebEngineView.cpp index 10bff6d..ba56d31 100644 --- a/src/widgets/PrivacyWebEngineView.cpp +++ b/src/widgets/PrivacyWebEngineView.cpp @@ -49,8 +49,9 @@ QWebEngineView* PrivacyWebEngineView::createWindow(QWebEnginePage::WebWindowType // Create the requsted window type. switch (webWindowType) { case QWebEnginePage::WebBrowserTab: { - // Create the new tab and return the privacy WebEngine view pointer. It will then be populated with the link from the context menu. - return browserWindowPointer->tabWidgetPointer->addTab(); + // Create the new tab and return the privacy WebEngine view pointer. `true` removes the focus from the blank URL line edit. + // The new privacy WebEngine view pointer is returned so it can be populated with the link from the context menu. + return browserWindowPointer->tabWidgetPointer->addTab(true); } default: { diff --git a/src/widgets/TabWidget.cpp b/src/widgets/TabWidget.cpp index ba12f04..9e843ef 100644 --- a/src/widgets/TabWidget.cpp +++ b/src/widgets/TabWidget.cpp @@ -141,7 +141,7 @@ void TabWidget::addFirstTab() tabWidgetPointer->currentWidget()->setFocus(); } -PrivacyWebEngineView* TabWidget::addTab() +PrivacyWebEngineView* TabWidget::addTab(const bool focusNewWebEngineView) { // Create a privacy WebEngine view. PrivacyWebEngineView *privacyWebEngineViewPointer = new PrivacyWebEngineView(); @@ -290,6 +290,10 @@ PrivacyWebEngineView* TabWidget::addTab() // Move to the new tab. tabWidgetPointer->setCurrentIndex(newTabIndex); + // Clear the URL line edit focus so that it populates correctly when opening a new tab from the context menu. + if (focusNewWebEngineView) + emit clearUrlLineEditFocus(); + // Return the privacy WebEngine view pointer. return privacyWebEngineViewPointer; } diff --git a/src/widgets/TabWidget.h b/src/widgets/TabWidget.h index 2b63a63..6a24313 100644 --- a/src/widgets/TabWidget.h +++ b/src/widgets/TabWidget.h @@ -84,8 +84,8 @@ signals: public Q_SLOTS: // The public slots. - PrivacyWebEngineView* addTab(); void addCookieToStore(QNetworkCookie cookie, QWebEngineCookieStore *webEngineCookieStorePointer = nullptr) const; + PrivacyWebEngineView* addTab(const bool focusNewWebEngineView=false); void applyApplicationSettings(); void applyDomainSettingsAndReload(); void applyDomainSettingsWithoutReloading(const QString &hostname);