]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Open the developer console using half the available space. https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Thu, 15 May 2025 22:03:01 +0000 (15:03 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 15 May 2025 22:03:01 +0000 (15:03 -0700)
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h

index fc01862c1a83d5e0af4b31834fcefa365fc9c979..4f89cb3c8be9d4fabc204f5d968a1dc01178f31d 100644 (file)
@@ -43,7 +43,6 @@
 #include <QPrintDialog>
 #include <QPrintPreviewDialog>
 #include <QPrinter>
-#include <QSplitter>
 
 // Initialize the public static variables.
 QString TabWidget::webEngineDefaultUserAgent = QLatin1String("");
@@ -181,7 +180,7 @@ void TabWidget::addFirstTab()
 PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool adjacent, const bool backgroundTab, const QString urlString)
 {
     // Create a splitter widget.
-    QSplitter *splitterPointer = new QSplitter();
+    splitterPointer = new QSplitter();
 
     // Set the splitter to be vertical.
     splitterPointer->setOrientation(Qt::Vertical);
@@ -215,7 +214,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     QWebEngineCookieStore *webEngineCookieStorePointer = webEngineProfilePointer->cookieStore();
     QWebEngineSettings *webEngineSettingsPointer = webEnginePagePointer->settings();
 
-    // Set the development tools WebEngine.  This must be done here to preserve the bottom half of the window as the initial development tools size.
+    // Set the development tools WebEngine.
     webEnginePagePointer->setDevToolsPage(devToolsWebEngineViewPointer->page());
 
     // Initially hide the development tools WebEngine.
@@ -243,7 +242,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Update the title when it changes.
-    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this, splitterPointer] (const QString &title)
+    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this] (const QString &title)
     {
         // Get the index for this tab.
         int tabIndex = qTabWidgetPointer->indexOf(splitterPointer);
@@ -257,7 +256,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Connect the loading favorite icon movie to the tab icon.
-    connect(loadingFavoriteIconMoviePointer, &QMovie::frameChanged, [this, splitterPointer, privacyWebEngineViewPointer]
+    connect(loadingFavoriteIconMoviePointer, &QMovie::frameChanged, [this, privacyWebEngineViewPointer]
     {
         // Get the index for this tab.
         int tabIndex = qTabWidgetPointer->indexOf(splitterPointer);
@@ -268,7 +267,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Update the icon when it changes.
-    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [this, splitterPointer, privacyWebEngineViewPointer] (const QIcon &newFavoriteIcon)
+    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [this, privacyWebEngineViewPointer] (const QIcon &newFavoriteIcon)
     {
         // Store the favorite icon in the privacy web engine view.
         if (newFavoriteIcon.isNull())
@@ -315,7 +314,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Update the progress bar when a load finishes.
-    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadFinished, [this, splitterPointer, privacyWebEngineViewPointer] ()
+    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadFinished, [this, privacyWebEngineViewPointer] ()
     {
         // Set the privacy web engine view to be not loading.
         privacyWebEngineViewPointer->isLoading = false;
@@ -452,7 +451,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     // Plugins must be enabled for the PDF viewer to work.  <https://doc.qt.io/qt-5/qtwebengine-features.html#pdf-file-viewing>
     webEngineSettingsPointer->setAttribute(QWebEngineSettings::PluginsEnabled, true);
 
-    // Allow JavaScript to paste to (but not copy from) the clipboard with user interaction.
+    // Allow JavaScript to paste to (but not copy from) the clipboard, but only with user interaction.
     webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, true);
 
     // Update the blocked requests action.
@@ -1173,6 +1172,9 @@ void TabWidget::toggleDeveloperTools(const bool enabled) const
 
         // Display the developer tools.
         devToolsWebEngineViewPointer->setVisible(true);
+
+        // Split the visible space equally between the main WebEngine and the developer tools WebEngine.
+        splitterPointer->setSizes(QList<int>({1, 1}));
     }
     else
     {
index 9bb21839cb9ccbe5db7d3929d76ea9c081ef49c7..9b8dc5c3e6b6978f39fc223791419443318549b6 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
@@ -30,6 +30,7 @@
 // Qt toolkit headers.
 #include <QMovie>
 #include <QPushButton>
+#include <QSplitter>
 #include <QTabWidget>
 #include <QWebEngineCookieStore>
 #include <QWebEngineFullScreenRequest>
@@ -166,6 +167,7 @@ private:
     QTabWidget *qTabWidgetPointer;
     bool savingArchive;
     QString searchEngineUrl;
+    QSplitter *splitterPointer;
     UserAgentHelper *userAgentHelperPointer;
     bool wipingCurrentFindTextSelection = false;
 };