-/*
- * 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) {}
-/*
- * 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
Q_OBJECT
public:
- // The default constructor.
+ // The primary constructor.
explicit PrivacyWebEnginePage(QWebEngineProfile *webEngineProfilePointer, QObject *parentObjectPointer = nullptr);
-
-//protected:
};
#endif
/* 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/>.
*
// 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
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.
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.
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();
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();
}
/* 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/>.
*
// 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;
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;
// 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;
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;
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);
}
});
});
// 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.
return currentPrivacyWebEngineViewPointer->cookieListPointer;
}
-QIcon TabWidget::getCurrentTabFavoritIcon() const
+QIcon TabWidget::getCurrentTabFavoriteIcon() const
{
// Return the current Privacy WebEngine favorite icon.
return currentPrivacyWebEngineViewPointer->favoriteIcon;
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
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);
// 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)
/* 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/>.
*
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;
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;
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;
/* 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/>.
*
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);
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);
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)));
{
// 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()));
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()));
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);
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()));
}
}
-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
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);
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);
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.
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;
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;
private:
// The private variables.
KActionCollection *actionCollectionPointer;
+ QAction *backActionPointer;
+ QMenu *backMenuPointer;
QAction *blockedRequestsActionPointer;
QAction *bookmarkedActionPointer;
QList<QPair<QMenu *, QAction *> *> bookmarkFolderFinalActionList;
QAction *findTextLineEditActionPointer;
KLineEdit *findTextLineEditPointer;
QAction *findTextSpacerActionPointer;
+ QAction *forwardActionPointer;
+ QMenu *forwardMenuPointer;
KToggleFullScreenAction *fullScreenActionPointer;
QAction *hideFindTextActionPointer;
QAction *javaScriptActionPointer;