]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Add Reload and Bypass Cache. https://redmine.stoutner.com/issues/982
authorSoren Stoutner <soren@stoutner.com>
Fri, 9 Jun 2023 21:46:56 +0000 (14:46 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 9 Jun 2023 21:46:56 +0000 (14:46 -0700)
src/ui.rcs/browserwindowui.rc
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index 12eb32d72ab4a6fd2e01bdc3ca58f3717a316eac..d296881739b7ea18f9c5775252b7b08cc9e66ebe 100644 (file)
     <MenuBar>
         <!-- File. -->
         <Menu name="file">
-            <Action name="new_tab" append="new_merge"/>
-            <Action name="new_window" append="new_merge"/>
+            <Action name="new_tab" append="new_merge" />
+            <Action name="new_window" append="new_merge" />
+        </Menu>
+
+        <!-- View. -->
+        <Menu name="view">
+            <Action name="reload_and_bypass_cache" />
         </Menu>
 
         <!-- On-the-fly Settings. -->
index 0a7b3ca1d458ae6d0b97d735545f1fd5bfdcc28c..7ca54342638d460692eb64627a70c401c41869d9 100644 (file)
@@ -828,6 +828,13 @@ void TabWidget::refresh() const
     currentPrivacyWebEngineViewPointer->reload();
 }
 
+void TabWidget::reloadAndBypassCache() const
+{
+    // Reload the website, bypassing the cache.
+    currentWebEnginePagePointer->triggerAction(QWebEnginePage::ReloadAndBypassCache);
+}
+
+
 void TabWidget::setTabBarVisible(const bool visible) const
 {
     // Set the tab bar visibility.
index ea9efe52048ecb63f6e6be8e35c90b54f0166bf9..57082e0ffa4fd5abc40449881f6116065eaaee74 100644 (file)
@@ -111,6 +111,7 @@ public Q_SLOTS:
     void print() const;
     void printPreview() const;
     void refresh() const;
+    void reloadAndBypassCache() const;
 
 private Q_SLOTS:
     // The private slots.
index c2497aa3f94cff825b2589158fc999d87c7db407..fac3235dd69b1fc13e02fa762f07d25ebb171273 100644 (file)
@@ -75,6 +75,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // Add the custom actions.
     QAction *newTabActionPointer = actionCollectionPointer->addAction(QLatin1String("new_tab"));
     QAction *newWindowActionPointer = actionCollectionPointer->addAction(QLatin1String("new_window"));
+    QAction *reloadAndBypassCacheActionPointer = actionCollectionPointer->addAction(QLatin1String("reload_and_bypass_cache"));
     userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_privacy_browser"));
     userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_webengine_default"));
     userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_linux"));
@@ -150,6 +151,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // Set the action text.
     newTabActionPointer->setText(i18nc("New tab action", "New Tab"));
     newWindowActionPointer->setText(i18nc("New window action", "New Window"));
+    reloadAndBypassCacheActionPointer->setText(i18nc("Reload and bypass cache action", "Reload and Bypass Cache"));
     userAgentPrivacyBrowserActionPointer->setText(userAgentHelperPointer->PRIVACY_BROWSER_TRANSLATED);
     userAgentWebEngineDefaultActionPointer->setText(userAgentHelperPointer->WEB_ENGINE_DEFAULT_TRANSLATED);
     userAgentFirefoxLinuxActionPointer->setText(userAgentHelperPointer->FIREFOX_LINUX_TRANSLATED);
@@ -176,6 +178,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // The toolbar icons don't pick up unless the size is explicit, probably because the toolbar ends up being an intermediate size.
     newTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("tab-new")));
     newWindowActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-new")));
+    reloadAndBypassCacheActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-refresh")));
     userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode.svg"));
     userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"),
                                                                                                                QIcon::fromTheme(QLatin1String("contact-new")))));
@@ -207,6 +210,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // Create the key sequences.
     QKeySequence ctrlTKeySequence = QKeySequence(i18nc("The open new tab key sequence.", "Ctrl+T"));
     QKeySequence ctrlNKeySequence = QKeySequence(i18nc("The open new window key sequence.", "Ctrl+N"));
+    QKeySequence ctrlF5KeySequence = QKeySequence(i18nc("The reload and bypass cache key sequence.", "Ctrl+F5"));
     QKeySequence ctrlShiftPKeySequence = QKeySequence(i18nc("The print preview key sequence.", "Ctrl+Shift+P"));
     QKeySequence ctrlAltPKeySequence = QKeySequence(i18nc("The Privacy Browser user agent key sequence.", "Ctrl+Alt+P"));
     QKeySequence ctrlAltWKeySequence = QKeySequence(i18nc("The WebEngine Default user agent key sequence.", "Ctrl+Alt+W"));
@@ -231,6 +235,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // Set the action key sequences.
     actionCollectionPointer->setDefaultShortcut(newTabActionPointer, ctrlTKeySequence);
     actionCollectionPointer->setDefaultShortcut(newWindowActionPointer, ctrlNKeySequence);
+    actionCollectionPointer->setDefaultShortcut(reloadAndBypassCacheActionPointer, ctrlF5KeySequence);
     actionCollectionPointer->setDefaultShortcut(printPreviewActionPointer, ctrlShiftPKeySequence);
     actionCollectionPointer->setDefaultShortcut(userAgentPrivacyBrowserActionPointer, ctrlAltPKeySequence);
     actionCollectionPointer->setDefaultShortcut(userAgentWebEngineDefaultActionPointer, ctrlAltWKeySequence);
@@ -255,6 +260,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // Execute the actions.
     connect(newTabActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(addTab()));
     connect(newWindowActionPointer, SIGNAL(triggered()), this, SLOT(newWindow()));
+    connect(reloadAndBypassCacheActionPointer, SIGNAL(triggered()), this, SLOT(reloadAndBypassCache()));
     connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser()));
     connect(cookiesActionPointer, SIGNAL(triggered()), this, SLOT(showCookiesDialog()));
     connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(showDomainSettingsDialog()));
@@ -635,6 +641,15 @@ void BrowserWindow::refresh() const
     tabWidgetPointer->refresh();
 }
 
+void BrowserWindow::reloadAndBypassCache() const
+{
+    // Remove the focus from the URL line edit.
+    urlLineEditPointer->clearFocus();
+
+    // Refresh the web page.
+    tabWidgetPointer->refresh();
+}
+
 void BrowserWindow::showCookiesDialog()
 {
     // Remove the focus from the URL line edit.
index beb3f03024251c957fa554a5200c32c4b18dec82..44486d945c2e2c0e941959afcb5f6f7aeee695fc 100644 (file)
@@ -64,6 +64,7 @@ private Q_SLOTS:
     void loadUrlFromLineEdit(const QString &url) const;
     void newWindow() const;
     void refresh() const;
+    void reloadAndBypassCache() const;
     void showCookiesDialog();
     void showDownloadLocationBrowseDialog() const;
     void showDomainSettingsDialog() const;