]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Add a forward and back history. https://redmine.stoutner.com/issues/1098 master
authorSoren Stoutner <soren@stoutner.com>
Tue, 30 Jun 2026 21:51:27 +0000 (14:51 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 30 Jun 2026 21:51:27 +0000 (14:51 -0700)
src/widgets/PrivacyWebEnginePage.cpp
src/widgets/PrivacyWebEnginePage.h
src/widgets/PrivacyWebEngineView.cpp
src/widgets/PrivacyWebEngineView.h
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index b2fec02f605feeb779b2e030e64d281ef44c2d03..e89ecdb35384a795866daca9fed05ca4cb339f12 100644 (file)
@@ -1,25 +1,25 @@
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024, 2026 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
- * Privacy Browser PC is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
  *
- * Privacy Browser PC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 // Application headers.
 #include "PrivacyWebEnginePage.h"
 
 // Construct the class.
-PrivacyWebEnginePage::PrivacyWebEnginePage(QWebEngineProfile *webEngineProfilePointer, QObject *parentObjectPointer) : QWebEnginePage(webEngineProfilePointer, parentObjectPointer) {}
-
+PrivacyWebEnginePage::PrivacyWebEnginePage(QWebEngineProfile *webEngineProfilePointer, QObject *parentObjectPointer) :
+                                           QWebEnginePage(webEngineProfilePointer, parentObjectPointer) {}
index 9880b0bc185ed9616b92bbff962449cf63ff5db5..07a300f92fe2fe0caac601d1f9dcafc898165053 100644 (file)
@@ -1,20 +1,20 @@
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024, 2026 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
- * Privacy Browser PC is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
  *
- * Privacy Browser PC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef PRIVACY_WEBENGINE_PAGE_H
@@ -29,9 +29,7 @@ class PrivacyWebEnginePage : public QWebEnginePage
     Q_OBJECT
 
 public:
-    // The default constructor.
+    // The primary constructor.
     explicit PrivacyWebEnginePage(QWebEngineProfile *webEngineProfilePointer, QObject *parentObjectPointer = nullptr);
-
-//protected:
 };
 #endif
index 298cdb969b846273647a225fccd81b0c332f0468..3ad936b8e17272af9e7f6e3c0497fb15ae25ac34 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2026 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
@@ -73,6 +73,9 @@ PrivacyWebEngineView::PrivacyWebEngineView(QWidget *parentWidgetPointer) : QWebE
 
     // Store the URL when it changes.
     connect(this, SIGNAL(urlChanged(const QUrl&)), this, SLOT(storeUpdatedUrl(const QUrl&)));
+
+    // Update the favorite icon when it is received.
+    connect(this, SIGNAL(iconChanged(const QIcon&)), this, SLOT(processFavoriteIcon(const QIcon&)));
 }
 
 void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const
@@ -238,7 +241,8 @@ void PrivacyWebEngineView::applyDomainSettings(const QUrl &newUrl, const bool na
     Q_EMIT updateUi(this);
 
     // Reload the URL.
-    // This works around a bug in Qt WebEngine that causes massive problems when the user agent is changed after the page has started pre-rendering.  <https://redmine.stoutner.com/issues/821>
+    // This works around a bug in Qt WebEngine that causes massive problems when the user agent is changed after the page has started pre-rendering.
+    // <https://redmine.stoutner.com/issues/821>
     if (navigatingHistory)
     {
         // Get a handle for the WebEngine history.
@@ -436,6 +440,21 @@ void PrivacyWebEngineView::displayHttpPingDialog(const QString &httpPingUrl) con
     Q_EMIT displayHttpPingBlockedDialog(httpPingUrl);
 }
 
+QIcon PrivacyWebEngineView::getFavoriteIcon(const QString &favoriteIconUrlString)
+{
+    // Check if the favorite icons map already contains the favorite icon.
+    if (favoriteIconsMap.contains(favoriteIconUrlString))  // The favorite icons map already contains the icon.
+    {
+        // Return the favorite icon.
+        return favoriteIconsMap.value(favoriteIconUrlString);
+    }
+    else  // The favorite icons map does not contain the icon.
+    {
+        // Return the default favorite icon.
+        return defaultFavoriteIcon;
+    }
+}
+
 void PrivacyWebEngineView::handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer)
 {
     // Only display the HTTP authentication dialog if it hasn't already been displayed three times for this URL.
@@ -472,6 +491,21 @@ void PrivacyWebEngineView::openWithFirefox() const
     QProcess::startDetached(QLatin1String("firefox-esr"), QStringList(hoveredLinkString));
 }
 
