]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Add an stop action. https://redmine.stoutner.com/issues/1141
authorSoren Stoutner <soren@stoutner.com>
Tue, 26 Dec 2023 22:28:24 +0000 (15:28 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 26 Dec 2023 22:28:24 +0000 (15:28 -0700)
src/ui.rcs/browserwindowui.rc
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index f16913b6f2927149e10a42ee2f729f9eeb0bb0ca..9953db69321e31b9dcd73dd439532a1f62ce945e 100644 (file)
@@ -43,6 +43,7 @@
             <Action name="zoom_default" append="view_zoom_merge" />
 
             <Action name="reload_and_bypass_cache" />
+            <Action name="stop" />
 
             <Separator />
 
         <Action name="go_back" />
         <Action name="go_forward" />
         <Action name="view_redisplay" />
+        <Action name="stop" />
         <Action name="go_home" />
     </ToolBar>
 
index eb923336797868fd23e95206c1f20d7e2b6ccae2..a8f59b4800e6671ad167a3319574773c80c6c094 100644 (file)
@@ -1104,6 +1104,12 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin
     savingArchive = false;
 }
 
+void TabWidget::stop() const
+{
+    // Stop the loading of the current privacy WebEngine.
+    currentPrivacyWebEngineViewPointer->stop();
+}
+
 void TabWidget::toggleDeveloperTools(const bool enabled) const
 {
     // Get a handle for the current developer tools WebEngine.
index 5b9f2f9fe9de7d4a8f311ac5a282ce2cd7014a27..4cbfe97eb5bcd92cbf25f7055666f64fc5e2a704 100644 (file)
@@ -119,6 +119,7 @@ public Q_SLOTS:
     void refresh() const;
     void reloadAndBypassCache() const;
     void saveArchive();
+    void stop() const;
 
 private Q_SLOTS:
     // The private slots.
index 2eb4ab14fab687edc954e65d421be2beed5de5f2..99fc2fac5f92d8f9a3d628d678443426ac822e26 100644 (file)
@@ -77,7 +77,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
     zoomInActionPointer = KStandardAction::zoomIn(this, SLOT(incrementZoom()), actionCollectionPointer);
     zoomOutActionPointer = KStandardAction::zoomOut(this, SLOT(decrementZoom()), actionCollectionPointer);
-    KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer);
+    refreshActionPointer = KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer);
     fullScreenActionPointer = KStandardAction::fullScreen(this, SLOT(toggleFullScreen()), this, actionCollectionPointer);
     QAction *backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer);
     QAction *forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer);
@@ -94,6 +94,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     QAction *saveArchiveActionPointer = actionCollectionPointer->addAction(QLatin1String("save_archive"));
     zoomDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("zoom_default"));
     QAction *reloadAndBypassCacheActionPointer = actionCollectionPointer->addAction(QLatin1String("reload_and_bypass_cache"));
+    stopActionPointer = actionCollectionPointer->addAction(QLatin1String("stop"));
     viewSourceActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source"));
     viewSourceInNewTabActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source_in_new_tab"));
     developerToolsActionPointer = actionCollectionPointer->addAction(QLatin1String("developer_tools"));
@@ -179,6 +180,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     saveArchiveActionPointer->setText(i18nc("Save archive action", "Save Archive"));
     zoomDefaultActionPointer->setText(i18nc("Zoom default action", "Zoom Default"));
     reloadAndBypassCacheActionPointer->setText(i18nc("Reload and bypass cache action", "Reload and Bypass Cache"));
+    stopActionPointer->setText(i18nc("Stop action", "Stop"));
     viewSourceActionPointer->setText(i18nc("View source action", "View Source"));
     viewSourceInNewTabActionPointer->setText(i18nc("View source in new tab action", "View Source in New Tab"));
     developerToolsActionPointer->setText(i18nc("Developer tools action", "Developer Tools"));
@@ -212,12 +214,14 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     saveArchiveActionPointer->setIcon(QIcon::fromTheme(QLatin1String("document-save")));
     zoomDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("zoom-fit-best")));
     reloadAndBypassCacheActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-refresh")));
+    stopActionPointer->setIcon(QIcon::fromTheme(QLatin1String("process-stop")));
     viewSourceActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-choose"), QIcon::fromTheme(QLatin1String("accessories-text-editor"))));
     viewSourceInNewTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-choose"), QIcon::fromTheme(QLatin1String("accessories-text-editor"))));
     developerToolsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("add-subtitle"), QIcon::fromTheme("system-run")));
     domStorageActionPointer->setIcon(QIcon::fromTheme(QLatin1String("code-class"), QIcon(QLatin1String("/usr/share/icons/gnome/32x32/actions/gtk-unindent-ltr.png"))));
-    userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode.svg"));
-    userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new")))));
+    userAgentPrivacyBrowserActionPointer->setIcon(QIcon(QLatin1String(":/icons/privacy-mode.svg")));
+    userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"),
+                                                                                                               QIcon::fromTheme(QLatin1String("contact-new")))));
     userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr"), QIcon::fromTheme(QLatin1String("user-group-properties"),
                                                                                                                 QIcon::fromTheme(QLatin1String("contact-new")))));
     userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium"), QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new")))));
