From c4d97d832bee256781bc20bb8b5c2f7bf78d7744 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Fri, 9 Jun 2023 14:46:56 -0700 Subject: [PATCH] Add Reload and Bypass Cache. https://redmine.stoutner.com/issues/982 --- src/ui.rcs/browserwindowui.rc | 9 +++++++-- src/widgets/TabWidget.cpp | 7 +++++++ src/widgets/TabWidget.h | 1 + src/windows/BrowserWindow.cpp | 15 +++++++++++++++ src/windows/BrowserWindow.h | 1 + 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/ui.rcs/browserwindowui.rc b/src/ui.rcs/browserwindowui.rc index 12eb32d..d296881 100644 --- a/src/ui.rcs/browserwindowui.rc +++ b/src/ui.rcs/browserwindowui.rc @@ -32,8 +32,13 @@ - - + + + + + + + diff --git a/src/widgets/TabWidget.cpp b/src/widgets/TabWidget.cpp index 0a7b3ca..7ca5434 100644 --- a/src/widgets/TabWidget.cpp +++ b/src/widgets/TabWidget.cpp @@ -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. diff --git a/src/widgets/TabWidget.h b/src/widgets/TabWidget.h index ea9efe5..57082e0 100644 --- a/src/widgets/TabWidget.h +++ b/src/widgets/TabWidget.h @@ -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. diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index c2497aa..fac3235 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -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. diff --git a/src/windows/BrowserWindow.h b/src/windows/BrowserWindow.h index beb3f03..44486d9 100644 --- a/src/windows/BrowserWindow.h +++ b/src/windows/BrowserWindow.h @@ -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; -- 2.43.0