+void PrivacyWebEngineView::processFavoriteIcon(const QIcon &newFavoriteIcon)
+{
+    // Store the favorite icon in the privacy WebEngine view.  It is used when creating bookmarks.
+    if (newFavoriteIcon.isNull())
+        favoriteIcon = defaultFavoriteIcon;
+    else
+        favoriteIcon = newFavoriteIcon;
+
+    // Add the icon to the favorite icons map if it doesn't already exist.  These are used for populating the forward and back icons.
+    if (!favoriteIconsMap.contains(currentUrlString))
+        favoriteIconsMap.insert(currentUrlString, favoriteIcon);
+
+    Q_EMIT favoriteIconChanged(favoriteIcon);
+}
+
 void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const
 {
     //qDebug() << "Remove cookie:  " << cookie.toRawForm();
@@ -519,7 +553,7 @@ void PrivacyWebEngineView::storeRequest(RequestStruct *requestStructPointer)
 
 void PrivacyWebEngineView::storeUpdatedUrl(const QUrl &newUrl)
 {
-    // Store the new URL string (which changes when a new page is loaded as the current URL text.  This is important when loading a new tab from a link.  <https://redmine.stoutner.com/issues/1228>
-    currentUrlText = newUrl.toString();
+    // Store the new URL string.  This is important when loading a new tab from a link.  <https://redmine.stoutner.com/issues/1228>
+    currentUrlString = newUrl.toString();
 }
 
index 984d972b948f72af5bbae1d4f63981c7dc564457..e3c2b26e78089325488238ae34161c997fb483d1 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2026 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
@@ -42,6 +42,9 @@ public:
     // The default constructor.
     explicit PrivacyWebEngineView(QWidget *parentWidgetPointer = nullptr);
 
+    // The public functions.
+    QIcon getFavoriteIcon(const QString &favoriteIconUrlString);
+
     // The public static constants.
     static const int ULTRAPRIVACY = 0;
     static const int ULTRALIST = 1;
@@ -54,7 +57,7 @@ public:
     QVector<int> blockedRequestsVector = {0, 0, 0, 0, 0, 0};
     std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
     QString currentHost = QLatin1String("");
-    QString currentUrlText = QLatin1String("");
+    QString currentUrlString = QLatin1String("");
     double defaultZoomFactor = 1.00;
     QString domainSettingsName = QLatin1String("");
     bool easyListEnabled = true;
@@ -76,6 +79,7 @@ Q_SIGNALS:
     // The signals.
     void numberOfCookiesChanged(const int numberOfCookies) const;
     void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
+    void favoriteIconChanged(const QIcon &newFavoriteIcon) const;
     void requestBlocked(const QVector<int> blockedRequestsVector) const;
     void updateUi(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
 
@@ -93,12 +97,15 @@ private Q_SLOTS:
     void manualOpenInNewTab();
     void openWithChromium() const;
     void openWithFirefox() const;
+    void processFavoriteIcon(const QIcon&);
     void saveHoveredLink(const QString &hoveredLink);
     void storeRequest(RequestStruct *requestStructPointer);
     void storeUpdatedUrl(const QUrl &newUrl);
 
 private:
     // The private variables.
+    QIcon defaultFavoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
+    QMap<QString, QIcon> favoriteIconsMap;
     QString hoveredLinkString;
     bool manuallyOpeninginNewTab = false;
     KLineEdit *passwordLineEditPointer;
index f3a08fee323d70000d830c1dc8378ff425c1e6d9..bc1f4a0a82a48b5f5c0798aa3d0328c6676b8ef5 100644 (file)
@@ -236,8 +236,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
             Q_EMIT updateUrlLineEdit(newUrl);
 
             // Update the status of the forward and back buttons.
-            Q_EMIT updateBackAction(currentWebEngineHistoryPointer->canGoBack());
-            Q_EMIT updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
+            Q_EMIT forwardAndBackChanged(currentWebEngineHistoryPointer);
         }
     });
 