@@ -248,6 +252,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     QKeySequence ctrlAKeySequence = QKeySequence(i18nc("The save archive key sequence.", "Ctrl+A"));
     QKeySequence ctrl0KeySequence = QKeySequence(i18nc("The zoom default key sequence.", "Ctrl+0"));
     QKeySequence ctrlF5KeySequence = QKeySequence(i18nc("The reload and bypass cache key sequence.", "Ctrl+F5"));
+    QKeySequence ctrlShiftXKeySequence = QKeySequence(i18nc("The stop key sequence.", "Ctrl+Shift+X"));
     QKeySequence ctrlUKeySequence = QKeySequence(i18nc("The view source key sequence.", "Ctrl+U"));
     QKeySequence ctrlShiftUKeySequence = QKeySequence(i18nc("The view source in new tab key sequence.", "Ctrl+Shift+U"));
     QKeySequence f12KeySequence = QKeySequence(i18nc("The developer tools key sequence.", "F12"));
@@ -284,6 +289,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     actionCollectionPointer->setDefaultShortcut(saveArchiveActionPointer, ctrlAKeySequence);
     actionCollectionPointer->setDefaultShortcut(zoomDefaultActionPointer, ctrl0KeySequence);
     actionCollectionPointer->setDefaultShortcut(reloadAndBypassCacheActionPointer, ctrlF5KeySequence);
+    actionCollectionPointer->setDefaultShortcut(stopActionPointer, ctrlShiftXKeySequence);
     actionCollectionPointer->setDefaultShortcut(viewSourceActionPointer, ctrlUKeySequence);
     actionCollectionPointer->setDefaultShortcut(viewSourceInNewTabActionPointer, ctrlShiftUKeySequence);
     actionCollectionPointer->setDefaultShortcut(developerToolsActionPointer, f12KeySequence);
@@ -320,6 +326,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     connect(saveArchiveActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(saveArchive()));
     connect(zoomDefaultActionPointer, SIGNAL(triggered()), this, SLOT(zoomDefault()));
     connect(reloadAndBypassCacheActionPointer, SIGNAL(triggered()), this, SLOT(reloadAndBypassCache()));
+    connect(stopActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(stop()));
     connect(viewSourceActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewSource()));
     connect(viewSourceInNewTabActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewSourceInNewTab()));
     connect(developerToolsActionPointer, SIGNAL(triggered()), this, SLOT(toggleDeveloperTools()));
@@ -501,7 +508,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
 
     // Update the progress bar.
     connect(tabWidgetPointer, SIGNAL(showProgressBar(const int)), this, SLOT(showProgressBar(const int)));
-    connect(tabWidgetPointer, SIGNAL(hideProgressBar()), progressBarPointer, SLOT(hide()));
+    connect(tabWidgetPointer, SIGNAL(hideProgressBar()), this, SLOT(hideProgressBar()));
 
     // Update the URL line edit focus.
     connect(tabWidgetPointer, SIGNAL(clearUrlLineEditFocus()), this, SLOT(clearUrlLineEditFocus()));
@@ -979,6 +986,20 @@ void BrowserWindow::home() const
     tabWidgetPointer->home();
 }
 
+void BrowserWindow::hideProgressBar() const
+{
+    // Hide the progress bar.
+    progressBarPointer->hide();
+
+    // Disable and hide the stop action.
+    stopActionPointer->setEnabled(false);
+    stopActionPointer->setVisible(false);
+
+    // Enable and show the refresh action.
+    refreshActionPointer->setEnabled(true);
+    refreshActionPointer->setVisible(true);
+}
+
 void BrowserWindow::incrementZoom()
 {
     // Update the current zoom factor.
@@ -1489,6 +1510,14 @@ void BrowserWindow::showProgressBar(const int &progress) const
 
     // Show the progress bar.
     progressBarPointer->show();
+
+    // Disable and hide the refresh action.
+    refreshActionPointer->setEnabled(false);
+    refreshActionPointer->setVisible(false);
+
+    // Enable and show the stop action.
+    stopActionPointer->setEnabled(true);
+    stopActionPointer->setVisible(true);
 }
 
 void BrowserWindow::showSettingsDialog()
index e62b7b29c9b338a8f96981865f24b04bb1e95cf8..87297dc12347deebf7476ca6ca82bc46a3733ad8 100644 (file)
@@ -67,6 +67,7 @@ private Q_SLOTS:
     void fullScreenRequested(const bool toggleOn);
     void getZoomFactorFromUser();
     void hideFindTextActions() const;
+    void hideProgressBar() const;
     void home() const;
     void incrementZoom();
     void loadUrlFromLineEdit(const QString &url) const;
@@ -152,6 +153,7 @@ private:
     QPalette normalBackgroundPalette;
     QPalette positiveBackgroundPalette;
     QProgressBar *progressBarPointer;
+    QAction *refreshActionPointer;
     QLabel *searchEngineLabelPointer;
     QAction *searchEngineMenuActionPointer;
     QAction *searchEngineMojeekActionPointer;
@@ -161,6 +163,7 @@ private:
     QAction *searchEngineBingActionPointer;
     QAction *searchEngineYahooActionPointer;
     QAction *searchEngineCustomActionPointer;
+    QAction *stopActionPointer;
     QLabel *userAgentLabelPointer;
     QAction *userAgentMenuActionPointer;
     QAction *userAgentPrivacyBrowserActionPointer;