]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Clear the focus of the URL line edit when opening a new tab from the context menu...
authorSoren Stoutner <soren@stoutner.com>
Fri, 12 Aug 2022 22:00:44 +0000 (15:00 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 12 Aug 2022 22:00:44 +0000 (15:00 -0700)
src/widgets/PrivacyWebEngineView.cpp
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h

index 10bff6d14554f45a2d922d4a1ae831e935705637..ba56d31d76c6827f9b3e1e60927c756f9ed4e896 100644 (file)
@@ -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: {
index ba12f042d4076bc1cc0bb7e679e47f79f7c15e25..9e843ef306da564f362d7c5e434a0589b7dda21d 100644 (file)
@@ -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;
 }
index 2b63a63203bc9d11dd95db59ebce45ef8f7adcfd..6a24313b74561389ab87b35f1b1478554a7802e7 100644 (file)
@@ -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);