@@ -267,22 +266,16 @@ 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::favoriteIconChanged, [this, splitterPointer, privacyWebEngineViewPointer] (const QIcon &newFavoriteIcon)
     {
-        // Store the favorite icon in the privacy web engine view.
-        if (newFavoriteIcon.isNull())
-            privacyWebEngineViewPointer->favoriteIcon = defaultFavoriteIcon;
-        else
-            privacyWebEngineViewPointer->favoriteIcon = newFavoriteIcon;
-
         // Get the index for this tab.
         int tabIndex = qTabWidgetPointer->indexOf(splitterPointer);
 
         // Update the icon for this tab.
-        if (newFavoriteIcon.isNull())
-            qTabWidgetPointer->setTabIcon(tabIndex, defaultFavoriteIcon);
-        else
-            qTabWidgetPointer->setTabIcon(tabIndex, newFavoriteIcon);
+        qTabWidgetPointer->setTabIcon(tabIndex, newFavoriteIcon);
+
+        // Update the forward and back history.
+        Q_EMIT forwardAndBackChanged(currentWebEngineHistoryPointer);
     });
 
     // Update the progress bar and the favorite icon when a load is started.
@@ -730,7 +723,7 @@ std::list<QNetworkCookie>* TabWidget::getCookieList() const
     return currentPrivacyWebEngineViewPointer->cookieListPointer;
 }
 
-QIcon TabWidget::getCurrentTabFavoritIcon() const
+QIcon TabWidget::getCurrentTabFavoriteIcon() const
 {
     // Return the current Privacy WebEngine favorite icon.
     return currentPrivacyWebEngineViewPointer->favoriteIcon;
@@ -1143,10 +1136,10 @@ void TabWidget::stop() const
     currentPrivacyWebEngineViewPointer->stop();
 }
 
-void TabWidget::storeCurrentUrlText(const QString &urlText) const
+void TabWidget::storeCurrentUrlString(const QString &urlString) const
 {
     // Store the current URL text in the privacy WebEngine view.
-    currentPrivacyWebEngineViewPointer->currentUrlText = urlText;
+    currentPrivacyWebEngineViewPointer->currentUrlString = urlString;
 }
 
 void TabWidget::toggleDeveloperTools(const bool enabled) const
@@ -1341,11 +1334,10 @@ void TabWidget::updateUiWithTabSettings()
     Q_EMIT ultraPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->ultraPrivacyEnabled);
     Q_EMIT blockedRequestsUpdated(currentPrivacyWebEngineViewPointer->blockedRequestsVector);
     Q_EMIT cookiesChanged(currentPrivacyWebEngineViewPointer->cookieListPointer->size());
-    Q_EMIT updateBackAction(currentWebEngineHistoryPointer->canGoBack());
+    Q_EMIT forwardAndBackChanged(currentWebEngineHistoryPointer);
     Q_EMIT updateDefaultZoomFactor(currentPrivacyWebEngineViewPointer->defaultZoomFactor);
     Q_EMIT updateDeveloperToolsAction(devToolsWebEngineViewPointer->isVisible());
     Q_EMIT updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
-    Q_EMIT updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
     Q_EMIT updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
     Q_EMIT updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
     Q_EMIT updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true);
@@ -1364,7 +1356,7 @@ void TabWidget::updateUiWithTabSettings()
     // Update the URL.
     Q_EMIT updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
     Q_EMIT updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String(""));
