]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Implement loading of new tabs from the context menu.
authorSoren Stoutner <soren@stoutner.com>
Fri, 12 Aug 2022 21:43:17 +0000 (14:43 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 12 Aug 2022 21:43:17 +0000 (14:43 -0700)
src/uis/TabWidget.ui
src/widgets/PrivacyWebEngineView.cpp
src/widgets/PrivacyWebEngineView.h
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.h

index 3da43c069a685ca8a2971065395ad0b1818afd0f..2aad7efd4d8b1e9bd860285b043e76a60f73d6ba 100644 (file)
@@ -52,8 +52,8 @@
 
                     <property name="iconSize">
                         <size>
-                            <width>24</width>
                             <height>24</height>
+                            <width>24</width>
                         </size>
                     </property>
 
index 28fb66da18f32d7b66420a3cf361b960b873f0d9..10bff6d14554f45a2d922d4a1ae831e935705637 100644 (file)
@@ -20,6 +20,7 @@
 // Application headers.
 #include "PrivacyWebEngineView.h"
 #include "databases/CookiesDatabase.h"
+#include "windows/BrowserWindow.h"
 
 // Construct the class.
 PrivacyWebEngineView::PrivacyWebEngineView() : QWebEngineView(nullptr) {}
@@ -39,6 +40,26 @@ void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const
     emit updateCookiesAction(cookieListPointer->size());
 }
 
+QWebEngineView* PrivacyWebEngineView::createWindow(QWebEnginePage::WebWindowType webWindowType) {
+    qDebug().noquote().nospace() << "Web window type:  " << webWindowType;
+
+    // Get a handle for the browser window.
+    BrowserWindow *browserWindowPointer = qobject_cast<BrowserWindow*>(window());
+
+    // 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();
+        }
+
+        default: {
+            // Return an null pointer.
+            return nullptr;
+        }
+    }
+}
+
 void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const
 {
     //qDebug() << "Remove cookie:  " << cookie.toRawForm();
index 3869fc34ac2d938f6b150b3bf3be5ff76462f351..8a049576438953b23d72852889b97354c17d17b5 100644 (file)
@@ -46,5 +46,9 @@ public Q_SLOTS:
     // The public slots.
     void addCookieToList(const QNetworkCookie &cookie) const;
     void removeCookieFromList(const QNetworkCookie &cookie) const;
+
+protected:
+    // The protected functions.
+    QWebEngineView* createWindow(QWebEnginePage::WebWindowType webWindowType) override;
 };
 #endif
index 59e424331fd78643d2ae7927a56c87239ee300ff..ba12f042d4076bc1cc0bb7e679e47f79f7c15e25 100644 (file)
@@ -141,7 +141,7 @@ void TabWidget::addFirstTab()
     tabWidgetPointer->currentWidget()->setFocus();
 }
 
-void TabWidget::addTab()
+PrivacyWebEngineView* TabWidget::addTab()
 {
     // Create a privacy WebEngine view.
     PrivacyWebEngineView *privacyWebEngineViewPointer = new PrivacyWebEngineView();
@@ -168,7 +168,6 @@ void TabWidget::addTab()
     // Update the URL line edit when the URL changes.
     connect(privacyWebEngineViewPointer, SIGNAL(urlChanged(const QUrl)), this, SLOT(updateUrl(const QUrl)));
 
-
     // Update the progress bar.
     connect(privacyWebEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
     connect(privacyWebEngineViewPointer, SIGNAL(loadProgress(const int)), this, SLOT(loadProgress(const int)));
@@ -290,6 +289,9 @@ void TabWidget::addTab()
 
     // Move to the new tab.
     tabWidgetPointer->setCurrentIndex(newTabIndex);
+
+    // Return the privacy WebEngine view pointer.
+    return privacyWebEngineViewPointer;
 }
 
 void TabWidget::applyApplicationSettings()
index 525c81a291c170edb3342156f60251ec2fe8fcff..2b63a63203bc9d11dd95db59ebce45ef8f7adcfd 100644 (file)
@@ -84,7 +84,7 @@ signals:
 
 public Q_SLOTS:
     // The public slots.
-    void addTab();
+    PrivacyWebEngineView* addTab();
     void addCookieToStore(QNetworkCookie cookie, QWebEngineCookieStore *webEngineCookieStorePointer = nullptr) const;
     void applyApplicationSettings();
     void applyDomainSettingsAndReload();
index 39b8e8f5ea7e0caffacf2aa67a8706f77f7768f7..f880cc8f4903b2b63beea736f7614dc4fb3e4fb4 100644 (file)
@@ -45,6 +45,9 @@ public:
     // The public functions.
     QSize sizeHint() const override;
 
+    // The public variables.
+    TabWidget *tabWidgetPointer;
+
 private Q_SLOTS:
     // The private slots.
     void addOrEditDomainSettings() const;
@@ -107,7 +110,6 @@ private:
     QAction *searchEngineBingActionPointer;
     QAction *searchEngineYahooActionPointer;
     QAction *searchEngineCustomActionPointer;
-    TabWidget *tabWidgetPointer;
     QLabel *userAgentLabelPointer;
     QAction *userAgentMenuActionPointer;
     QAction *userAgentPrivacyBrowserActionPointer;