]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/windows/BrowserWindow.cpp
Add Reload and Bypass Cache. https://redmine.stoutner.com/issues/982
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.cpp
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.