-    Q_EMIT updateUrlLineEdit(QUrl(currentPrivacyWebEngineViewPointer->currentUrlText));
+    Q_EMIT updateUrlLineEdit(QUrl(currentPrivacyWebEngineViewPointer->currentUrlString));
 }
 
 void TabWidget::useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName)
index 86ba40b3cb2dce512c852eff50335408959e21f0..c1ed9ac79173dd8ec7af35b016054c4aa5c557fd 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2026 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
@@ -60,7 +60,7 @@ public:
     void loadInitialWebsite();
     void findPrevious(const QString &text) const;
     std::list<QNetworkCookie>* getCookieList() const;
-    QIcon getCurrentTabFavoritIcon() const;
+    QIcon getCurrentTabFavoriteIcon() const;
     QString getCurrentTabTitle() const;
     QString getCurrentTabUrl() const;
     QString getCurrentUserAgent() const;
@@ -85,20 +85,19 @@ Q_SIGNALS:
     void fanboysAnnoyanceListStatusChanged(const bool isEnabled) const;
     void removeCookie(const QNetworkCookie &cookie) const;
     void clearUrlLineEditFocus() const;
+    void forwardAndBackChanged(QWebEngineHistory *webEngineHistoryPointer) const;
     void fullScreenRequested(const bool toggleOn) const;
     void hideProgressBar() const;
     void linkHovered(const QString &linkUrl) const;
     void showProgressBar(const int &progress) const;
     void ultraListStatusChanged(const bool) const;
     void ultraPrivacyStatusChanged(const bool) const;
-    void updateBackAction(const bool isEnabled) const;
     void updateDefaultZoomFactor(const double newDefaultZoomFactorDouble) const;
     void updateDeveloperToolsAction(const bool isEnabled) const;
     void updateDomStorageAction(const bool isEnabled) const;
     void updateDomainSettingsIndicator(const bool status) const;
     void updateFindText(const QString &text, const bool findCaseSensitive) const;
     void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
-    void updateForwardAction(const bool isEnabled) const;
     void updateJavaScriptAction(const bool isEnabled) const;
     void updateLocalStorageAction(const bool isEnabled) const;
     void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus) const;
@@ -131,7 +130,7 @@ public Q_SLOTS:
     void reloadAndBypassCache() const;
     void saveArchive();
     void stop() const;
-    void storeCurrentUrlText(const QString &urlText) const;
+    void storeCurrentUrlString(const QString &urlString) const;
     void toggleEasyList() const;
     void toggleEasyPrivacy() const;
     void toggleFanboysAnnoyanceList() const;
index 2ff9a11b94a13ead9438d91b55671df32295eff9..40b3885474b66f5a0ae306a787ed89f1f2f24647 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2022-2025 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2022-2026 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
@@ -84,8 +84,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     zoomOutActionPointer = KStandardAction::zoomOut(this, SLOT(decrementZoom()), 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);
+    backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer);
+    forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer);
     KStandardAction::home(this, SLOT(home()), actionCollectionPointer);
     QAction *editBookmarksActionPointer = KStandardAction::editBookmarks(this, SLOT(editBookmarks()), actionCollectionPointer);
     KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollectionPointer);
@@ -139,6 +139,14 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     findCaseSensitiveActionPointer = actionCollectionPointer->addAction(QLatin1String("find_case_sensitive"));
     hideFindTextActionPointer = actionCollectionPointer->addAction(QLatin1String("hide_find_actions"));
 
+    // Create the forward and back menus.
+    backMenuPointer = new QMenu();
+    forwardMenuPointer = new QMenu();
+
+    // Set the forward and back menus.
+    backActionPointer->setMenu(backMenuPointer);
+    forwardActionPointer->setMenu(forwardMenuPointer);
+
     // Create the action groups
     QActionGroup *userAgentActionGroupPointer = new QActionGroup(this);
     QActionGroup *searchEngineActionGroupPointer = new QActionGroup(this);
