-Privacy Browser PC copyright 2016-2017,2021-2023 Soren Stoutner <soren@stoutner.com>.
+Privacy Browser PC copyright 2016-2017,2021-2024 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
<?xml version="1.0" ?>
<!--
- Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
</authorgroup>
<copyright>
- <year>2016-2017, 2021-2023</year>
+ <year>2016-2017, 2021-2024</year>
<holder>&Soren.Stoutner;</holder>
</copyright>
<legalnotice>&FDLNotice;</legalnotice>
<!-- Last update. -->
- <date>2023-10-12</date>
+ <date>2024-01-06</date>
<!-- The version of Privacy Browser this documentation is written for. -->
<releaseinfo>&privacybrowser; version 0.5</releaseinfo>
</listitem>
</varlistentry>
+ <!-- Save Archive. -->
+ <varlistentry id="file-save-archive">
+ <term>
+ <menuchoice>
+ <shortcut>
+ <keycombo action="simul">&Ctrl;<keycap>A</keycap></keycombo>
+ </shortcut>
+
+ <guimenu>File</guimenu>
+
+ <guimenuitem>Save Archive</guimenuitem>
+ </menuchoice>
+ </term>
+
+ <listitem>
+ <para>
+ Save the webpage as an MHT (MIME encapsulation of aggregate HTML documents) archive.
+ </para>
+ </listitem>
+ </varlistentry>
+
<!-- Print. -->
<varlistentry id="file-print">
<term>
<title>View</title>
<variablelist>
+ <!-- Zoom Default. -->
+ <varlistentry id="zoom-default">
+ <term>
+ <menuchoice>
+ <shortcut>
+ <keycombo action="simul">&Ctrl;<keycap>0</keycap></keycombo>
+ </shortcut>
+
+ <guimenu>View</guimenu>
+
+ <guimenuitem>Zoom Default</guimenuitem>
+ </menuchoice>
+ </term>
+
+ <listitem>
+ <para>
+ Return to either the app or the domain default zoom factor.
+ </para>
+ </listitem>
+ </varlistentry>
+
<!-- Zoom In. -->
<varlistentry id="zoom-in">
<term>
<listitem>
<para>
- Reload the website in the current tab.
+ Reload the website in the current tab. When Refresh is visible, <xref linkend="view-stop"/> is hidden.
</para>
</listitem>
</varlistentry>
</listitem>
</varlistentry>
+ <!-- Stop. -->
+ <varlistentry id="view-stop">
+ <term>
+ <menuchoice>
+ <shortcut>
+ <keycombo action="simul">&Ctrl;&Shift;<keycap>X</keycap></keycombo>
+ </shortcut>
+
+ <guimenu>View</guimenu>
+
+ <guimenuitem>Stop</guimenuitem>
+ </menuchoice>
+ </term>
+
+ <listitem>
+ <para>
+ Stop the loading of the website in the current tab. When Stop is visible, <xref linkend="view-refresh"/> is hidden.
+ </para>
+ </listitem>
+ </varlistentry>
+
<!-- View Source. -->
<varlistentry id="view-source">
<term>
</listitem>
</varlistentry>
+ <!-- Developer Tools. -->
+ <varlistentry id="view-developer-tools">
+ <term>
+ <menuchoice>
+ <shortcut>
+ <keycap>F12</keycap>
+ </shortcut>
+
+ <guimenu>View</guimenu>
+
+ <guimenuitem>Developer Tools</guimenuitem>
+ </menuchoice>
+ </term>
+
+ <listitem>
+ <para>
+ Display the developer tools, which are used to debug websites.
+ </para>
+ </listitem>
+ </varlistentry>
+
<!-- Full Screen Mode. -->
<varlistentry id="view-full-screen-mode">
<term>
<variablelist>
<!-- Edit Bookmarks. -->
- <varlistentry id="edit-bookmarks">
+ <varlistentry id="bookmarks-edit-bookmarks">
<term>
<menuchoice>
<shortcut>
</varlistentry>
<!-- View Bookmarks Toolbar. -->
- <varlistentry id="view-bookmarks-toolbar">
+ <varlistentry id="bookmarks-view-bookmarks-toolbar">
<term>
<menuchoice>
<shortcut>
</varlistentry>
<!-- Add Bookmark. -->
- <varlistentry id="add-bookmark">
+ <varlistentry id="bookmarks-add-bookmark">
<term>
<menuchoice>
<shortcut>
</varlistentry>
<!-- Add Folder. -->
- <varlistentry id="add-folder">
+ <varlistentry id="bookmarks-add-folder">
<term>
<menuchoice>
<shortcut>
<title>Credits and License</title>
<para>
- Privacy Browser PC copyright 2016-2017,2021-2023 Soren Stoutner <ulink url="mailto:soren@stoutner.com">soren@stoutner.com</ulink>.
+ Privacy Browser PC copyright 2016-2017,2021-2024 Soren Stoutner <ulink url="mailto:soren@stoutner.com">soren@stoutner.com</ulink>.
</para>
<!-- Program. -->
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// Application headers.
#include "DomainsDatabase.h"
+#include "Settings.h"
#include "helpers/UserAgentHelper.h"
// Define the private static schema constants.
}
else // Opening the database failed.
{
- // Write the last database error message to the debug output.
+ // Write the last database error message to the debug output.Settings::zoom
qDebug().noquote().nospace() << "Error opening database: " << domainsDatabase.lastError();
}
};
+void DomainsDatabase::addDomain(const QString &domainName)
+{
+ // Add the domain:
+ addDomain(domainName, SYSTEM_DEFAULT, SYSTEM_DEFAULT, SYSTEM_DEFAULT, UserAgentHelper::SYSTEM_DEFAULT_DATABASE, SYSTEM_DEFAULT, Settings::zoomFactor());
+}
+
+void DomainsDatabase::addDomain(const QString &domainName, const int javaScriptInt, const int localStorageInt, const int domStorageInt, const QString &userAgentDatabaseString,
+ const int zoomFactorInt, const double currentZoomFactorDouble)
+{
+ // Get a handle for the domains database.
+ QSqlDatabase domainsDatabase = QSqlDatabase::database(CONNECTION_NAME);
+
+ // Instantiate an add domain settings query.
+ QSqlQuery addDomainSettingsQuery(domainsDatabase);
+
+ // Prepare the query.
+ addDomainSettingsQuery.prepare("INSERT INTO " + DomainsDatabase::DOMAINS_TABLE + " (" +
+ DomainsDatabase::DOMAIN_NAME + ", " +
+ DomainsDatabase::JAVASCRIPT + ", " +
+ DomainsDatabase::LOCAL_STORAGE + ", " +
+ DomainsDatabase::DOM_STORAGE + ", " +
+ DomainsDatabase::USER_AGENT + ", " +
+ DomainsDatabase::ZOOM_FACTOR + ", " +
+ DomainsDatabase::CUSTOM_ZOOM_FACTOR + ") " +
+ "VALUES (:domain_name, :javascript, :local_storage, :dom_storage, :user_agent, :zoom_factor, :custom_zoom_factor)"
+ );
+
+ // Bind the query values.
+ addDomainSettingsQuery.bindValue(":domain_name", domainName);
+ addDomainSettingsQuery.bindValue(":javascript", javaScriptInt);
+ addDomainSettingsQuery.bindValue(":local_storage", localStorageInt);
+ addDomainSettingsQuery.bindValue(":dom_storage", domStorageInt);
+ addDomainSettingsQuery.bindValue(":user_agent", userAgentDatabaseString);
+ addDomainSettingsQuery.bindValue(":zoom_factor", zoomFactorInt);
+ addDomainSettingsQuery.bindValue(":custom_zoom_factor", currentZoomFactorDouble);
+
+ // Execute the query.
+ addDomainSettingsQuery.exec();
+}
+
QSqlQuery DomainsDatabase::getDomainQuery(const QString &hostname)
{
// Get a handle for the domains database.
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// The public functions.
static void addDatabase();
+ static void addDomain(const QString &domainName);
+ static void addDomain(const QString &domainName, const int javaScriptInt, const int localStorageInt, const int domStorageInt, const QString &userAgentDatabaseString, const int zoomFactorInt,
+ const double currentZoomFactorDouble);
static QSqlQuery getDomainQuery(const QString &hostname);
// The public int constants.
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// Define the public static int constants.
const int DomainSettingsDialog::SHOW_ALL_DOMAINS = 0;
-const int DomainSettingsDialog::ADD_DOMAIN = 1;
-const int DomainSettingsDialog::EDIT_DOMAIN = 2;
+const int DomainSettingsDialog::EDIT_DOMAIN = 1;
// Construct the class.
DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr)
break;
}
- case ADD_DOMAIN:
- {
- // Add the new domain.
- addDomain(domainName);
-
- // Emit the domain settings updated signal after 100 milliseconds. This is necessary because the browser window takes time to process the connect command to receive the signal.
- QTimer::singleShot(100, [this] () { emit domainSettingsUpdated();});
-
- break;
- }
-
case EDIT_DOMAIN:
{
// Find the index for the new domain. `1` returns the first match.
updateUi();
}
-void DomainSettingsDialog::addDomain(const QString &domainName) const
-{
- // Create a new domain record.
- QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabase::CONNECTION_NAME).record(DomainsDatabase::DOMAINS_TABLE);
-
- // Set the values for the new domain.
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME), domainName);
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::JAVASCRIPT), DomainsDatabase::SYSTEM_DEFAULT);
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::LOCAL_STORAGE), DomainsDatabase::SYSTEM_DEFAULT);
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOM_STORAGE), DomainsDatabase::SYSTEM_DEFAULT);
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE);
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::ZOOM_FACTOR), DomainsDatabase::SYSTEM_DEFAULT);
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR), 1.0);
-
- // Insert the new domain. `-1` appends it to the end.
- domainsTableModelPointer->insertRecord(-1, newDomainRecord);
-
- // Submit all pending changes.
- domainsTableModelPointer->submitAll();
-
- // Find the index for the new domain. `-1` allows for multiple entries to be returned.
- QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)),
- Qt::DisplayRole, domainName, -1, Qt::MatchWrap);
-
- // Move to the new domain. If there are multiple domains with the same name, the new one should be the last in the list.
- domainsListViewPointer->setCurrentIndex(newDomainIndex[newDomainIndex.size() - 1]);
-
- // Populate the domain settings.
- domainSelected(domainsSelectionModelPointer->currentIndex());
-
- // Update the UI.
- updateUi();
-
- // Emit the domain settings updated signal.
- emit domainSettingsUpdated();
-}
-
void DomainSettingsDialog::apply() const
{
// Get the current index.
QLineEdit::Normal, QString(), &okClicked);
// Add the new domain if the user clicked OK.
- if (okClicked) addDomain(newDomainName);
+ if (okClicked)
+ {
+ // Add the new domain.
+ DomainsDatabase::addDomain(newDomainName);
+
+ // Submit all pending changes. This reloads the model from the database, getting the new domain added above.
+ domainsTableModelPointer->submitAll();
+
+
+ // Find the index for the new domain. `-1` allows for multiple entries to be returned.
+ QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)),
+ Qt::DisplayRole, newDomainName, -1, Qt::MatchWrap);
+
+ // Move to the new domain. If there are multiple domains with the same name, the new one should be the last in the list.
+ domainsListViewPointer->setCurrentIndex(newDomainIndex[newDomainIndex.size() - 1]);
+
+ // Populate the domain settings.
+ domainSelected(domainsSelectionModelPointer->currentIndex());
+
+ // Update the UI.
+ updateUi();
+
+ // Emit the domain settings updated signal.
+ emit domainSettingsUpdated();
+ }
}
void DomainSettingsDialog::showDeleteMessageBox() const
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022,2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
QComboBox *zoomFactorComboBoxPointer;
// The private functions.
- void addDomain(const QString &domainName) const;
void populateDomStorageLabel() const;
void populateJavaScriptLabel() const;
void populateLocalStorageLabel() const;
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
else return translatedUserAgentName; // Return the custom user agent.
}
+QString UserAgentHelper::getDatabaseUserAgentNameFromUserAgent(const QString &userAgent)
+{
+ // Return the database user agent name.
+ if (userAgent == PRIVACY_BROWSER_USER_AGENT) return PRIVACY_BROWSER_DATABASE; // Privacy Browser.
+ else if (userAgent == TabWidget::webEngineDefaultUserAgent) return WEB_ENGINE_DEFAULT_DATABASE; // WebEngine default.
+ else if (userAgent == FIREFOX_LINUX_USER_AGENT) return FIREFOX_LINUX_DATABASE; // Firefox Linux.
+ else if (userAgent == CHROMIUM_LINUX_USER_AGENT) return CHROMIUM_LINUX_DATABASE; // Chromium Linux.
+ else if (userAgent == FIREFOX_WINDOWS_USER_AGENT) return FIREFOX_WINDOWS_DATABASE; // Firefox Windows.
+ else if (userAgent == CHROME_WINDOWS_USER_AGENT) return CHROME_WINDOWS_DATABASE; // Chrome Windows.
+ else if (userAgent == EDGE_WINDOWS_USER_AGENT) return EDGE_WINDOWS_DATABASE; // Edge Windows.
+ else if (userAgent == SAFARI_MACOS_USER_AGENT) return SAFARI_MACOS_DATABASE; // Safari macOS.
+ else return userAgent; // Return the custom user agent.
+}
+
int UserAgentHelper::getDomainSettingsUserAgentIndex(const QString &userAgentName)
{
// Return the domain settings user agent index.
/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022,2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
static const QString WEB_ENGINE_DEFAULT_DATABASE;
// The public static functions.
+ static QString getDatabaseUserAgentNameFromUserAgent(const QString &userAgent);
static int getDomainSettingsUserAgentIndex(const QString &userAgentName);
static QString getUserAgentFromDatabaseName(const QString &userAgentDatabaseName);
static QString getResultingDomainSettingsUserAgent(const QString &rawUserAgent);
QString EDGE_WINDOWS_TRANSLATED;
QString SAFARI_MACOS_TRANSLATED;
- // The public functions.
+ // The public functions. Anything that accesses the translated user names must use an instantiated copy of the class.
QString getDatabaseUserAgentNameFromTranslatedName(const QString &translatedUserAgentName);
QString getUserAgentFromTranslatedName(const QString &userAgentTranslatedName);
QString getTranslatedUserAgentNameFromDatabaseName(const QString &userAgentName);
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
// Populate additional about data info.
aboutData.setBugAddress("https://redmine.stoutner.com/projects/privacy-browser-pc/issues");
- aboutData.setCopyrightStatement(i18nc("Copyright", "Copyright 2016-2017,2021-2023 Soren Stoutner <soren@stoutner.com>"));
+ aboutData.setCopyrightStatement(i18nc("Copyright", "Copyright 2016-2017,2021-2024 Soren Stoutner <soren@stoutner.com>"));
aboutData.setDesktopFileName(QStringLiteral("com.stoutner.privacybrowser"));
aboutData.setHomepage(QStringLiteral("https://www.stoutner.com/privacy-browser-pc/"));
//aboutData.setLicense(KAboutLicense::GPL_V3, KAboutLicense::OrLaterVersions); <https://redmine.stoutner.com/issues/822>
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
currentPrivacyWebEngineViewPointer->reload();
}
-void TabWidget::applyOnTheFlyZoomFactor(const double &zoomFactor) const
+void TabWidget::applyOnTheFlyZoomFactor(const double zoomFactorDouble) const
{
// Set the zoom factor.
- currentPrivacyWebEngineViewPointer->setZoomFactor(zoomFactor);
+ currentPrivacyWebEngineViewPointer->setZoomFactor(zoomFactorDouble);
}
void TabWidget::applySpellCheckLanguages() const
return currentPrivacyWebEngineViewPointer->url().toString();
}
+QString TabWidget::getCurrentUserAgent() const
+{
+ // Return the current WebEngine user agent.
+ return currentWebEngineProfilePointer->httpUserAgent();
+}
+
QString& TabWidget::getDomainSettingsName() const
{
// Return the domain settings name.
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
~TabWidget();
// The public functions.
- void applyOnTheFlyZoomFactor(const double &zoomFactor) const;
+ void applyOnTheFlyZoomFactor(const double zoomFactorDouble) const;
void applySpellCheckLanguages() const;
PrivacyWebEngineView* loadBlankInitialWebsite();
void loadInitialWebsite();
QIcon getCurrentTabFavoritIcon() const;
QString getCurrentTabTitle() const;
QString getCurrentTabUrl() const;
+ QString getCurrentUserAgent() const;
QString& getDomainSettingsName() const;
void setTabBarVisible(const bool visible) const;
void toggleDeveloperTools(const bool enabled) const;
void showProgressBar(const int &progress) const;
void updateBackAction(const bool &isEnabled) const;
void updateCookiesAction(const int numberOfCookies) const;
- void updateDefaultZoomFactor(const double newDefaultZoomFactor) 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 updateUrlLineEdit(const QUrl &newUrl) const;
void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus) const;
void updateWindowTitle(const QString &title) const;
- void updateZoomActions(const double &zoomFactor) const;
+ void updateZoomActions(const double zoomFactorDouble) const;
public Q_SLOTS:
// The public slots.
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
#include "ui_SettingsPrivacy.h"
#include "ui_SettingsSpellCheck.h"
#include "databases/BookmarksDatabase.h"
+#include "databases/DomainsDatabase.h"
#include "dialogs/AddBookmarkDialog.h"
#include "dialogs/AddFolderDialog.h"
#include "dialogs/BookmarksDialog.h"
// Remove the focus from the URL line edit.
urlLineEditPointer->clearFocus();
- // Create the domain settings dialog pointer.
- DomainSettingsDialog *domainSettingsDialogPointer;
-
// Get the current domain settings name.
QString ¤tDomainSettingsName = tabWidgetPointer->getDomainSettingsName();
// Run the commands according to the current domain settings status.
if (currentDomainSettingsName == QStringLiteral("")) // Domain settings are not currently applied.
{
- // Instruct the domain settings dialog to add a new domain.
- domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::ADD_DOMAIN, currentUrl.host());
- }
- else // Domain settings are currently applied.
- {
- // Instruct the domain settings dialog to edit the current domain.
- domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
+ // Get the current settings status.
+ int javaScriptInt = calculateSettingsInt(javaScriptEnabled, Settings::javaScriptEnabled());
+ int localStorageInt = calculateSettingsInt(localStorageActionPointer->isChecked(), Settings::localStorageEnabled());
+ int domStorageInt = calculateSettingsInt(domStorageActionPointer->isChecked(), Settings::domStorageEnabled());
+
+ // Get the current user agent string.
+ QString currentUserAgentString = tabWidgetPointer->getCurrentUserAgent();
+
+ // Get the current user agent database string.
+ QString currentUserAgentDatabaseString = UserAgentHelper::getDatabaseUserAgentNameFromUserAgent(currentUserAgentString);
+
+ // Initialize the user agent database string.
+ QString userAgentDatabaseString = UserAgentHelper::SYSTEM_DEFAULT_DATABASE;
+
+ // Replace the user agent database string if the current user agent is not the default.
+ if (currentUserAgentDatabaseString != Settings::userAgent())
+ userAgentDatabaseString = currentUserAgentDatabaseString;
+
+ // Initialize the zoom factor variables.
+ int zoomFactorInt = DomainsDatabase::SYSTEM_DEFAULT;
+
+ // Use a custom zoom factor if currently applied. Doubles cannot be reliably compared using `==`, so a mathematical workaround is used.
+ if (abs(currentZoomFactorDouble - defaultZoomFactorDouble ) > 0.01)
+ zoomFactorInt = DomainsDatabase::CUSTOM;
+
+ // Add the domain.
+ DomainsDatabase::addDomain(currentUrl.host(), javaScriptInt, localStorageInt, domStorageInt, userAgentDatabaseString, zoomFactorInt, currentZoomFactorDouble);
+
+ // Apply the domain settings.
+ tabWidgetPointer->applyDomainSettingsAndReload();
}
+ // Create the domain settings dialog pointer.
+ DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
+
// Reload the tabs when domain settings are updated.
connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
tabWidgetPointer->back();
}
+int BrowserWindow::calculateSettingsInt(const bool settingCurrentlyEnabled, const bool settingEnabledByDefault) const
+{
+ // Return the int that matches the current state.
+ if (settingCurrentlyEnabled == settingEnabledByDefault) // The current system default is used.
+ return DomainsDatabase::SYSTEM_DEFAULT;
+ else if (settingCurrentlyEnabled) // The setting is enabled, which is different from the system default.
+ return DomainsDatabase::ENABLED;
+ else // The setting is disabled, which is different from the system default.
+ return DomainsDatabase::DISABLED;
+}
+
void BrowserWindow::clearUrlLineEditFocus() const
{
// Remove the focus from the URL line edit.
void BrowserWindow::decrementZoom()
{
// Update the current zoom factor.
- currentZoomFactor = currentZoomFactor - 0.25;
+ currentZoomFactorDouble = currentZoomFactorDouble - 0.25;
// Check to make sure the zoom factor is in the valid range (0.25 to 5.00).
- if (currentZoomFactor < 0.25)
- currentZoomFactor = 0.25;
+ if (currentZoomFactorDouble < 0.25)
+ currentZoomFactorDouble = 0.25;
// Set the new zoom factor.
- tabWidgetPointer->applyOnTheFlyZoomFactor(currentZoomFactor);
+ tabWidgetPointer->applyOnTheFlyZoomFactor(currentZoomFactorDouble);
// Update the on-the-fly action text.
- updateZoomActions(currentZoomFactor);
+ updateZoomActions(currentZoomFactorDouble);
}
void BrowserWindow::editBookmarks() const
bool okClicked;
// Display a dialog to get the new zoom factor from the user. Format the double to display two decimals and have a 0.25 step.
- double newZoomFactor = QInputDialog::getDouble(this, i18nc("The on-the-fly zoom factor dialog title", "On-The-Fly Zoom Factor"),
+ double newZoomFactorDouble = QInputDialog::getDouble(this, i18nc("The on-the-fly zoom factor dialog title", "On-The-Fly Zoom Factor"),
i18nc("The instruction text of the on-the-fly zoom factor dialog", "Enter a zoom factor between 0.25 and 5.00"),
- currentZoomFactor, .025, 5.00, 2, &okClicked, Qt::WindowFlags(), 0.25);
+ currentZoomFactorDouble, .025, 5.00, 2, &okClicked, Qt::WindowFlags(), 0.25);
// Update the zoom factor if the user clicked OK.
if (okClicked)
{
// Set the new zoom factor.
- tabWidgetPointer->applyOnTheFlyZoomFactor(newZoomFactor);
+ tabWidgetPointer->applyOnTheFlyZoomFactor(newZoomFactorDouble);
// Update the on-the-fly action text.
- updateZoomActions(newZoomFactor);
+ updateZoomActions(newZoomFactorDouble);
}
}
void BrowserWindow::incrementZoom()
{
// Update the current zoom factor.
- currentZoomFactor = currentZoomFactor + 0.25;
+ currentZoomFactorDouble = currentZoomFactorDouble + 0.25;
// Check to make sure the zoom factor is in the valid range (0.25 to 5.00).
- if (currentZoomFactor > 5.0)
- currentZoomFactor = 5.0;
+ if (currentZoomFactorDouble > 5.0)
+ currentZoomFactorDouble = 5.0;
// Set the new zoom factor.
- tabWidgetPointer->applyOnTheFlyZoomFactor(currentZoomFactor);
+ tabWidgetPointer->applyOnTheFlyZoomFactor(currentZoomFactorDouble);
// Update the on-the-fly action text.
- updateZoomActions(currentZoomFactor);
+ updateZoomActions(currentZoomFactorDouble);
}
void BrowserWindow::loadUrlFromLineEdit(const QString &url) const
cookiesActionPointer->setText(i18nc("The Cookies action, which also displays the number of cookies", "Cookies - %1", numberOfCookies));
}
-void BrowserWindow::updateDefaultZoomFactor(const double newDefaultZoomFactor)
+void BrowserWindow::updateDefaultZoomFactor(const double newDefaultZoomFactorDouble)
{
// Store the new default zoom factor.
- defaultZoomFactor = newDefaultZoomFactor;
+ defaultZoomFactorDouble = newDefaultZoomFactorDouble;
}
void BrowserWindow::updateDomStorageAction(const bool &isEnabled) const
setWindowTitle(title);
}
-void BrowserWindow::updateZoomActions(const double &zoomFactor)
+void BrowserWindow::updateZoomActions(const double zoomFactorDouble)
{
// Set the current zoom factor.
- currentZoomFactor = zoomFactor;
+ currentZoomFactorDouble = zoomFactorDouble;
// Set the status of the default zoom action.
- zoomDefaultActionPointer->setEnabled(currentZoomFactor != defaultZoomFactor);
+ zoomDefaultActionPointer->setEnabled(currentZoomFactorDouble != defaultZoomFactorDouble);
// Set the status of the zoom in action and button.
- zoomInActionPointer->setEnabled(currentZoomFactor <= 4.99);
- zoomPlusButtonPointer->setEnabled(currentZoomFactor <= 4.99);
+ zoomInActionPointer->setEnabled(currentZoomFactorDouble <= 4.99);
+ zoomPlusButtonPointer->setEnabled(currentZoomFactorDouble <= 4.99);
// Set the status of the zoom out action and button.
- zoomMinusButtonPointer->setEnabled(currentZoomFactor > 0.25);
- zoomOutActionPointer->setEnabled(currentZoomFactor > 0.25);
+ zoomMinusButtonPointer->setEnabled(currentZoomFactorDouble > 0.25);
+ zoomOutActionPointer->setEnabled(currentZoomFactorDouble > 0.25);
// Update the zoom factor action text, formatting the double with 2 decimal places. `0` specifies no extra field width. `'0'` sets the format to not use scientific notation.
- zoomFactorActionPointer->setText(ki18nc("The zoom factor action", "Zoom Factor - %1").subs(zoomFactor, 0, '0', 2).toString());
+ zoomFactorActionPointer->setText(ki18nc("The zoom factor action", "Zoom Factor - %1").subs(zoomFactorDouble, 0, '0', 2).toString());
// Update the status bar zoom factor label.
- currentZoomButtonPointer->setText(ki18nc("The status bar zoom, which is just the formatted zoom factor", "%1").subs(zoomFactor, 0, '0', 2).toString());
+ currentZoomButtonPointer->setText(ki18nc("The status bar zoom, which is just the formatted zoom factor", "%1").subs(zoomFactorDouble, 0, '0', 2).toString());
}
void BrowserWindow::zoomDefault()
{
// Set the new zoom factor.
- tabWidgetPointer->applyOnTheFlyZoomFactor(defaultZoomFactor);
+ tabWidgetPointer->applyOnTheFlyZoomFactor(defaultZoomFactorDouble);
// Update the on-the-fly action text.
- updateZoomActions(defaultZoomFactor);
+ updateZoomActions(defaultZoomFactorDouble);
}
/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
void toggleViewSource() const;
void toggleViewSourceInNewTab() const;
void updateCookiesAction(const int numberOfCookies) const;
- void updateDefaultZoomFactor(const double newDefaultZoomFactor);
+ void updateDefaultZoomFactor(const double newDefaultZoomFactorDouble);
void updateDomStorageAction(const bool &isEnabled) const;
void updateDomainSettingsIndicator(const bool status);
void updateFindText(const QString &text, const bool findCaseSensitive) const;
void updateLocalStorageAction(const bool &isEnabled);
void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus);
void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus);
- void updateZoomActions(const double &zoomFactor);
+ void updateZoomActions(const double zoomFactorDouble);
void updateSearchEngineLabel(const QString &searchEngineString) const;
void updateUrlLineEdit(const QUrl &newUrl);
void updateUserAgentLabel(const QString &userAgentDatabaseName) const;
QAction *cookiesActionPointer;
QUrl currentUrl;
QPushButton *currentZoomButtonPointer;
- double currentZoomFactor;
+ double currentZoomFactorDouble;
bool customSearchEngineEnabled;
bool customUserAgentEnabled;
- double defaultZoomFactor;
+ double defaultZoomFactorDouble;
QAction *developerToolsActionPointer;
QAction *domStorageActionPointer;
QComboBox *downloadDirectoryComboBoxPointer;
// The private functions.
void addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double folderId);
+ int calculateSettingsInt(const bool settingCurrentlyEnabled, const bool settingEnabledByDefault) const;
void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
void populateBookmarksToolBar();
void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);