@@ -426,9 +434,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     connect(tabWidgetPointer, SIGNAL(fanboysAnnoyanceListStatusChanged(bool)), fanboysAnnoyanceListPointer, SLOT(setChecked(bool)));
     connect(tabWidgetPointer, SIGNAL(ultraListStatusChanged(bool)), ultraListActionPointer, SLOT(setChecked(bool)));
     connect(tabWidgetPointer, SIGNAL(ultraPrivacyStatusChanged(bool)), ultraPrivacyActionPointer, SLOT(setChecked(bool)));
+    connect(tabWidgetPointer, SIGNAL(forwardAndBackChanged(QWebEngineHistory *)), this, SLOT(updateForwardAndBackActions(QWebEngineHistory *)));
     connect(tabWidgetPointer, SIGNAL(updateDeveloperToolsAction(bool)), developerToolsActionPointer, SLOT(setChecked(bool)));
-    connect(tabWidgetPointer, SIGNAL(updateBackAction(bool)), backActionPointer, SLOT(setEnabled(bool)));
-    connect(tabWidgetPointer, SIGNAL(updateForwardAction(bool)), forwardActionPointer, SLOT(setEnabled(bool)));
     connect(tabWidgetPointer, SIGNAL(updateJavaScriptAction(bool)), this, SLOT(updateJavaScriptAction(bool)));
     connect(tabWidgetPointer, SIGNAL(updateLocalStorageAction(bool)), this, SLOT(updateLocalStorageAction(bool)));
     connect(tabWidgetPointer, SIGNAL(updateDomStorageAction(bool)), this, SLOT(updateDomStorageAction(bool)));
@@ -690,7 +697,7 @@ void BrowserWindow::addBookmarkFolderFinalActions(QMenu *menuPointer, const doub
         {
             // Instantiate an add bookmark dialog.
             AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(this, tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl(),
-                                                                                tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
+                                                                                tabWidgetPointer->getCurrentTabFavoriteIcon(), folderId);
 
             // Update the displayed bookmarks when a new one is added.
             connect(addBookmarkDialogPointer, SIGNAL(bookmarkAdded()), this, SLOT(populateBookmarksInAllWindows()));
@@ -704,7 +711,7 @@ void BrowserWindow::addBookmarkFolderFinalActions(QMenu *menuPointer, const doub
     QAction *addFolderActionPointer = menuPointer->addAction(QIcon::fromTheme(QLatin1String("folder-add")), i18nc("The add folder action", "Add Folder"), [=]
         {
             // Instantiate an add folder dialog.
-            AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(this, tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
+            AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(this, tabWidgetPointer->getCurrentTabFavoriteIcon(), folderId);
 
             // Update the displayed bookmarks when a folder is added.
             connect(addFolderDialogPointer, SIGNAL(folderAdded()), this, SLOT(populateBookmarksInAllWindows()));
@@ -772,7 +779,7 @@ void BrowserWindow::addBookmarkFolderFinalActions(QMenu *menuPointer, const doub
         QAction *editFolderActionPointer = menuPointer->addAction(QIcon::fromTheme(QLatin1String("document-edit")), i18nc("The edit folder action", "Edit Folder"), [=]
             {
                 // Get the current tab favorite icon.
-                QIcon currentTabFavoriteIcon = tabWidgetPointer->getCurrentTabFavoritIcon();
+                QIcon currentTabFavoriteIcon = tabWidgetPointer->getCurrentTabFavoriteIcon();
 
                 // Instantiate an edit folder dialog.
                 QDialog *editFolderDialogPointer = new EditFolderDialog(this, folderDatabaseId, currentTabFavoriteIcon);
@@ -985,7 +992,7 @@ void BrowserWindow::decrementZoom()
 void BrowserWindow::editBookmarks()
 {
     // Instantiate an edit bookmarks dialog.
-    BookmarksDialog *bookmarksDialogPointer = new BookmarksDialog(this, tabWidgetPointer->getCurrentTabFavoritIcon(), tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl());
+    BookmarksDialog *bookmarksDialogPointer = new BookmarksDialog(this, tabWidgetPointer->getCurrentTabFavoriteIcon(), tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl());
 
     // Update the displayed bookmarks when edited.
     connect(bookmarksDialogPointer, SIGNAL(bookmarkUpdated()), this, SLOT(populateBookmarksInAllWindows()));
@@ -1424,13 +1431,13 @@ void BrowserWindow::populateBookmarksToolBarSubfolders(const double folderId, QM
     }
 }
 
-void BrowserWindow::processUrlTextChanges(const QString &newUrlText) const
+void BrowserWindow::processUrlTextChanges(const QString &newUrlString) const
 {
     // Update the visibility of the restore URL text action pointer.
-    restoreUrlTextActionPointer->setVisible(newUrlText != tabWidgetPointer->getCurrentTabUrl());
+    restoreUrlTextActionPointer->setVisible(newUrlString != tabWidgetPointer->getCurrentTabUrl());
 
     // Store the new URL text in the WebEngine View.
-    tabWidgetPointer->storeCurrentUrlText(newUrlText);
+    tabWidgetPointer->storeCurrentUrlString(newUrlString);
 }
 
 void BrowserWindow::refresh() const
@@ -1542,7 +1549,7 @@ void BrowserWindow::showBookmarkContextMenu(const QPoint &point)
             bookmarkContextMenuPointer->addAction(QIcon::fromTheme(QLatin1String("document-edit")), i18nc("Edit bookmark context menu entry", "Edit"), [=]
                 {
                     // Get the current tab favorite icon.
-                    QIcon currentTabFavoriteIcon = tabWidgetPointer->getCurrentTabFavoritIcon();
+                    QIcon currentTabFavoriteIcon = tabWidgetPointer->getCurrentTabFavoriteIcon();
 
                     // Instantiate an edit bookmark dialog.
                     QDialog *editBookmarkDialogPointer = new EditBookmarkDialog(this, databaseId, currentTabFavoriteIcon);
@@ -1745,7 +1752,7 @@ void BrowserWindow::toggleBookmark()
         bookmarkStructPointer->name = tabWidgetPointer->getCurrentTabTitle();
         bookmarkStructPointer->url = tabWidgetPointer->getCurrentTabUrl();
         bookmarkStructPointer->parentFolderId = 0;
-        bookmarkStructPointer->favoriteIcon = tabWidgetPointer->getCurrentTabFavoritIcon();
+        bookmarkStructPointer->favoriteIcon = tabWidgetPointer->getCurrentTabFavoriteIcon();
 
         // Add the bookmark.
         BookmarksDatabase::addBookmark(bookmarkStructPointer);
@@ -1950,6 +1957,81 @@ void BrowserWindow::updateFindTextResults(const QWebEngineFindTextResult &findTe
         findTextLineEditPointer->setPalette(positiveBackgroundPalette);
 }
 
+void BrowserWindow::updateForwardAndBackActions(QWebEngineHistory *webEngineHistoryPointer)
+{
+    // Clear the forward and back menus.
+    backMenuPointer->clear();
+    forwardMenuPointer->clear();
+
+    // Get the history item lists (maximum of 100 items).
+    QList<QWebEngineHistoryItem> backItemsList = webEngineHistoryPointer->backItems(100);
+    QList<QWebEngineHistoryItem> forwardItemsList = webEngineHistoryPointer->forwardItems(100);
+
+    // Populate the back menu pointer.  This must start at the end of the list and move backwards to populate the menu in the correct order.
+    for (int i = (backItemsList.size() - 1); i >= 0; --i)
+    {
+        // Get the WebEngine history item.
+        const QWebEngineHistoryItem &backHistoryItem = backItemsList.at(i);
+
+        // Get the icon for entry.
+        QIcon favoriteIcon = tabWidgetPointer->currentPrivacyWebEngineViewPointer->getFavoriteIcon(backHistoryItem.url().toString());
+
+        // Create a back action.
+        QAction *backActionPointer = new QAction();
+
+        // Populate the back action.
+        backActionPointer->setText(backHistoryItem.title());
+        backActionPointer->setIcon(favoriteIcon);
+
+        // Connect the action.
+        connect(backActionPointer, &QAction::triggered, [this, webEngineHistoryPointer, backHistoryItem] ()
+        {
+            // Remove the focus from the URL line edit.
+            urlLineEditPointer->clearFocus();
+
+            // Go back to the specified page.
+            webEngineHistoryPointer->goToItem(backHistoryItem);
+        });
+
+        // Populate the back menu.
+        backMenuPointer->addAction(backActionPointer);
+    }
+
+    // Populate the forward menu pointer.
+    for (int i = 0; i < forwardItemsList.size(); ++i)
+    {
+        // Get the WebEngine history item.
+        const QWebEngineHistoryItem &forwardHistoryItem = forwardItemsList.at(i);
+
+        // Get the icon for entry.
+        QIcon favoriteIcon = tabWidgetPointer->currentPrivacyWebEngineViewPointer->getFavoriteIcon(forwardHistoryItem.url().toString());
+
+        // Create a forward action.
+        QAction *forwardActionPointer = new QAction();
+
+        // Populate the forward action.
+        forwardActionPointer->setText(forwardHistoryItem.title());
+        forwardActionPointer->setIcon(favoriteIcon);
+
+        // Connect the action.
+        connect(forwardActionPointer, &QAction::triggered, [this, webEngineHistoryPointer, forwardHistoryItem] ()
+        {
+            // Remove the focus from the URL line edit.
+            urlLineEditPointer->clearFocus();
+
+            // Go forward to the specified page.
+            webEngineHistoryPointer->goToItem(forwardHistoryItem);
+        });
+
+        // Populate the forward menu.
+        forwardMenuPointer->addAction(forwardActionPointer);
+    }
+
+    // Set the status for the actions.
+    backActionPointer->setEnabled(webEngineHistoryPointer->canGoBack());
+    forwardActionPointer->setEnabled(webEngineHistoryPointer->canGoForward());
+}
+
 void BrowserWindow::updateJavaScriptAction(const bool &isEnabled)
 {
     // Update the JavaScript status.
index 525cb85a63e9a9c913a805548518542a4e64d7c6..199dcbb55c8ba3c35477c1dab24005b1181e3fbb 100644 (file)
@@ -78,7 +78,7 @@ private Q_SLOTS:
     void openWithChromium() const;
     void openWithFirefox() const;
     void populateBookmarksInAllWindows() const;
-    void processUrlTextChanges(const QString &newUrlText) const;
+    void processUrlTextChanges(const QString &newUrlString) const;
     void refresh() const;
     void reloadAndBypassCache() const;
     void restoreUrlText() const;
@@ -107,6 +107,7 @@ private Q_SLOTS:
     void updateDomainSettingsIndicator(const bool status);
     void updateFindText(const QString &text, const bool findCaseSensitive) const;
     void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
+    void updateForwardAndBackActions(QWebEngineHistory *webEngineHistoryPointer);
     void updateJavaScriptAction(const bool &isEnabled);
     void updateLocalStorageAction(const bool &isEnabled);
     void updateRequestsAction(const QVector<int> blockedRequestsVector) const;
@@ -121,6 +122,8 @@ private Q_SLOTS:
 private:
     // The private variables.
     KActionCollection *actionCollectionPointer;
+    QAction *backActionPointer;
+    QMenu *backMenuPointer;
     QAction *blockedRequestsActionPointer;
     QAction *bookmarkedActionPointer;
     QList<QPair<QMenu *, QAction *> *> bookmarkFolderFinalActionList;
@@ -154,6 +157,8 @@ private:
     QAction *findTextLineEditActionPointer;
     KLineEdit *findTextLineEditPointer;
     QAction *findTextSpacerActionPointer;
+    QAction *forwardActionPointer;
+    QMenu *forwardMenuPointer;
     KToggleFullScreenAction *fullScreenActionPointer;
     QAction *hideFindTextActionPointer;
     QAction *javaScriptActionPointer;