-# Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2022-2024 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 <https://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/>.
# Set the minimum CMake version.
project(privacybrowser)
# Set the minimum framework versions.
-set(QT_MIN_VERSION "5.15.0")
-set(KDE_FRAMEWORKS_MIN_VERSION "5.83.0")
+set(QT_MIN_VERSION "6.0.0")
+set(KDE_FRAMEWORKS_MIN_VERSION "6.0.0")
# Load the Extra CMake Modules that correspond to the KDE Frameworks version.
find_package(ECM ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED NO_MODULE)
#set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# Load the Qt components.
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
PrintSupport
)
# Load the KDE Frameworks components.
-find_package(KF5 ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED COMPONENTS
+find_package(KF6 ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED COMPONENTS
Completion
ConfigWidgets
CoreAddons
-# Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2022-2024 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/>.
# Create the executable and add the resources.
add_executable(privacybrowser resources.qrc)
# Link the following libraries.
target_link_libraries(privacybrowser
- Qt5::Core
- Qt5::Gui
- Qt5::Sql
- Qt5::PrintSupport
- Qt5::Widgets
- Qt5::WebEngineCore
- Qt5::WebEngineWidgets
- KF5::Completion
- KF5::ConfigWidgets
- KF5::CoreAddons
- KF5::Crash
- KF5::DBusAddons
- KF5::DocTools
- KF5::I18n
- KF5::Notifications
- KF5::KIOCore
- KF5::KIOWidgets
- KF5::XmlGui
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::PrintSupport
+ Qt6::Widgets
+ Qt6::WebEngineCore
+ Qt6::WebEngineWidgets
+ KF6::Completion
+ KF6::ConfigWidgets
+ KF6::CoreAddons
+ KF6::Crash
+ KF6::DBusAddons
+ KF6::DocTools
+ KF6::I18n
+ KF6::Notifications
+ KF6::KIOCore
+ KF6::KIOWidgets
+ KF6::XmlGui
)
# Add the subdirectories.
-/*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
const int BookmarksDatabase::SCHEMA_VERSION = 0;
// Define the public static constants.
-const QString BookmarksDatabase::CONNECTION_NAME = "bookmarks_database";
-const QString BookmarksDatabase::BOOKMARK_NAME = "bookmark_name";
-const QString BookmarksDatabase::BOOKMARKS_TABLE = "bookmarks";
-const QString BookmarksDatabase::BOOKMARK_URL = "bookmark_url";
-const QString BookmarksDatabase::DISPLAY_ORDER = "display_order";
-const QString BookmarksDatabase::FAVORITE_ICON = "favorite_icon";
-const QString BookmarksDatabase::FOLDER_ID = "folder_id";
-const QString BookmarksDatabase::ID = "_id";
-const QString BookmarksDatabase::IS_FOLDER = "is_folder";
-const QString BookmarksDatabase::PARENT_FOLDER_ID = "parent_folder_id";
+const QString BookmarksDatabase::CONNECTION_NAME = QLatin1String("bookmarks_database");
+const QString BookmarksDatabase::BOOKMARK_NAME = QLatin1String("bookmark_name");
+const QString BookmarksDatabase::BOOKMARKS_TABLE = QLatin1String("bookmarks");
+const QString BookmarksDatabase::BOOKMARK_URL = QLatin1String("bookmark_url");
+const QString BookmarksDatabase::DISPLAY_ORDER = QLatin1String("display_order");
+const QString BookmarksDatabase::FAVORITE_ICON = QLatin1String("favorite_icon");
+const QString BookmarksDatabase::FOLDER_ID = QLatin1String("folder_id");
+const QString BookmarksDatabase::ID = QLatin1String("_id");
+const QString BookmarksDatabase::IS_FOLDER = QLatin1String("is_folder");
+const QString BookmarksDatabase::PARENT_FOLDER_ID = QLatin1String("parent_folder_id");
// Construct the class.
BookmarksDatabase::BookmarksDatabase() {}
QSqlDatabase bookmarksDatabase = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), CONNECTION_NAME);
// Set the database name.
- bookmarksDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/bookmarks.db");
+ bookmarksDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/bookmarks.db"));
// Open the database.
if (bookmarksDatabase.open()) // Opening the database succeeded.
// Check to see if the bookmarks table already exists.
if (bookmarksDatabase.tables().contains(BOOKMARKS_TABLE)) // The bookmarks table already exists.
{
+ // Create a schema version query.
+ QSqlQuery schemaVersionQuery(bookmarksDatabase);
+
// Query the database schema version.
- QSqlQuery schemaVersionQuery = bookmarksDatabase.exec(QStringLiteral("PRAGMA user_version"));
+ schemaVersionQuery.exec(QLatin1String("PRAGMA user_version"));
// Move to the first record.
schemaVersionQuery.first();
{
// Run the schema update code.
+ // Create an update schema version query.
+ QSqlQuery updateSchemaVersionQuery(bookmarksDatabase);
+
// Update the schema version.
- bookmarksDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+ updateSchemaVersionQuery.exec(QLatin1String("PRAGMA user_version = ") + QString::number(SCHEMA_VERSION));
}
}
else // The bookmarks table does not exist.
QSqlQuery createTableQuery(bookmarksDatabase);
// Populate the create table query.
- createTableQuery.prepare("CREATE TABLE " + BOOKMARKS_TABLE + "(" +
- ID + " INTEGER PRIMARY KEY, " +
- BOOKMARK_NAME + " TEXT, " +
- BOOKMARK_URL + " TEXT, " +
- PARENT_FOLDER_ID + " INTEGER DEFAULT 0, " +
- DISPLAY_ORDER + " INTEGER DEFAULT 0, " +
- IS_FOLDER + " BOOLEAN DEFAULT FALSE, " +
- FOLDER_ID + " INTEGER DEFAULT 0, " +
- FAVORITE_ICON + " BLOB)");
+ createTableQuery.prepare(QLatin1String("CREATE TABLE ") + BOOKMARKS_TABLE + QLatin1String("(") +
+ ID + QLatin1String(" INTEGER PRIMARY KEY, ") +
+ BOOKMARK_NAME + QLatin1String(" TEXT, ") +
+ BOOKMARK_URL + QLatin1String(" TEXT, ") +
+ PARENT_FOLDER_ID + QLatin1String(" INTEGER DEFAULT 0, ") +
+ DISPLAY_ORDER + QLatin1String(" INTEGER DEFAULT 0, ") +
+ IS_FOLDER + QLatin1String(" BOOLEAN DEFAULT FALSE, ") +
+ FOLDER_ID + QLatin1String(" INTEGER DEFAULT 0, ") +
+ FAVORITE_ICON + QLatin1String(" BLOB)"));
// Execute the query.
if (!createTableQuery.exec())
qDebug().noquote().nospace() << "Error creating table: " << bookmarksDatabase.lastError();
}
+ // Create an update schema version query.
+ QSqlQuery updateSchemaVersionQuery(bookmarksDatabase);
+
// Set the schema version.
- bookmarksDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+ updateSchemaVersionQuery.exec(QLatin1String("PRAGMA user_version = ") + QString::number(SCHEMA_VERSION));
}
}
else // Opening the database failed.
QSqlQuery addBookmarkQuery(bookmarksDatabase);
// Prepare the add bookmark query.
- addBookmarkQuery.prepare("INSERT INTO " + BOOKMARKS_TABLE + " (" +
- BOOKMARK_NAME + ", " +
- BOOKMARK_URL + ", " +
- PARENT_FOLDER_ID + ", " +
- DISPLAY_ORDER + ", " +
- FAVORITE_ICON + ") " +
- "VALUES (:bookmark_name, :bookmark_url, :parent_folder_id, :display_order, :favorite_icon)"
- );
+ addBookmarkQuery.prepare(QLatin1String("INSERT INTO ") + BOOKMARKS_TABLE + QLatin1String(" (") +
+ BOOKMARK_NAME + QLatin1String(", ") +
+ BOOKMARK_URL + QLatin1String(", ") +
+ PARENT_FOLDER_ID + QLatin1String(", ") +
+ DISPLAY_ORDER + QLatin1String(", ") +
+ FAVORITE_ICON + QLatin1String(") ") +
+ QLatin1String("VALUES (:bookmark_name, :bookmark_url, :parent_folder_id, :display_order, :favorite_icon)"));
// Bind the query values.
- addBookmarkQuery.bindValue(":bookmark_name", bookmarkStructPointer->name);
- addBookmarkQuery.bindValue(":bookmark_url", bookmarkStructPointer->url);
- addBookmarkQuery.bindValue(":parent_folder_id", bookmarkStructPointer->parentFolderId);
- addBookmarkQuery.bindValue(":display_order", folderItemCount);
- addBookmarkQuery.bindValue(":favorite_icon", getFavoriteIconBase64String(bookmarkStructPointer->favoriteIcon));
+ addBookmarkQuery.bindValue(QLatin1String(":bookmark_name"), bookmarkStructPointer->name);
+ addBookmarkQuery.bindValue(QLatin1String(":bookmark_url"), bookmarkStructPointer->url);
+ addBookmarkQuery.bindValue(QLatin1String(":parent_folder_id"), bookmarkStructPointer->parentFolderId);
+ addBookmarkQuery.bindValue(QLatin1String(":display_order"), folderItemCount);
+ addBookmarkQuery.bindValue(QLatin1String(":favorite_icon"), getFavoriteIconBase64String(bookmarkStructPointer->favoriteIcon));
// Execute the add bookmark query.
addBookmarkQuery.exec();
QSqlQuery addFolderQuery(bookmarksDatabase);
// Prepare the add folder query.
- addFolderQuery.prepare("INSERT INTO " + BOOKMARKS_TABLE + " (" +
- BOOKMARK_NAME + ", " +
- PARENT_FOLDER_ID + ", " +
- DISPLAY_ORDER + ", " +
- IS_FOLDER + ", " +
- FOLDER_ID + ", " +
- FAVORITE_ICON + ") " +
- "VALUES (:bookmark_name, :parent_folder_id, :display_order, :is_folder, :folder_id, :favorite_icon)"
- );
+ addFolderQuery.prepare(QLatin1String("INSERT INTO ") + BOOKMARKS_TABLE + QLatin1String(" (") +
+ BOOKMARK_NAME + QLatin1String(", ") +
+ PARENT_FOLDER_ID + QLatin1String(", ") +
+ DISPLAY_ORDER + QLatin1String(", ") +
+ IS_FOLDER + QLatin1String(", ") +
+ FOLDER_ID + QLatin1String(", ") +
+ FAVORITE_ICON + QLatin1String(") ") +
+ QLatin1String("VALUES (:bookmark_name, :parent_folder_id, :display_order, :is_folder, :folder_id, :favorite_icon)"));
// Bind the query values.
- addFolderQuery.bindValue(":bookmark_name", bookmarkStructPointer->name);
- addFolderQuery.bindValue(":parent_folder_id", bookmarkStructPointer->parentFolderId);
- addFolderQuery.bindValue(":display_order", folderItemCount);
- addFolderQuery.bindValue(":is_folder", 1);
- addFolderQuery.bindValue(":folder_id", generateFolderId());
- addFolderQuery.bindValue(":favorite_icon", getFavoriteIconBase64String(bookmarkStructPointer->favoriteIcon));
+ addFolderQuery.bindValue(QLatin1String(":bookmark_name"), bookmarkStructPointer->name);
+ addFolderQuery.bindValue(QLatin1String(":parent_folder_id"), bookmarkStructPointer->parentFolderId);
+ addFolderQuery.bindValue(QLatin1String(":display_order"), folderItemCount);
+ addFolderQuery.bindValue(QLatin1String(":is_folder"), 1);
+ addFolderQuery.bindValue(QLatin1String(":folder_id"), generateFolderId());
+ addFolderQuery.bindValue(QLatin1String(":favorite_icon"), getFavoriteIconBase64String(bookmarkStructPointer->favoriteIcon));
// Execute the add folder query.
addFolderQuery.exec();
QSqlQuery deleteBookmarkQuery(bookmarksDatabase);
// Prepare the delete bookmark query.
- deleteBookmarkQuery.prepare("DELETE FROM " + BOOKMARKS_TABLE + " WHERE " + ID + " = :id");
+ deleteBookmarkQuery.prepare(QLatin1String("DELETE FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- deleteBookmarkQuery.bindValue(":id", databaseId);
+ deleteBookmarkQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
deleteBookmarkQuery.exec();
QSqlQuery parentFolderIdsQuery(bookmarksDatabase);
// Prepare the parent folder IDs query.
- parentFolderIdsQuery.prepare("SELECT " + PARENT_FOLDER_ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + IS_FOLDER + " = 0 AND " + BOOKMARK_URL + " = :url");
+ parentFolderIdsQuery.prepare(QLatin1String("SELECT ") + PARENT_FOLDER_ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + IS_FOLDER + QLatin1String(" = 0 AND ") +
+ BOOKMARK_URL + QLatin1String(" = :url"));
// Bind the query values.
- parentFolderIdsQuery.bindValue(":url", url);
+ parentFolderIdsQuery.bindValue(QLatin1String(":url"), url);
// Execute the query.
parentFolderIdsQuery.exec();
QSqlQuery deleteBookmarksQuery(bookmarksDatabase);
// Prepare the delete bookmark query.
- deleteBookmarksQuery.prepare("DELETE FROM " + BOOKMARKS_TABLE + " WHERE " + IS_FOLDER + " = 0 AND " + BOOKMARK_URL + " = :url");
+ deleteBookmarksQuery.prepare(QLatin1String("DELETE FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + IS_FOLDER + QLatin1String(" = 0 AND ") + BOOKMARK_URL + QLatin1String(" = :url"));
// Bind the query values.
- deleteBookmarksQuery.bindValue(":url", url);
+ deleteBookmarksQuery.bindValue(QLatin1String(":url"), url);
// Execute the query.
deleteBookmarksQuery.exec();
QSqlQuery existingFolderQuery(bookmarksDatabase);
// Prepare the existing folder query.
- existingFolderQuery.prepare("SELECT " + ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + FOLDER_ID + " = :possible_folder_id");
+ existingFolderQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + FOLDER_ID + QLatin1String(" = :possible_folder_id"));
// Bind the query values.
- existingFolderQuery.bindValue(":possible_folder_id", possibleFolderId);
+ existingFolderQuery.bindValue(QLatin1String(":possible_folder_id"), possibleFolderId);
// Execute the query.
existingFolderQuery.exec();
folderUrlsQuery.setForwardOnly(true);
// Prepare the folder URLs query.
- folderUrlsQuery.prepare("SELECT " + BOOKMARK_URL + ", " + IS_FOLDER + ", " + FOLDER_ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id");
+ folderUrlsQuery.prepare(QLatin1String("SELECT ") + BOOKMARK_URL + QLatin1String(", ") + IS_FOLDER + QLatin1String(", ") + FOLDER_ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE +
+ QLatin1String(" WHERE ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id"));
// Bind the query values.
- folderUrlsQuery.bindValue(":parent_folder_id", folderId);
+ folderUrlsQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
folderUrlsQuery.exec();
bookmarkQuery.setForwardOnly(true);
// Prepare the bookmark query.
- bookmarkQuery.prepare("SELECT * FROM " + BOOKMARKS_TABLE + " WHERE " + ID + " = :id");
+ bookmarkQuery.prepare(QLatin1String("SELECT * FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- bookmarkQuery.bindValue(":id", databaseId);
+ bookmarkQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
bookmarkQuery.exec();
bookmarksQuery.setForwardOnly(true);
// Prepare the bookmarks query.
- bookmarksQuery.prepare("SELECT * FROM " + BOOKMARKS_TABLE + " ORDER BY " + DISPLAY_ORDER + " ASC");
+ bookmarksQuery.prepare(QLatin1String("SELECT * FROM ") + BOOKMARKS_TABLE + QLatin1String(" ORDER BY ") + DISPLAY_ORDER + QLatin1String(" ASC"));
// Execute the query.
bookmarksQuery.exec();
}
// Prepare the bookmarks query.
- bookmarksQuery.prepare("SELECT * FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id AND " + ID + " NOT IN (" + idsNotToGetString + ") ORDER BY " + DISPLAY_ORDER + " ASC");
+ bookmarksQuery.prepare(QLatin1String("SELECT * FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id AND ") + ID +
+ QLatin1String(" NOT IN (") + idsNotToGetString + QLatin1String(") ORDER BY ") + DISPLAY_ORDER + QLatin1String(" ASC"));
// Bind the query values.
- bookmarksQuery.bindValue(":parent_folder_id", folderId);
+ bookmarksQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
bookmarksQuery.exec();
favoriteIconBuffer.close();
// Convert the favorite icon byte array to a base 64 string.
- QString favoriteIconBase64String = favoriteIconByteArray.toBase64();
+ QString favoriteIconBase64String = QLatin1String(favoriteIconByteArray.toBase64());
// Return the favorite icon base 64 string.
return favoriteIconBase64String;
folderContentsQuery.setForwardOnly(true);
// Prepare the folder contents query.
- folderContentsQuery.prepare("SELECT * FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id ORDER BY " + DISPLAY_ORDER + " ASC");
+ folderContentsQuery.prepare(QLatin1String("SELECT * FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id ORDER BY ") + DISPLAY_ORDER +
+ QLatin1String(" ASC"));
// Bind the query values.
- folderContentsQuery.bindValue(":parent_folder_id", folderId);
+ folderContentsQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
folderContentsQuery.exec();
folderContentsQuery.setForwardOnly(true);
// Prepare the folder contents query.
- folderContentsQuery.prepare("SELECT " + ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id");
+ folderContentsQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id"));
// Bind the query values.
- folderContentsQuery.bindValue(":parent_folder_id", folderId);
+ folderContentsQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
folderContentsQuery.exec();
folderContentsQuery.setForwardOnly(true);
// Prepare the folder contents query.
- folderContentsQuery.prepare("SELECT " + ID + ", " + IS_FOLDER + ", " + FOLDER_ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id");
+ folderContentsQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(", ") + IS_FOLDER + QLatin1String(", ") + FOLDER_ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE +
+ QLatin1String(" WHERE ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id"));
// Bind the query values.
- folderContentsQuery.bindValue(":parent_folder_id", folderId);
+ folderContentsQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
folderContentsQuery.exec();
folderDatabaseIdQuery.setForwardOnly(true);
// Prepare the folder database ID query.
- folderDatabaseIdQuery.prepare("SELECT " + ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + FOLDER_ID + " = :folder_id");
+ folderDatabaseIdQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + FOLDER_ID + QLatin1String(" = :folder_id"));
// Bind the query values.
- folderDatabaseIdQuery.bindValue(":folder_id", folderId);
+ folderDatabaseIdQuery.bindValue(QLatin1String(":folder_id"), folderId);
// Execute the query.
folderDatabaseIdQuery.exec();
folderIdQuery.setForwardOnly(true);
// Prepare the folder ID query.
- folderIdQuery.prepare("SELECT " + FOLDER_ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + ID + " = :database_id");
+ folderIdQuery.prepare(QLatin1String("SELECT ") + FOLDER_ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = :database_id"));
// Bind the query values.
- folderIdQuery.bindValue(":database_id", databaseId);
+ folderIdQuery.bindValue(QLatin1String(":database_id"), databaseId);
// Execute the query.
folderIdQuery.exec();
folderContentsQuery.setForwardOnly(true);
// Prepare the folder contents query.
- folderContentsQuery.prepare("SELECT " + ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id");
+ folderContentsQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id"));
// Bind the query values.
- folderContentsQuery.bindValue(":parent_folder_id", folderId);
+ folderContentsQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
folderContentsQuery.exec();
parentFolderIdQuery.setForwardOnly(true);
// Prepare the parent folder ID query.
- parentFolderIdQuery.prepare("SELECT " + PARENT_FOLDER_ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + ID + " = :database_id");
+ parentFolderIdQuery.prepare(QLatin1String("SELECT ") + PARENT_FOLDER_ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = :database_id"));
// Bind the query values.
- parentFolderIdQuery.bindValue(":database_id", databaseId);
+ parentFolderIdQuery.bindValue(QLatin1String(":database_id"), databaseId);
// Execute the query.
parentFolderIdQuery.exec();
subfoldersQuery.setForwardOnly(true);
// Prepare the subfolders query.
- subfoldersQuery.prepare("SELECT * FROM " + BOOKMARKS_TABLE + " WHERE " + IS_FOLDER + " = 1 AND " + PARENT_FOLDER_ID + " = :parent_folder_id ORDER BY " + DISPLAY_ORDER + " ASC");
+ subfoldersQuery.prepare(QLatin1String("SELECT * FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + IS_FOLDER + QLatin1String(" = 1 AND ") + PARENT_FOLDER_ID +
+ QLatin1String(" = :parent_folder_id ORDER BY ") + DISPLAY_ORDER + QLatin1String(" ASC"));
// Bind the query values.
- subfoldersQuery.bindValue(":parent_folder_id", folderId);
+ subfoldersQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
subfoldersQuery.exec();
isBookmarkedQuery.setForwardOnly(true);
// Prepare the is bookmarked query.
- isBookmarkedQuery.prepare("SELECT " + ID + " FROM " + BOOKMARKS_TABLE + " WHERE " + IS_FOLDER + " = 0 AND " + BOOKMARK_URL + " = :url");
+ isBookmarkedQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + IS_FOLDER + QLatin1String(" = 0 AND ") + BOOKMARK_URL +
+ QLatin1String(" = :url"));
// Bind the query values.
- isBookmarkedQuery.bindValue(":url", url);
+ isBookmarkedQuery.bindValue(QLatin1String(":url"), url);
// Execute the query.
isBookmarkedQuery.exec();
isFolderQuery.setForwardOnly(true);
// Prepare the is folder query.
- isFolderQuery.prepare("SELECT " + IS_FOLDER + " FROM " + BOOKMARKS_TABLE + " WHERE " + ID + " = :id");
+ isFolderQuery.prepare(QLatin1String("SELECT ") + IS_FOLDER + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- isFolderQuery.bindValue(":id", databaseId);
+ isFolderQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
isFolderQuery.exec();
QSqlQuery updateBookmarkQuery(bookmarksDatabase);
// Prepare the update bookmark query.
- updateBookmarkQuery.prepare("UPDATE " + BOOKMARKS_TABLE + " SET " +
- BOOKMARK_NAME + " = :bookmark_name, " +
- BOOKMARK_URL + " = :bookmark_url, " +
- PARENT_FOLDER_ID + " = :parent_folder_id, " +
- DISPLAY_ORDER + " = :display_order, " +
- FAVORITE_ICON + "= :favorite_icon " +
- "WHERE " + ID + " = :id");
+ updateBookmarkQuery.prepare(QLatin1String("UPDATE ") + BOOKMARKS_TABLE + QLatin1String(" SET ") +
+ BOOKMARK_NAME + QLatin1String(" = :bookmark_name, ") +
+ BOOKMARK_URL + QLatin1String(" = :bookmark_url, ") +
+ PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id, ") +
+ DISPLAY_ORDER + QLatin1String(" = :display_order, ") +
+ FAVORITE_ICON + QLatin1String("= :favorite_icon ") +
+ QLatin1String("WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- updateBookmarkQuery.bindValue(":bookmark_name", bookmarkStructPointer->name);
- updateBookmarkQuery.bindValue(":bookmark_url", bookmarkStructPointer->url);
- updateBookmarkQuery.bindValue(":parent_folder_id", bookmarkStructPointer->parentFolderId);
- updateBookmarkQuery.bindValue(":display_order", bookmarkStructPointer->displayOrder);
- updateBookmarkQuery.bindValue(":favorite_icon", getFavoriteIconBase64String(bookmarkStructPointer->favoriteIcon));
- updateBookmarkQuery.bindValue(":id", bookmarkStructPointer->databaseId);
+ updateBookmarkQuery.bindValue(QLatin1String(":bookmark_name"), bookmarkStructPointer->name);
+ updateBookmarkQuery.bindValue(QLatin1String(":bookmark_url"), bookmarkStructPointer->url);
+ updateBookmarkQuery.bindValue(QLatin1String(":parent_folder_id"), bookmarkStructPointer->parentFolderId);
+ updateBookmarkQuery.bindValue(QLatin1String(":display_order"), bookmarkStructPointer->displayOrder);
+ updateBookmarkQuery.bindValue(QLatin1String(":favorite_icon"), getFavoriteIconBase64String(bookmarkStructPointer->favoriteIcon));
+ updateBookmarkQuery.bindValue(QLatin1String(":id"), bookmarkStructPointer->databaseId);
// Execute the query.
updateBookmarkQuery.exec();
QSqlQuery updateBookmarkNameQuery(bookmarksDatabase);
// Prepare the update bookmark name query.
- updateBookmarkNameQuery.prepare("UPDATE " + BOOKMARKS_TABLE +
- " SET " + BOOKMARK_NAME + " = :bookmark_name " +
- "WHERE " + ID + " = :id");
+ updateBookmarkNameQuery.prepare(QLatin1String("UPDATE ") + BOOKMARKS_TABLE +
+ QLatin1String(" SET ") + BOOKMARK_NAME + QLatin1String(" = :bookmark_name ") +
+ QLatin1String("WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- updateBookmarkNameQuery.bindValue(":bookmark_name", bookmarkName);
- updateBookmarkNameQuery.bindValue(":id", databaseId);
+ updateBookmarkNameQuery.bindValue(QLatin1String(":bookmark_name"), bookmarkName);
+ updateBookmarkNameQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
updateBookmarkNameQuery.exec();
QSqlQuery updateBookmarkUrlQuery(bookmarksDatabase);
// Prepare the update bookmark URL query.
- updateBookmarkUrlQuery.prepare("UPDATE " + BOOKMARKS_TABLE +
- " SET " + BOOKMARK_URL + " = :bookmark_url " +
- "WHERE " + ID + " = :id");
+ updateBookmarkUrlQuery.prepare(QLatin1String("UPDATE ") + BOOKMARKS_TABLE +
+ QLatin1String(" SET ") + BOOKMARK_URL + QLatin1String(" = :bookmark_url ") +
+ QLatin1String("WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- updateBookmarkUrlQuery.bindValue(":bookmark_url", bookmarkUrl);
- updateBookmarkUrlQuery.bindValue(":id", databaseId);
+ updateBookmarkUrlQuery.bindValue(QLatin1String(":bookmark_url"), bookmarkUrl);
+ updateBookmarkUrlQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
updateBookmarkUrlQuery.exec();
QSqlQuery updateBookmarkDisplayOrderQuery(bookmarksDatabase);
// Prepare the update bookmark display order query.
- updateBookmarkDisplayOrderQuery.prepare("UPDATE " + BOOKMARKS_TABLE +
- " SET " + DISPLAY_ORDER + " = :display_order " +
- "WHERE " + ID + " = :id");
+ updateBookmarkDisplayOrderQuery.prepare(QLatin1String("UPDATE ") + BOOKMARKS_TABLE +
+ QLatin1String(" SET ") + DISPLAY_ORDER + QLatin1String(" = :display_order ") +
+ QLatin1String("WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- updateBookmarkDisplayOrderQuery.bindValue(":display_order", displayOrder);
- updateBookmarkDisplayOrderQuery.bindValue(":id", databaseId);
+ updateBookmarkDisplayOrderQuery.bindValue(QLatin1String(":display_order"), displayOrder);
+ updateBookmarkDisplayOrderQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
updateBookmarkDisplayOrderQuery.exec();
folderContentsQuery.setForwardOnly(true);
// Prepare the folder contents query.
- folderContentsQuery.prepare("SELECT " + ID + ", " + DISPLAY_ORDER + " FROM " + BOOKMARKS_TABLE + " WHERE " + PARENT_FOLDER_ID + " = :parent_folder_id ORDER BY " + DISPLAY_ORDER + " ASC");
+ folderContentsQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(", ") + DISPLAY_ORDER + QLatin1String(" FROM ") + BOOKMARKS_TABLE + QLatin1String(" WHERE ") + PARENT_FOLDER_ID +
+ QLatin1String(" = :parent_folder_id ORDER BY ") + DISPLAY_ORDER + QLatin1String(" ASC"));
// Bind the query values.
- folderContentsQuery.bindValue(":parent_folder_id", folderId);
+ folderContentsQuery.bindValue(QLatin1String(":parent_folder_id"), folderId);
// Execute the query.
folderContentsQuery.exec();
QSqlQuery updateBookmarkDisplayOrderQuery(bookmarksDatabase);
// Prepare the update bookmark display order query.
- updateBookmarkDisplayOrderQuery.prepare("UPDATE " + BOOKMARKS_TABLE +
- " SET " + PARENT_FOLDER_ID + " = :parent_folder_id " +
- ", " + DISPLAY_ORDER + " = :display_order " +
- "WHERE " + ID + " = :id");
+ updateBookmarkDisplayOrderQuery.prepare(QLatin1String("UPDATE ") + BOOKMARKS_TABLE +
+ QLatin1String(" SET ") + PARENT_FOLDER_ID + QLatin1String(" = :parent_folder_id ,") +
+ DISPLAY_ORDER + QLatin1String(" = :display_order ") +
+ QLatin1String("WHERE ") + ID + QLatin1String(" = :id"));
// Bind the query values.
- updateBookmarkDisplayOrderQuery.bindValue(":parent_folder_id", parentFolderId);
- updateBookmarkDisplayOrderQuery.bindValue(":display_order", displayOrder);
- updateBookmarkDisplayOrderQuery.bindValue(":id", databaseId);
+ updateBookmarkDisplayOrderQuery.bindValue(QLatin1String(":parent_folder_id"), parentFolderId);
+ updateBookmarkDisplayOrderQuery.bindValue(QLatin1String(":display_order"), displayOrder);
+ updateBookmarkDisplayOrderQuery.bindValue(QLatin1String(":id"), databaseId);
// Execute the query.
updateBookmarkDisplayOrderQuery.exec();
-/*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 BOOKMARKSDATABASE_H
-/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
const int CookiesDatabase::SCHEMA_VERSION = 0;
// Define the public static constants.
-const QString CookiesDatabase::CONNECTION_NAME = "cookies_database";
-const QString CookiesDatabase::COOKIES_TABLE = "cookies";
-const QString CookiesDatabase::DOMAIN = "domain";
-const QString CookiesDatabase::EXPIRATION_DATE = "expiration_date";
-const QString CookiesDatabase::HTTP_ONLY = "http_only";
-const QString CookiesDatabase::ID = "_id";
-const QString CookiesDatabase::NAME = "name";
-const QString CookiesDatabase::PATH = "path";
-const QString CookiesDatabase::SECURE = "secure";
-const QString CookiesDatabase::VALUE = "value";
+const QString CookiesDatabase::CONNECTION_NAME = QLatin1String("cookies_database");
+const QString CookiesDatabase::COOKIES_TABLE = QLatin1String("cookies");
+const QString CookiesDatabase::DOMAIN = QLatin1String("domain");
+const QString CookiesDatabase::EXPIRATION_DATE = QLatin1String("expiration_date");
+const QString CookiesDatabase::HTTP_ONLY = QLatin1String("http_only");
+const QString CookiesDatabase::ID = QLatin1String("_id");
+const QString CookiesDatabase::NAME = QLatin1String("name");
+const QString CookiesDatabase::PATH = QLatin1String("path");
+const QString CookiesDatabase::SECURE = QLatin1String("secure");
+const QString CookiesDatabase::VALUE = QLatin1String("value");
// Construct the class.
CookiesDatabase::CookiesDatabase() {}
QSqlDatabase cookiesDatabase = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), CONNECTION_NAME);
// Set the database name.
- cookiesDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/cookies.db");
+ cookiesDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/cookies.db"));
// Open the database.
if (cookiesDatabase.open()) // Opening the database succeeded.
// Check to see if the cookies table already exists.
if (cookiesDatabase.tables().contains(COOKIES_TABLE)) // The cookies table exists.
{
+ // Create a schema version query.
+ QSqlQuery schemaVersionQuery(cookiesDatabase);
+
// Query the database schema version.
- QSqlQuery schemaVersionQuery = cookiesDatabase.exec(QStringLiteral("PRAGMA user_version"));
+ schemaVersionQuery.exec(QLatin1String("PRAGMA user_version"));
// Move to the first record.
schemaVersionQuery.first();
// Upgrade code here.
}
+ // Create an update schema version version.
+ QSqlQuery updateSchemaVersionQuery = QSqlQuery(cookiesDatabase);
+
// Update the schema version.
- cookiesDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+ updateSchemaVersionQuery.exec(QLatin1String("PRAGMA user_version = ") + QString::number(SCHEMA_VERSION));
}
}
else // The cookies table does not exist.
QSqlQuery createTableQuery(cookiesDatabase);
// Prepare the create table query.
- createTableQuery.prepare("CREATE TABLE " + COOKIES_TABLE + "(" +
- ID + " INTEGER PRIMARY KEY, " +
- DOMAIN + " TEXT NOT NULL, " +
- NAME + " TEXT NOT NULL, " +
- PATH + " TEXT NOT NULL, " +
- EXPIRATION_DATE + " TEXT, " +
- HTTP_ONLY + " INTEGER NOT NULL DEFAULT 0, " +
- SECURE + " INTEGER NOT NULL DEFAULT 0, " +
- VALUE + " TEXT NOT NULL)");
+ createTableQuery.prepare(QLatin1String("CREATE TABLE ") + COOKIES_TABLE + QLatin1String("(") +
+ ID + QLatin1String(" INTEGER PRIMARY KEY, ") +
+ DOMAIN + QLatin1String(" TEXT NOT NULL, ") +
+ NAME + QLatin1String(" TEXT NOT NULL, ") +
+ PATH + QLatin1String(" TEXT NOT NULL, ") +
+ EXPIRATION_DATE + QLatin1String(" TEXT, ") +
+ HTTP_ONLY + QLatin1String(" INTEGER NOT NULL DEFAULT 0, ") +
+ SECURE + QLatin1String(" INTEGER NOT NULL DEFAULT 0, ") +
+ VALUE + QLatin1String(" TEXT NOT NULL)"));
// Execute the query.
if (!createTableQuery.exec())
qDebug().noquote().nospace() << "Error creating table: " << cookiesDatabase.lastError();
}
+ // Create an set schema version version.
+ QSqlQuery setSchemaVersionQuery(cookiesDatabase);
+
// Set the schema version.
- cookiesDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+ setSchemaVersionQuery.exec(QLatin1String("PRAGMA user_version = ") + QString::number(SCHEMA_VERSION));
}
}
else // Opening the database failed.
QSqlQuery addCookieQuery(cookiesDatabase);
// Prepare the add cookie query.
- addCookieQuery.prepare("INSERT INTO " + COOKIES_TABLE + " (" +
- DOMAIN + ", " +
- NAME + ", " +
- PATH + ", " +
- EXPIRATION_DATE + ", " +
- HTTP_ONLY + ", " +
- SECURE + ", " +
- VALUE + ") "
- "VALUES (:domain, :name, :path, :expiration_date, :http_only, :secure, :value)"
- );
+ addCookieQuery.prepare(QLatin1String("INSERT INTO ") + COOKIES_TABLE + QLatin1String(" (") +
+ DOMAIN + QLatin1String(", ") +
+ NAME + QLatin1String(", ") +
+ PATH + QLatin1String(", ") +
+ EXPIRATION_DATE + QLatin1String(", ") +
+ HTTP_ONLY + QLatin1String(", ") +
+ SECURE + QLatin1String(", ") +
+ VALUE + QLatin1String(") ") +
+ QLatin1String("VALUES (:domain, :name, :path, :expiration_date, :http_only, :secure, :value)"));
// Bind the values.
- addCookieQuery.bindValue(":domain", cookie.domain());
- addCookieQuery.bindValue(":name", QString(cookie.name()));
- addCookieQuery.bindValue(":path", cookie.path());
- addCookieQuery.bindValue(":expiration_date", cookie.expirationDate());
- addCookieQuery.bindValue(":http_only", cookie.isHttpOnly());
- addCookieQuery.bindValue(":secure", cookie.isSecure());
- addCookieQuery.bindValue(":value", QString(cookie.value()));
+ addCookieQuery.bindValue(QLatin1String(":domain"), cookie.domain());
+ addCookieQuery.bindValue(QLatin1String(":name"), QLatin1String(cookie.name()));
+ addCookieQuery.bindValue(QLatin1String(":path"), cookie.path());
+ addCookieQuery.bindValue(QLatin1String(":expiration_date"), cookie.expirationDate());
+ addCookieQuery.bindValue(QLatin1String(":http_only"), cookie.isHttpOnly());
+ addCookieQuery.bindValue(QLatin1String(":secure"), cookie.isSecure());
+ addCookieQuery.bindValue(QLatin1String(":value"), QLatin1String(cookie.value()));
// Execute the query.
addCookieQuery.exec();
countCookiesQuery.setForwardOnly(true);
// Prepare the query.
- countCookiesQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE);
+ countCookiesQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + COOKIES_TABLE);
// Execute the query.
countCookiesQuery.exec();
QSqlQuery deleteAllCookiesQuery(cookiesDatabase);
// Prepare the delete all cookies query.
- deleteAllCookiesQuery.prepare("DELETE FROM " + COOKIES_TABLE);
+ deleteAllCookiesQuery.prepare(QLatin1String("DELETE FROM ") + COOKIES_TABLE);
// Execute the query.
deleteAllCookiesQuery.exec();
QSqlQuery deleteCookieQuery(cookiesDatabase);
// Prepare the delete cookie query.
- deleteCookieQuery.prepare("DELETE FROM " + COOKIES_TABLE + " WHERE " +
- DOMAIN + " = :domain AND " +
- NAME + " = :name AND " +
- PATH + " = :path");
+ deleteCookieQuery.prepare(QLatin1String("DELETE FROM ") + COOKIES_TABLE + QLatin1String(" WHERE ") +
+ DOMAIN + QLatin1String(" = :domain AND ") +
+ NAME + QLatin1String(" = :name AND ") +
+ PATH + QLatin1String(" = :path"));
// Bind the values.
- deleteCookieQuery.bindValue(":domain", cookie.domain());
- deleteCookieQuery.bindValue(":name", QString(cookie.name()));
- deleteCookieQuery.bindValue(":path", cookie.path());
+ deleteCookieQuery.bindValue(QLatin1String(":domain"), cookie.domain());
+ deleteCookieQuery.bindValue(QLatin1String(":name"), QLatin1String(cookie.name()));
+ deleteCookieQuery.bindValue(QLatin1String(":path"), cookie.path());
// Execute the query.
deleteCookieQuery.exec();
cookiesQuery.setForwardOnly(true);
// Prepare the cookies query.
- cookiesQuery.prepare("SELECT * FROM " + COOKIES_TABLE);
+ cookiesQuery.prepare(QLatin1String("SELECT * FROM ") + COOKIES_TABLE);
// Execute the query.
cookiesQuery.exec();
cookieQuery.setForwardOnly(true);
// Prepare the cookies query.
- cookieQuery.prepare("SELECT * FROM " + COOKIES_TABLE + " WHERE " + ID + " = :id");
+ cookieQuery.prepare(QLatin1String("SELECT * FROM ") + COOKIES_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = :id"));
// Bind the values.
- cookieQuery.bindValue(":id", id);
+ cookieQuery.bindValue(QLatin1String(":id"), id);
// Execute the query.
cookieQuery.exec();
isDurableQuery.setForwardOnly(true);
// Prepare the is durable query.
- isDurableQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE + " WHERE " +
- DOMAIN + " = :domain AND " +
- NAME + " = :name AND " +
- PATH + " = :path");
+ isDurableQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + COOKIES_TABLE + QLatin1String(" WHERE ") +
+ DOMAIN + QLatin1String(" = :domain AND ") +
+ NAME + QLatin1String(" = :name AND ") +
+ PATH + QLatin1String(" = :path"));
// Bind the values.
- isDurableQuery.bindValue(":domain", cookie.domain());
- isDurableQuery.bindValue(":name", QString(cookie.name()));
- isDurableQuery.bindValue(":path", cookie.path());
+ isDurableQuery.bindValue(QLatin1String(":domain"), cookie.domain());
+ isDurableQuery.bindValue(QLatin1String(":name"), QLatin1String(cookie.name()));
+ isDurableQuery.bindValue(QLatin1String(":path"), cookie.path());
// Execute the query.
isDurableQuery.exec();
QSqlQuery isUpdateQuery(cookiesDatabase);
// Prepare the is update query.
- isUpdateQuery.prepare("SELECT " + EXPIRATION_DATE + " , " +
- HTTP_ONLY + " , " +
- SECURE + " , " +
+ isUpdateQuery.prepare(QLatin1String("SELECT ") + EXPIRATION_DATE + QLatin1String(" , ") +
+ HTTP_ONLY + QLatin1String(" , ") +
+ SECURE + QLatin1String(" , ") +
VALUE +
- " FROM " + COOKIES_TABLE +
- " WHERE " + DOMAIN + " = :domain AND " +
- NAME + " = :name AND " +
- PATH + " = :path");
+ QLatin1String(" FROM ") + COOKIES_TABLE +
+ QLatin1String(" WHERE ") + DOMAIN + QLatin1String(" = :domain AND ") +
+ NAME + QLatin1String(" = :name AND ") +
+ PATH + QLatin1String(" = :path"));
// Bind the values.
- isUpdateQuery.bindValue(":domain", cookie.domain());
- isUpdateQuery.bindValue(":name", QString(cookie.name()));
- isUpdateQuery.bindValue(":path", cookie.path());
+ isUpdateQuery.bindValue(QLatin1String(":domain"), cookie.domain());
+ isUpdateQuery.bindValue(QLatin1String(":name"), QLatin1String(cookie.name()));
+ isUpdateQuery.bindValue(QLatin1String(":path"), cookie.path());
// Execute the query.
isUpdateQuery.exec();
QSqlQuery updateCookieQuery(cookiesDatabase);
// Prepare the update cookie query.
- updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
- " SET " + EXPIRATION_DATE + " = :expiration_date , " +
- HTTP_ONLY + " = :http_only , " +
- SECURE + " = :secure , " +
- VALUE + " = :value " +
- "WHERE " + DOMAIN + " = :domain AND " +
- NAME + " = :name AND " +
- PATH + " = :path");
+ updateCookieQuery.prepare(QLatin1String("UPDATE ") + COOKIES_TABLE +
+ QLatin1String(" SET ") + EXPIRATION_DATE + QLatin1String(" = :expiration_date , ") +
+ HTTP_ONLY + QLatin1String(" = :http_only , ") +
+ SECURE + QLatin1String(" = :secure , ") +
+ VALUE + QLatin1String(" = :value ") +
+ QLatin1String("WHERE ") + DOMAIN + QLatin1String(" = :domain AND ") +
+ NAME + QLatin1String(" = :name AND ") +
+ PATH + QLatin1String(" = :path"));
// Bind the values.
- updateCookieQuery.bindValue(":domain", cookie.domain());
- updateCookieQuery.bindValue(":name", QString(cookie.name()));
- updateCookieQuery.bindValue(":path", cookie.path());
- updateCookieQuery.bindValue(":expiration_date", cookie.expirationDate());
- updateCookieQuery.bindValue(":http_only", cookie.isHttpOnly());
- updateCookieQuery.bindValue(":secure", cookie.isSecure());
- updateCookieQuery.bindValue(":value", QString(cookie.value()));
+ updateCookieQuery.bindValue(QLatin1String(":domain"), cookie.domain());
+ updateCookieQuery.bindValue(QLatin1String(":name"), QLatin1String(cookie.name()));
+ updateCookieQuery.bindValue(QLatin1String(":path"), cookie.path());
+ updateCookieQuery.bindValue(QLatin1String(":expiration_date"), cookie.expirationDate());
+ updateCookieQuery.bindValue(QLatin1String(":http_only"), cookie.isHttpOnly());
+ updateCookieQuery.bindValue(QLatin1String(":secure"), cookie.isSecure());
+ updateCookieQuery.bindValue(QLatin1String(":value"), QLatin1String(cookie.value()));
// Execute the query.
updateCookieQuery.exec();
oldCookieQuery.setForwardOnly(true);
// Prepare the old cookie query.
- oldCookieQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE +
- " WHERE " + DOMAIN + " = :domain AND " +
- NAME + " = :name AND " +
- PATH + " = :path");
+ oldCookieQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(" FROM ") + COOKIES_TABLE +
+ QLatin1String(" WHERE ") + DOMAIN + QLatin1String(" = :domain AND ") +
+ NAME + QLatin1String(" = :name AND ") +
+ PATH + QLatin1String(" = :path"));
// Bind the values.
- oldCookieQuery.bindValue(":domain", oldCookie.domain());
- oldCookieQuery.bindValue(":name", QString(oldCookie.name()));
- oldCookieQuery.bindValue(":path", oldCookie.path());
+ oldCookieQuery.bindValue(QLatin1String(":domain"), oldCookie.domain());
+ oldCookieQuery.bindValue(QLatin1String(":name"), QLatin1String(oldCookie.name()));
+ oldCookieQuery.bindValue(QLatin1String(":path"), oldCookie.path());
// Execute the query.
oldCookieQuery.exec();
QSqlQuery updateCookieQuery(cookiesDatabase);
// Prepare the update cookie query.
- updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
- " SET " + DOMAIN + " = :domain , " +
- NAME + " = :name , " +
- PATH + " = :path , " +
- EXPIRATION_DATE + " = :expiration_date , " +
- HTTP_ONLY + " = :http_only , " +
- SECURE + " = :secure , " +
- VALUE + " = :value " +
- "WHERE " + ID + " = :id");
+ updateCookieQuery.prepare(QLatin1String("UPDATE ") + COOKIES_TABLE +
+ QLatin1String(" SET ") + DOMAIN + QLatin1String(" = :domain , ") +
+ NAME + QLatin1String(" = :name , ") +
+ PATH + QLatin1String(" = :path , ") +
+ EXPIRATION_DATE + QLatin1String(" = :expiration_date , ") +
+ HTTP_ONLY + QLatin1String(" = :http_only , ") +
+ SECURE + QLatin1String(" = :secure , ") +
+ VALUE + QLatin1String(" = :value ") +
+ QLatin1String("WHERE ") + ID + QLatin1String(" = :id"));
// Bind the values.
- updateCookieQuery.bindValue(":id", oldCookieQuery.value(0).toLongLong());
- updateCookieQuery.bindValue(":domain", newCookie.domain());
- updateCookieQuery.bindValue(":name", QString(newCookie.name()));
- updateCookieQuery.bindValue(":path", newCookie.path());
- updateCookieQuery.bindValue(":expiration_date", newCookie.expirationDate());
- updateCookieQuery.bindValue(":http_only", newCookie.isHttpOnly());
- updateCookieQuery.bindValue(":secure", newCookie.isSecure());
- updateCookieQuery.bindValue(":value", QString(newCookie.value()));
+ updateCookieQuery.bindValue(QLatin1String(":id"), oldCookieQuery.value(0).toLongLong());
+ updateCookieQuery.bindValue(QLatin1String(":domain"), newCookie.domain());
+ updateCookieQuery.bindValue(QLatin1String(":name"), QLatin1String(newCookie.name()));
+ updateCookieQuery.bindValue(QLatin1String(":path"), newCookie.path());
+ updateCookieQuery.bindValue(QLatin1String(":expiration_date"), newCookie.expirationDate());
+ updateCookieQuery.bindValue(QLatin1String(":http_only"), newCookie.isHttpOnly());
+ updateCookieQuery.bindValue(QLatin1String(":secure"), newCookie.isSecure());
+ updateCookieQuery.bindValue(QLatin1String(":value"), QLatin1String(newCookie.value()));
// Execute the query.
updateCookieQuery.exec();
-/*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2023 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 COOKIESDATABASE_H
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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.
const int DomainsDatabase::SCHEMA_VERSION = 7;
// Define the public static constants.
-const QString DomainsDatabase::CONNECTION_NAME = "domains_database";
-const QString DomainsDatabase::CUSTOM_ZOOM_FACTOR = "custom_zoom_factor";
-const QString DomainsDatabase::DOM_STORAGE = "dom_storage";
-const QString DomainsDatabase::DOMAIN_NAME = "domain_name";
-const QString DomainsDatabase::DOMAINS_TABLE = "domains";
-const QString DomainsDatabase::EASYLIST = "easylist";
-const QString DomainsDatabase::EASYPRIVACY = "easyprivacy";
-const QString DomainsDatabase::FANBOYS_ANNOYANCE_LIST = "fanboys_annoyance_list";
-const QString DomainsDatabase::ID = "_id";
-const QString DomainsDatabase::JAVASCRIPT = "javascript";
-const QString DomainsDatabase::LOCAL_STORAGE = "local_storage";
-const QString DomainsDatabase::ULTRALIST = "ultralist";
-const QString DomainsDatabase::ULTRAPRIVACY = "ultraprivacy";
-const QString DomainsDatabase::USER_AGENT = "user_agent";
-const QString DomainsDatabase::ZOOM_FACTOR = "zoom_factor";
+const QString DomainsDatabase::CONNECTION_NAME = QLatin1String("domains_database");
+const QString DomainsDatabase::CUSTOM_ZOOM_FACTOR = QLatin1String("custom_zoom_factor");
+const QString DomainsDatabase::DOM_STORAGE = QLatin1String("dom_storage");
+const QString DomainsDatabase::DOMAIN_NAME = QLatin1String("domain_name");
+const QString DomainsDatabase::DOMAINS_TABLE = QLatin1String("domains");
+const QString DomainsDatabase::EASYLIST = QLatin1String("easylist");
+const QString DomainsDatabase::EASYPRIVACY = QLatin1String("easyprivacy");
+const QString DomainsDatabase::FANBOYS_ANNOYANCE_LIST = QLatin1String("fanboys_annoyance_list");
+const QString DomainsDatabase::ID = QLatin1String("_id");
+const QString DomainsDatabase::JAVASCRIPT = QLatin1String("javascript");
+const QString DomainsDatabase::LOCAL_STORAGE = QLatin1String("local_storage");
+const QString DomainsDatabase::ULTRALIST = QLatin1String("ultralist");
+const QString DomainsDatabase::ULTRAPRIVACY = QLatin1String("ultraprivacy");
+const QString DomainsDatabase::USER_AGENT = QLatin1String("user_agent");
+const QString DomainsDatabase::ZOOM_FACTOR = QLatin1String("zoom_factor");
// Construct the class.
DomainsDatabase::DomainsDatabase() {}
QSqlDatabase domainsDatabase = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), CONNECTION_NAME);
// Set the database name.
- domainsDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/domains.db");
+ domainsDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/domains.db"));
// Open the database.
if (domainsDatabase.open()) // Opening the database succeeded.
// Check to see if the domains table already exists.
if (domainsDatabase.tables().contains(DOMAINS_TABLE)) // The domains table already exists.
{
+ // Create a schema version query.
+ QSqlQuery schemaVersionQuery(domainsDatabase);
+
// Query the database schema version.
- QSqlQuery schemaVersionQuery = domainsDatabase.exec(QStringLiteral("PRAGMA user_version"));
+ schemaVersionQuery.exec(QLatin1String("PRAGMA user_version"));
// Move to the first record.
schemaVersionQuery.first();
// Upgrade from schema version 0 to schema version 1.
case 0:
{
+ // Create an add JavaScript query.
+ QSqlQuery addJavaScriptQuery(domainsDatabase);
+
// Add the JavaScript column.
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + JAVASCRIPT + " INTEGER DEFAULT 0");
+ addJavaScriptQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + JAVASCRIPT + QLatin1String(" INTEGER DEFAULT 0"));
// Fall through to the next case.
[[fallthrough]];
// Upgrade from schema version 1 to schema version 2.
case 1:
{
+ // Create an add user agent query.
+ QSqlQuery addUserAgentQuery(domainsDatabase);
+
// Add the User Agent column.
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "'");
+ addUserAgentQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + USER_AGENT + QLatin1String(" TEXT DEFAULT '") +
+ UserAgentHelper::SYSTEM_DEFAULT_DATABASE + QLatin1String("'"));
// Fall through to the next case.
[[fallthrough]];
// Upgrade from schema version 2 to schema version 3.
case 2:
{
+ // Create an add zoom factor query.
+ QSqlQuery addZoomFactorQuery(domainsDatabase);
+
// Add the Zoom Factor columns.
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ZOOM_FACTOR + " INTEGER DEFAULT 0");
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0");
+ addZoomFactorQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + ZOOM_FACTOR + QLatin1String(" INTEGER DEFAULT 0"));
+ addZoomFactorQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + CUSTOM_ZOOM_FACTOR + QLatin1String(" REAL DEFAULT 1.0"));
// Fall through to the next case.
[[fallthrough]];
// Upgrade from schema version 3 to schema version 4.
case 3:
{
+ // Create an add DOM storage query.
+ QSqlQuery addDomStorageQuery(domainsDatabase);
+
// Add the DOM Storage column.
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + DOM_STORAGE + " INTEGER DEFAULT 0");
+ addDomStorageQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + DOM_STORAGE + QLatin1String(" INTEGER DEFAULT 0"));
// Fall through to the next case.
[[fallthrough]];
// Upgrade from schema version 4 to schema version 5, first used in Privacy Browser PC 0.1.
case 4:
{
+ // Create an add local storage query.
+ QSqlQuery addLocalStorageQuery(domainsDatabase);
+
// Add the Local Storage column.
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + LOCAL_STORAGE + " INTEGER DEFAULT 0");
+ addLocalStorageQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + LOCAL_STORAGE + QLatin1String(" INTEGER DEFAULT 0"));
// Fall through to the next case.
[[fallthrough]];
spinnerQuery.setForwardOnly(true);
// Prepare the query.
- spinnerQuery.prepare("SELECT " + ID + "," + JAVASCRIPT + "," + LOCAL_STORAGE + "," + DOM_STORAGE + " FROM " + DOMAINS_TABLE);
+ spinnerQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(",") + JAVASCRIPT + QLatin1String(",") + LOCAL_STORAGE + QLatin1String(",") + DOM_STORAGE +
+ QLatin1String(" FROM ") + DOMAINS_TABLE);
// Execute the query.
spinnerQuery.exec();
QSqlQuery updateSpinnerQuery(domainsDatabase);
// Prepare the update spinner query.
- updateSpinnerQuery.prepare("UPDATE " + DOMAINS_TABLE + " SET " +
- JAVASCRIPT + " = :javascript , " +
- LOCAL_STORAGE + " = :local_storage , " +
- DOM_STORAGE + " = :dom_storage " +
- " WHERE " + ID + " = :id");
+ updateSpinnerQuery.prepare(QLatin1String("UPDATE ") + DOMAINS_TABLE + QLatin1String(" SET ") +
+ JAVASCRIPT + QLatin1String(" = :javascript , ") +
+ LOCAL_STORAGE + QLatin1String(" = :local_storage , ") +
+ DOM_STORAGE + QLatin1String(" = :dom_storage ") +
+ QLatin1String(" WHERE ") + ID + QLatin1String(" = :id"));
// Bind the values.
- updateSpinnerQuery.bindValue(":javascript", newJavaScriptValue);
- updateSpinnerQuery.bindValue(":local_storage", newLocalStorageValue);
- updateSpinnerQuery.bindValue(":dom_storage", newDomStorageValue);
- updateSpinnerQuery.bindValue(":id", spinnerQuery.value(ID));
+ updateSpinnerQuery.bindValue(QLatin1String(":javascript"), newJavaScriptValue);
+ updateSpinnerQuery.bindValue(QLatin1String(":local_storage"), newLocalStorageValue);
+ updateSpinnerQuery.bindValue(QLatin1String(":dom_storage"), newDomStorageValue);
+ updateSpinnerQuery.bindValue(QLatin1String(":id"), spinnerQuery.value(ID));
// Execute the query.
updateSpinnerQuery.exec();
// Upgrade from schema version 6 to schema version 7, first used in Privacy Browser PC 0.6.
case 6:
{
+ // Create an add filter lists query.
+ QSqlQuery addFilterListsQuery(domainsDatabase);
+
// Add the filter list columns.
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ULTRAPRIVACY + " INTEGER DEFAULT 0");
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ULTRALIST + " INTEGER DEFAULT 0");
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + EASYPRIVACY + " INTEGER DEFAULT 0");
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + EASYLIST + " INTEGER DEFAULT 0");
- domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + FANBOYS_ANNOYANCE_LIST + " INTEGER DEFAULT 0");
+ addFilterListsQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + ULTRAPRIVACY + QLatin1String(" INTEGER DEFAULT 0"));
+ addFilterListsQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + ULTRALIST + QLatin1String(" INTEGER DEFAULT 0"));
+ addFilterListsQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + EASYPRIVACY + QLatin1String(" INTEGER DEFAULT 0"));
+ addFilterListsQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + EASYLIST + QLatin1String(" INTEGER DEFAULT 0"));
+ addFilterListsQuery.exec(QLatin1String("ALTER TABLE ") + DOMAINS_TABLE + QLatin1String(" ADD COLUMN ") + FANBOYS_ANNOYANCE_LIST + QLatin1String(" INTEGER DEFAULT 0"));
// Fall through to the next case.
// [[fallthrough]];
}
}
+ // Create an update scheme version query.
+ QSqlQuery updateSchemaVersionQuery(domainsDatabase);
+
// Update the schema version.
- domainsDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+ updateSchemaVersionQuery.exec(QLatin1String("PRAGMA user_version = ") + QString::number(SCHEMA_VERSION));
}
}
else // The domains table does not exist.
QSqlQuery createTableQuery(domainsDatabase);
// Prepare the create table query.
- createTableQuery.prepare("CREATE TABLE " + DOMAINS_TABLE + "(" +
- ID + " INTEGER PRIMARY KEY, " +
- DOMAIN_NAME + " TEXT, " +
- JAVASCRIPT + " INTEGER DEFAULT 0, " +
- LOCAL_STORAGE + " INTEGER DEFAULT 0, " +
- DOM_STORAGE + " INTEGER DEFAULT 0, " +
- USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "', " +
- ULTRAPRIVACY + " INTEGER DEFAULT 0, " +
- ULTRALIST + " INTEGER DEFAULT 0, " +
- EASYPRIVACY + " INTEGER DEFAULT 0, " +
- EASYLIST + " INTEGER DEFAULT 0, " +
- FANBOYS_ANNOYANCE_LIST + " INTEGER DEFAULT 0, " +
- ZOOM_FACTOR + " INTEGER DEFAULT 0, " +
- CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0)");
+ createTableQuery.prepare(QLatin1String("CREATE TABLE ") + DOMAINS_TABLE + QLatin1String("(") +
+ ID + QLatin1String(" INTEGER PRIMARY KEY, ") +
+ DOMAIN_NAME + QLatin1String(" TEXT, ") +
+ JAVASCRIPT + QLatin1String(" INTEGER DEFAULT 0, ") +
+ LOCAL_STORAGE + QLatin1String(" INTEGER DEFAULT 0, ") +
+ DOM_STORAGE + QLatin1String(" INTEGER DEFAULT 0, ") +
+ USER_AGENT + QLatin1String(" TEXT DEFAULT '") + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + QLatin1String("', ") +
+ ULTRAPRIVACY + QLatin1String(" INTEGER DEFAULT 0, ") +
+ ULTRALIST + QLatin1String(" INTEGER DEFAULT 0, ") +
+ EASYPRIVACY + QLatin1String(" INTEGER DEFAULT 0, ") +
+ EASYLIST + QLatin1String(" INTEGER DEFAULT 0, ") +
+ FANBOYS_ANNOYANCE_LIST + QLatin1String(" INTEGER DEFAULT 0, ") +
+ ZOOM_FACTOR + QLatin1String(" INTEGER DEFAULT 0, ") +
+ CUSTOM_ZOOM_FACTOR + QLatin1String(" REAL DEFAULT 1.0)"));
// Execute the query.
if (!createTableQuery.exec())
qDebug().noquote().nospace() << "Error creating table: " << domainsDatabase.lastError();
}
+ // Create an update schema version query.
+ QSqlQuery updateSchemaVersionQuery(domainsDatabase);
+
// Set the schema version.
- domainsDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+ updateSchemaVersionQuery.exec(QLatin1String("PRAGMA user_version = ") + QString::number(SCHEMA_VERSION));
}
}
else // Opening the database failed.
QSqlQuery addDomainSettingsQuery(domainsDatabase);
// Prepare the query.
- addDomainSettingsQuery.prepare("INSERT INTO " + DOMAINS_TABLE + " (" +
- DOMAIN_NAME + ", " +
- JAVASCRIPT + ", " +
- LOCAL_STORAGE + ", " +
- DOM_STORAGE + ", " +
- USER_AGENT + ", " +
- ULTRAPRIVACY + ", " +
- ULTRALIST + ", " +
- EASYPRIVACY + ", " +
- EASYLIST + ", " +
- FANBOYS_ANNOYANCE_LIST + ", " +
- ZOOM_FACTOR + ", " +
- CUSTOM_ZOOM_FACTOR + ") " +
- "VALUES (:domain_name, :javascript, :local_storage, :dom_storage, :user_agent, :ultraprivacy, :ultralist, :easyprivacy, :easylist, :fanboys_annoyance_list, :zoom_factor, :custom_zoom_factor)"
- );
+ addDomainSettingsQuery.prepare(QLatin1String("INSERT INTO ") + DOMAINS_TABLE + QLatin1String(" (") +
+ DOMAIN_NAME + QLatin1String(", ") +
+ JAVASCRIPT + QLatin1String(", ") +
+ LOCAL_STORAGE + QLatin1String(", ") +
+ DOM_STORAGE + QLatin1String(", ") +
+ USER_AGENT + QLatin1String(", ") +
+ ULTRAPRIVACY + QLatin1String(", ") +
+ ULTRALIST + QLatin1String(", ") +
+ EASYPRIVACY + QLatin1String(", ") +
+ EASYLIST + QLatin1String(", ") +
+ FANBOYS_ANNOYANCE_LIST + QLatin1String(", ") +
+ ZOOM_FACTOR + QLatin1String(", ") +
+ CUSTOM_ZOOM_FACTOR + QLatin1String(") ") +
+ QLatin1String("VALUES (:domain_name, :javascript, :local_storage, :dom_storage, :user_agent, :ultraprivacy, :ultralist, :easyprivacy, :easylist,") +
+ QLatin1String(":fanboys_annoyance_list, :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(":ultraprivacy", ultraPrivacyInt);
- addDomainSettingsQuery.bindValue(":ultralist", ultraListInt);
- addDomainSettingsQuery.bindValue(":easyprivacy", easyPrivacyInt);
- addDomainSettingsQuery.bindValue(":easylist", easyListInt);
- addDomainSettingsQuery.bindValue(":fanboys_annoyance_list", fanboysAnnoyanceListInt);
- addDomainSettingsQuery.bindValue(":zoom_factor", zoomFactorInt);
- addDomainSettingsQuery.bindValue(":custom_zoom_factor", currentZoomFactorDouble);
+ addDomainSettingsQuery.bindValue(QLatin1String(":domain_name"), domainName);
+ addDomainSettingsQuery.bindValue(QLatin1String(":javascript"), javaScriptInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":local_storage"), localStorageInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":dom_storage"), domStorageInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":user_agent"), userAgentDatabaseString);
+ addDomainSettingsQuery.bindValue(QLatin1String(":ultraprivacy"), ultraPrivacyInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":ultralist"), ultraListInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":easyprivacy"), easyPrivacyInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":easylist"), easyListInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":fanboys_annoyance_list"), fanboysAnnoyanceListInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":zoom_factor"), zoomFactorInt);
+ addDomainSettingsQuery.bindValue(QLatin1String(":custom_zoom_factor"), currentZoomFactorDouble);
// Execute the query.
addDomainSettingsQuery.exec();
allDomainNamesQuery.setForwardOnly(true);
// Prepare the query.
- allDomainNamesQuery.prepare("SELECT " + ID + "," + DOMAIN_NAME + " FROM " + DOMAINS_TABLE);
+ allDomainNamesQuery.prepare(QLatin1String("SELECT ") + ID + QLatin1String(",") + DOMAIN_NAME + QLatin1String(" FROM ") + DOMAINS_TABLE);
// Execute the query.
allDomainNamesQuery.exec();
QString subdomain = hostname;
// Check all the subdomains of the hostname.
- while ((databaseId == -1) && subdomain.contains(".")) // Stop checking when a match is found or there are no more `.` in the hostname.
+ while ((databaseId == -1) && subdomain.contains(QLatin1String("."))) // Stop checking when a match is found or there are no more `.` in the hostname.
{
// Check to see if the domain settings map contains the subdomain with a `*.` prepended.
- if (domainSettingsMap.contains("*." + subdomain))
+ if (domainSettingsMap.contains(QLatin1String("*.") + subdomain))
{
// Get the database ID.
- databaseId = domainSettingsMap.value("*." + subdomain);
+ databaseId = domainSettingsMap.value(QLatin1String("*.") + subdomain);
}
// Strip out the first subdomain.
- subdomain = subdomain.section('.', 1);
+ subdomain = subdomain.section(QLatin1Char('.'), 1);
}
// Instantiate the domain lookup query.
QSqlQuery domainLookupQuery(domainsDatabase);
// Prepare the domain lookup query.
- domainLookupQuery.prepare("SELECT * FROM " + DOMAINS_TABLE + " WHERE " + ID + " = " + QString::number(databaseId));
+ domainLookupQuery.prepare(QLatin1String("SELECT * FROM ") + DOMAINS_TABLE + QLatin1String(" WHERE ") + ID + QLatin1String(" = ") + QString::number(databaseId));
// Execute the query.
domainLookupQuery.exec();
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 DOMAINS_DATABASE_H
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
addButtonPointer = dialogButtonBoxPointer->addButton(i18nc("The add bookmark button", "Add"), QDialogButtonBox::AcceptRole);
// Set the button icons.
- addButtonPointer->setIcon(QIcon::fromTheme("list-add"));
+ addButtonPointer->setIcon(QIcon::fromTheme(QLatin1String("list-add")));
// Connect the buttons.
connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(browse()));
BookmarksDatabase::addBookmark(bookmarkStructPointer);
// Update the list of bookmarks in the menu and toolbar.
- emit bookmarkAdded();
+ Q_EMIT bookmarkAdded();
// Close the dialog.
close();
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 ADDBOOKMARKDIALOG_H
// The primary constructor.
explicit AddBookmarkDialog(QWidget *parentWidgetPointer, const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon, const double parentFolderId);
-signals:
+Q_SIGNALS:
// The signals.
void bookmarkAdded() const;
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
addButtonPointer = dialogButtonBoxPointer->addButton(i18nc("The add folder button", "Add"), QDialogButtonBox::AcceptRole);
// Set the button icons.
- addButtonPointer->setIcon(QIcon::fromTheme("list-add"));
+ addButtonPointer->setIcon(QIcon::fromTheme(QLatin1String("list-add")));
// Connect the buttons.
connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(browse()));
BookmarksDatabase::addFolder(bookmarkStructPointer);
// Update the list of bookmarks in the menu and toolbar.
- emit folderAdded();
+ Q_EMIT folderAdded();
// Close the dialog.
close();
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 ADDFOLDERDIALOG_H
// The primary constructor.
explicit AddFolderDialog(QWidget *parentWidgetPointer, const QIcon ¤tWebsiteFavoriteIcon, const double parentFolderId);
-signals:
+Q_SIGNALS:
// The signals.
void folderAdded() const;
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
// Populate the widgets.
domainLineEditPointer->setText(originalCookie.domain());
durableCheckBoxPointer->setChecked(originalIsDurable);
- nameLineEditPointer->setText(originalCookie.name());
+ nameLineEditPointer->setText(QLatin1String(originalCookie.name()));
pathLineEditPointer->setText(originalCookie.path());
httpOnlyCheckBoxPointer->setChecked(originalCookie.isHttpOnly());
secureCheckBoxPointer->setChecked(originalCookie.isSecure());
- valueLineEditPointer->setText(originalCookie.value());
+ valueLineEditPointer->setText(QLatin1String(originalCookie.value()));
// Scroll to the beginning of the line edits.
domainLineEditPointer->setCursorPosition(0);
{
// Delete the old cookie if this is an edit dialog.
if (isEditDialog)
- emit deleteCookie(originalCookie);
+ Q_EMIT deleteCookie(originalCookie);
// Create the variables.
QNetworkCookie cookie;
}
// Add the cookie to the store, the list, and the tree.
- emit addCookie(cookie, isDurable);
+ Q_EMIT addCookie(cookie, isDurable);
// Close the dialog.
close();
saveButtonPointer->setDisabled(domainLineEditPointer->text().isEmpty() || nameLineEditPointer->text().isEmpty() || pathLineEditPointer->text().isEmpty() ||
valueLineEditPointer->text().isEmpty());
}
+
-/*
- * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 ADDOREDITCOOKIEDIALOG_H
static const int AddCookie;
static const int EditCookie;
-signals:
+Q_SIGNALS:
// The signals.
void addCookie(const QNetworkCookie &cookie, const bool &isDurable) const;
void deleteCookie(const QNetworkCookie &cookie) const;
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
populateBookmarks();
// Emit the bookmark updated signal to redraw the bookmarks in the menu and toolbar.
- emit bookmarkUpdated();
+ Q_EMIT bookmarkUpdated();
}
void BookmarksDialog::populateBookmarks() const
populateBookmarks();
// Emit the bookmark updated signal to redraw the bookmarks in the menu and toolbar.
- emit bookmarkUpdated();
+ Q_EMIT bookmarkUpdated();
}
void BookmarksDialog::selectSubfolderContents(const QModelIndex &parentModelIndex) const
}
// Emit the bookmark updated signal.
- emit bookmarkUpdated();
+ Q_EMIT bookmarkUpdated();
}
void BookmarksDialog::updateSelection() const
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 BOOKMARKSDIALOG_H
static const int IS_FOLDER_COLUMN = 4;
static const int FOLDER_ID_COLUMN = 5;
-signals:
+Q_SIGNALS:
// The signals.
void bookmarkUpdated() const;
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
int rightHandDots = rightHandDomain.count(QLatin1Char('.'));
// Get the top level domains.
- leftHandTopLevelDomain = leftHandDomain.section('.', -1);
- rightHandTopLevelDomain = rightHandDomain.section('.', -1);
+ leftHandTopLevelDomain = leftHandDomain.section(QLatin1Char('.'), -1);
+ rightHandTopLevelDomain = rightHandDomain.section(QLatin1Char('.'), -1);
// Get the second level domains if they contain at least one dot.
if (leftHandDots >= 1)
- leftHandSecondLevelDomain = leftHandDomain.section('.', -2);
+ leftHandSecondLevelDomain = leftHandDomain.section(QLatin1Char('.'), -2);
if (rightHandDots >= 1)
- rightHandSecondLevelDomain = rightHandDomain.section('.', -2);
+ rightHandSecondLevelDomain = rightHandDomain.section(QLatin1Char('.'), -2);
// Get the third level domains if they contain at least two dots.
if (leftHandDots >= 2)
- leftHandThirdLevelDomain = leftHandDomain.section('.', -3);
+ leftHandThirdLevelDomain = leftHandDomain.section(QLatin1Char('.'), -3);
if (rightHandDots >= 2)
- rightHandThirdLevelDomain = rightHandDomain.section('.', -3);
+ rightHandThirdLevelDomain = rightHandDomain.section(QLatin1Char('.'), -3);
// Check to see if the top level domains are the same. Segments, like third level domains, that don't exist will be blank, which will cause the sorting to group similar domains.
if (leftHandTopLevelDomain == rightHandTopLevelDomain)
cookieListPointer->sort(cookieSortPredicate);
// Create the current domain string.
- QString currentDomainString = "";
+ QString currentDomainString = QLatin1String("");
// Create the current domain item pointer.
QStandardItem *currentDomainItemPointer;
QList<QStandardItem*> cookieItemList;
// Create the cookie items.
- QStandardItem *nameItemPointer = new QStandardItem(QString(cookie.name()));
+ QStandardItem *nameItemPointer = new QStandardItem(QLatin1String(cookie.name()));
QStandardItem *durableItemPointer = new QStandardItem(isDurable ? i18n("yes") : i18n("no"));
QStandardItem *pathItemPointer = new QStandardItem(cookie.path());
QStandardItem *expirationDateItemPointer = new QStandardItem(cookie.expirationDate().toString());
QStandardItem *isHttpOnlyItemPointer = new QStandardItem(cookie.isHttpOnly() ? i18n("yes") : i18n("no"));
QStandardItem *isSecureItemPointer = new QStandardItem(cookie.isSecure() ? i18n("yes") : i18n("no"));
- QStandardItem *valueItemPointer = new QStandardItem(QString(cookie.value()));
+ QStandardItem *valueItemPointer = new QStandardItem(QLatin1String(cookie.value()));
// Populate the cookie standard item list.
cookieItemList.append(nameItemPointer);
QDialogButtonBox::ActionRole);
// Set the button icons.
- durableCookiesButtonPointer->setIcon(QIcon::fromTheme("view-visible", QIcon::fromTheme(QLatin1String("appointment-new"))));
+ durableCookiesButtonPointer->setIcon(QIcon::fromTheme(QLatin1String("view-visible"), QIcon::fromTheme(QLatin1String("appointment-new"))));
// Connect the buttons.
connect(addCookieButtonPointer, SIGNAL(clicked()), this, SLOT(showAddCookieDialog()));
void CookiesDialog::addCookieFromDialog(const QNetworkCookie &cookie, const bool &isDurable) const
{
// Add the cookie to the cookie list and the cookie store.
- emit addCookie(cookie);
+ Q_EMIT addCookie(cookie);
// Get the new domain string.
QString newDomain = cookie.domain();
int newDomainDots = newDomain.count(QLatin1Char('.'));
// Get the new top level domain.
- newDomainTopLevelDomain = newDomain.section('.', -1);
+ newDomainTopLevelDomain = newDomain.section(QLatin1Char('.'), -1);
// Get the new second level domain if it contains at least one dot.
if (newDomainDots >= 1)
- newDomainSecondLevelDomain = newDomain.section('.', -2);
+ newDomainSecondLevelDomain = newDomain.section(QLatin1Char('.'), -2);
// Get the new third level domain if it contains at least two dots.
if (newDomainDots >= 2)
- newDomainThirdLevelDomain = newDomain.section('.', -3);
+ newDomainThirdLevelDomain = newDomain.section(QLatin1Char('.'), -3);
// Create while loop trackers.
bool locationFound = false;
int currentDomainDots = currentDomain.count(QLatin1Char('.'));
// Get the current top level domain.
- currentDomainTopLevelDomain = currentDomain.section('.', -1);
+ currentDomainTopLevelDomain = currentDomain.section(QLatin1Char('.'), -1);
// Get the current second level domain if it contains at least one dot.
if (currentDomainDots >= 1)
- currentDomainSecondLevelDomain = currentDomain.section('.', -2);
+ currentDomainSecondLevelDomain = currentDomain.section(QLatin1Char('.'), -2);
// Get the current third level domain if it contains at least two dots.
if (currentDomainDots >= 2)
- currentDomainThirdLevelDomain = currentDomain.section('.', -3);
+ currentDomainThirdLevelDomain = currentDomain.section(QLatin1Char('.'), -3);
// Check to see if the new domain should be inserted after the current domain.
// Segments, like third level domains, that do not exist will be blank, which will cause the sorting to group similar domains.
}
// Get strings for the new cookie name and path (used later in the placement of the row).
- QString newCookieName = QString(cookie.name());
+ QString newCookieName = QLatin1String(cookie.name());
QString newCookiePath = QString(cookie.path());
// Create a cookie item list.
// Create the cookie items.
QStandardItem *nameItemPointer = new QStandardItem(newCookieName);
- QStandardItem *durableItemPointer = new QStandardItem(QString(isDurable ? i18n("yes") : i18n("no")));
+ QStandardItem *durableItemPointer = new QStandardItem(isDurable ? i18n("yes") : i18n("no"));
QStandardItem *pathItemPointer = new QStandardItem(newCookiePath);
- QStandardItem *expirationDateItemPointer = new QStandardItem(QString(cookie.expirationDate().toString()));
- QStandardItem *isHttpOnlyItemPointer = new QStandardItem(QString(cookie.isHttpOnly() ? i18n("yes") : i18n("no")));
- QStandardItem *isSecureItemPointer = new QStandardItem(QString(cookie.isSecure() ? i18n("yes") : i18n("no")));
- QStandardItem *valueItemPointer = new QStandardItem(QString(cookie.value()));
+ QStandardItem *expirationDateItemPointer = new QStandardItem(cookie.expirationDate().toString());
+ QStandardItem *isHttpOnlyItemPointer = new QStandardItem(cookie.isHttpOnly() ? i18n("yes") : i18n("no"));
+ QStandardItem *isSecureItemPointer = new QStandardItem(cookie.isSecure() ? i18n("yes") : i18n("no"));
+ QStandardItem *valueItemPointer = new QStandardItem(QLatin1String(cookie.value()));
// Populate the cookie item list.
cookieItemList.append(nameItemPointer);
treeModelPointer->removeRow(modelIndex.row(), modelIndex.parent());
// Delete the cookie from the cookie list and cookie store.
- emit deleteCookie(cookieToDelete);
+ Q_EMIT deleteCookie(cookieToDelete);
// Delete the cookie from the durable cookies database.
if (isDurable)
QModelIndex nameModelIndex = nameItemPointer->index();
// Check to see if the name and the path match.
- if ((nameModelIndex.data().toString() == cookie.name()) && (nameModelIndex.siblingAtColumn(2).data().toString() == cookie.path()))
+ if ((nameModelIndex.data().toString() == QLatin1String(cookie.name())) && (nameModelIndex.siblingAtColumn(2).data().toString() == cookie.path()))
{
// Set the current index.
treeSelectionModelPointer->setCurrentIndex(nameModelIndex, QItemSelectionModel::ClearAndSelect);
treeModelPointer->removeRow(parentIndex.row(), parentIndex.parent());
// Delete the cookie from the cookie list and cookie store.
- emit deleteCookie(cookie);
+ Q_EMIT deleteCookie(cookie);
}
void CookiesDialog::showAddCookieDialog()
if (deleteDurableCookiesCheckBox.isChecked()) // Delete everything.
{
// Delete all the cookies.
- emit deleteAllCookies();
+ Q_EMIT deleteAllCookies();
// Clear the tree model.
treeModelPointer->clear();
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 COOKIESDIALOG_H
// The primary constructor.
explicit CookiesDialog(std::list<QNetworkCookie> *cookieListPointer);
-signals:
+Q_SIGNALS:
// The signals.
void addCookie(const QNetworkCookie &cookie) const;
void deleteAllCookies() const;
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 <https://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.
updateButtons();
// Emit the domain settings updated signal.
- emit domainSettingsUpdated();
+ Q_EMIT domainSettingsUpdated();
}
void DomainSettingsDialog::cancel()
domainsTableModelPointer->submitAll();
// Emit the domain settings updated signal.
- emit domainSettingsUpdated();
+ Q_EMIT domainSettingsUpdated();
// Close the dialog.
accept();
else
{
// Display the user agent name in bold.
- userAgentLabelPointer->setText("<strong>" + userAgentName + "</strong>");
+ userAgentLabelPointer->setText(QLatin1String("<strong>") + userAgentName + QLatin1String("</strong>"));
// Set the palette.
userAgentWidgetPointer->setPalette(highlightedPalette);
updateButtons();
// Emit the domain settings updated signal.
- emit domainSettingsUpdated();
+ Q_EMIT domainSettingsUpdated();
}
}
updateButtons();
// Emit the domain settings updated signal.
- emit domainSettingsUpdated();
+ Q_EMIT domainSettingsUpdated();
}
}
updateButtons();
// Emit the domain settings updated signal.
- emit domainSettingsUpdated();
+ Q_EMIT domainSettingsUpdated();
}
}
-/*
- * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 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 <https://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 DOMAIN_SETTINGS_DIALOG_H
static const int ADD_DOMAIN;
static const int EDIT_DOMAIN;
-signals:
+Q_SIGNALS:
void domainSettingsUpdated() const;
private Q_SLOTS:
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
cookie.setPath(sqlRecord.value(CookiesDatabase::PATH).toString());
// Delete the cookie.
- emit deletingCookie(cookie);
+ Q_EMIT deletingCookie(cookie);
}
void DurableCookiesDialog::beforeUpdate(int row, QSqlRecord &sqlRecord) const
QNetworkCookie *cookiePointer = CookiesDatabase::getCookieById(id);
// Delete the cookie.
- emit deletingCookie(*cookiePointer);
+ Q_EMIT deletingCookie(*cookiePointer);
}
// Add the new cookie, which modifies any existing cookies with the same core attributes.
cookie.setValue(sqlRecord.value(CookiesDatabase::VALUE).toByteArray());
// Update the cookie in the cookies dialog tree, cookies list, and cookie store.
- emit addingCookie(cookie, false);
+ Q_EMIT addingCookie(cookie, false);
}
void DurableCookiesDialog::ok()
applyButtonPointer->setEnabled(durableCookiesTableModelPointer->isDirty());
// Update the parent UI.
- emit updateParentUi();
+ Q_EMIT updateParentUi();
}
-/*
- * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 DURABLECOOKIESDIALOG_H
// The default constructor.
explicit DurableCookiesDialog(QWidget *parentWidgetPointer);
-signals:
+Q_SIGNALS:
// The signals.
void addingCookie(const QNetworkCookie &cookie, const bool &addToDatabase) const;
void deletingCookie(const QNetworkCookie &cookie) const;
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
BookmarksDatabase::updateFolderContentsDisplayOrder(bookmarkStructPointer->parentFolderId);
// Emit the bookmark saved signal.
- emit bookmarkSaved();
+ Q_EMIT bookmarkSaved();
// Close the dialog.
close();
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 EDITBOOKMARKDIALOG_H
// The primary constructor.
explicit EditBookmarkDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon ¤tWebsiteFavoriteIcon);
-signals:
+Q_SIGNALS:
// The signals.
void bookmarkSaved() const;
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
BookmarksDatabase::updateFolderContentsDisplayOrder(folderBookmarkStructPointer->parentFolderId);
// Emit the folder saved signal.
- emit folderSaved();
+ Q_EMIT folderSaved();
// Close the dialog.
close();
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 EDITFOLDERDIALOG_H
// The primary constructor.
explicit EditFolderDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon ¤tWebsiteFavoriteIcon);
-signals:
+Q_SIGNALS:
// The signals.
void folderSaved() const;
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
mimeGraphicsScenePointer->addPixmap(mimeTypeIcon.pixmap(64, 64));
// Populate the labels.
- urlLabelPointer->setText("<b>" + downloadUrl.toString() + "</b>");
- filetypeLabelPointer->setText("<b>" + mimeType.comment() + "</b>");
- mimeTypeLabelPointer->setText("<b>" + mimeTypeString + "</b>");
+ urlLabelPointer->setText(QLatin1String("<b>") + downloadUrl.toString() + QLatin1String("</b>"));
+ filetypeLabelPointer->setText(QLatin1String("<b>") + mimeType.comment() + QLatin1String("</b>"));
+ mimeTypeLabelPointer->setText(QLatin1String("<b>") + mimeTypeString + QLatin1String("</b>"));
// Populate the download size label.
if (totalBytes == -1) // The file size is unknown.
void SaveDialog::showFilePicker()
{
// Show the file picker dialog.
- emit useNativeKdeDownloader(downloadUrl, suggestedFileName);
+ Q_EMIT useNativeKdeDownloader(downloadUrl, suggestedFileName);
// Close the dialog.
reject();
-/*
- * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 SAVEDIALOG_H
// Qt toolkit headers.
#include <QDialog>
#include <QUrl>
-#include <QWebEngineDownloadItem>
+#include <QWebEngineDownloadRequest>
class SaveDialog : public QDialog
{
// The primary constructor.
explicit SaveDialog(QWidget *parentWidgetPointer, QUrl &url, QString &mimeTypeString, int totalBytes, QString fileName = QString(), bool nativeDownloader = false);
-signals:
+Q_SIGNALS:
// The signals.
void useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName);
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
QStringList enabledSpellCheckLanguagesList = Settings::spellCheckLanguages();
// Add each dictionary to the spell check list widget.
- foreach (QString dictionaryString, dictionariesStringList)
+ for (QString dictionaryString : dictionariesStringList)
{
// Create a new list widget item pointer.
QListWidgetItem *listWidgetItemPointer = new QListWidgetItem();
QString settingsIconString;
// Get a settings icon that matches the theme.
- if (QIcon::hasThemeIcon("breeze-settings"))
+ if (QIcon::hasThemeIcon(QLatin1String("breeze-settings")))
{
// KDE uses breeze-settings.
settingsIconString = QLatin1String("breeze-settings");
QString languageString = languageCheckBoxPointer->text();
// Remove all instances of `&`, which may have been added automatically when creating the check box text.
- languageString.remove(QChar('&'));
+ languageString.remove(QLatin1Char('&'));
// Add the language string to the list.
newSpellCheckLanguages.append(languageString);
coreConfigSkeletonPointer->save();
// Emit the spell check languages updated signal.
- emit spellCheckLanguagesUpdated();
+ Q_EMIT spellCheckLanguagesUpdated();
}
};
if (newDownloadDirectory == QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)) // The default download location was selected.
{
// Populate the download location with the default text.
- downloadDirectoryComboBoxPointer->setCurrentText("System Download Directory");
+ downloadDirectoryComboBoxPointer->setCurrentText(QLatin1String("System Download Directory"));
}
else if (newDownloadDirectory != QStringLiteral("")) // A different directory was selected.
{
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 SETTINGSDIALOG_H
// The primary constructor.
explicit SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton *coreConfigSkeletonPointer);
-signals:
+Q_SIGNALS:
void spellCheckLanguagesUpdated() const;
private Q_SLOTS:
-/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
{
case (Qt::BackButton):
// Tell the WebEngine to go back.
- emit mouseBack();
+ Q_EMIT mouseBack();
// Consume the event.
return true;
case (Qt::ForwardButton):
// Tell the WebEngine to go forward.
- emit mouseForward();
+ Q_EMIT mouseForward();
// Consume the event.
return true;
-/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 MOUSEEVENTFILTER_H
// The primary constructor.
MouseEventFilter();
-signals:
+Q_SIGNALS:
// The signals.
void mouseBack() const;
void mouseForward() const;
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024 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 <https://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.
else if (entryStructPointer->domain == FilterOptionDisposition::Apply) // Block requests from listed domains.
{
// Check each domain.
- foreach (QString blockedDomain, entryStructPointer->domainList)
+ for (QString blockedDomain : entryStructPointer->domainList)
{
// Check if the request came from a blocked domain.
if (requestStructPointer->firstPartyHost.endsWith(blockedDomain))
bool blockDomain = true;
// Check each overridden domain.
- foreach (QString overriddenDomain, entryStructPointer->domainList)
+ for (QString overriddenDomain : entryStructPointer->domainList)
{
// Check if the request came from an overridden domain.
if (requestStructPointer->firstPartyHost.endsWith(overriddenDomain))
QStringList appliedFilterOptionsList;
// Populate the applied filter options list.
- foreach (QString filterOption, originalFilterOptionsList)
+ for (QString filterOption : originalFilterOptionsList)
{
// Only add filter options that are handled by Privacy Browser. <https://help.adblockplus.org/hc/en-us/articles/360062733293-How-to-write-filters>
// `csp` specifies a Content Security Policy, which isn't handled by Privacy Browser.
OverrideStruct overrideStruct;
// Populate the filter options entries.
- foreach (QString filterOption, appliedFilterOptionsList)
+ for (QString filterOption : appliedFilterOptionsList)
{
// Parse the filter options.
if (filterOption.startsWith(QLatin1String("domain="))) // Domain.
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024 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 <https://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 FILTER_LIST_HELPER_H
-/*
- * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022, 2024 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.
QString SearchEngineHelper::getSearchUrl(const QString &searchEngineName)
{
- if (searchEngineName == "Mojeek") // Mojeek.
+ if (searchEngineName == QLatin1String("Mojeek")) // Mojeek.
{
- return "https://www.mojeek.com/search?q=";
+ return QLatin1String("https://www.mojeek.com/search?q=");
}
- else if (searchEngineName == "Monocles") // Monocles.
+ else if (searchEngineName == QLatin1String("Monocles")) // Monocles.
{
- return "https://monocles.de/search?q=";
+ return QLatin1String("https://monocles.de/search?q=");
}
- else if (searchEngineName == "MetaGer") // MetaGer.
+ else if (searchEngineName == QLatin1String("MetaGer")) // MetaGer.
{
- return "https://metager.org/meta/meta.ger3?eingabe=";
+ return QLatin1String("https://metager.org/meta/meta.ger3?eingabe=");
}
- else if (searchEngineName == "Google") // Google.
+ else if (searchEngineName == QLatin1String("Google")) // Google.
{
- return "https://www.google.com/search?q=";
+ return QLatin1String("https://www.google.com/search?q=");
}
- else if (searchEngineName == "Bing") // Bing.
+ else if (searchEngineName == QLatin1String("Bing")) // Bing.
{
- return "https://www.bing.com/search?q=";
+ return QLatin1String("https://www.bing.com/search?q=");
}
- else if (searchEngineName == "Yahoo") // Yahoo.
+ else if (searchEngineName == QLatin1String("Yahoo")) // Yahoo.
{
- return "https://search.yahoo.com/search?p=";
+ return QLatin1String("https://search.yahoo.com/search?p=");
}
else
{
-/*
- * Copyright 2022 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022 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 SEARCHENGINEHELPER_H
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 <https://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.
{
// Clear the requests list if a main frame resource is being loaded.
if (urlRequestInfo.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame)
- emit newMainFrameResource();
+ Q_EMIT newMainFrameResource();
// Create a requests struct.
RequestStruct *requestStructPointer = new RequestStruct;
// Store the basic request information.
requestStructPointer->navigationTypeInt = urlRequestInfo.navigationType();
- requestStructPointer->requestMethodString = urlRequestInfo.requestMethod();
+ requestStructPointer->requestMethodString = QLatin1String(urlRequestInfo.requestMethod());
requestStructPointer->resourceTypeInt = urlRequestInfo.resourceType();
requestStructPointer->urlString = urlRequestInfo.requestUrl().toString();
requestStructPointer->webPageUrlString = urlRequestInfo.firstPartyUrl().toString();
requestStructPointer->filterListTitle = i18nc("Default HTTP ping blocking", "Default blocking of all HTTP ping requests.");
// Display the HTTP Ping blocked dialog.
- emit displayHttpPingDialog(urlRequestInfo.requestUrl().toString());
+ Q_EMIT displayHttpPingDialog(urlRequestInfo.requestUrl().toString());
break;
}
// Reapply the domain settings if the host is changing.
if (requestingHost != requestedHost)
- emit applyDomainSettings(requestedHost);
+ Q_EMIT applyDomainSettings(requestedHost);
}
break;
}
// Send the request struct to the privacy WebEngine view.
- emit requestProcessed(requestStructPointer);
+ Q_EMIT requestProcessed(requestStructPointer);
}
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 URL_REQUEST_INTERCEPTOR_H
// The public functions.
void interceptRequest(QWebEngineUrlRequestInfo &urlRequestInfo) override;
-signals:
+Q_SIGNALS:
// The signals.
void applyDomainSettings(const QString &hostname) const;
void displayHttpPingDialog(const QString &httpPingUrl) const;
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 <https://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.
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
BookmarksDatabase::updateFolderContentsDisplayOrder(parentFolderId);
// Emit the bookmarks moved signal.
- emit bookmarksMoved();
+ Q_EMIT bookmarksMoved();
}
QList<int>* DraggableTreeView::getRootSelectedDatabaseIds(QList<int> *selectedDatabaseIdsPointer) const
-/*
- * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 DRAGGABLETREEVIEW_H
// The default contructor.
explicit DraggableTreeView(QWidget *parentWidget = nullptr);
-signals:
+Q_SIGNALS:
// The signals.
void bookmarksMoved() const;
CookiesDatabase::updateCookie(cookie);
// Update the cookies action.
- emit numberOfCookiesChanged(cookieListPointer->size());
+ Q_EMIT numberOfCookiesChanged(cookieListPointer->size());
}
void PrivacyWebEngineView::applyDomainSettingsWithoutReloading(const QString &hostname)
httpAuthenticationDialogsDisplayed = 0;
// Update the UI.
- emit updateUi(this);
+ Q_EMIT updateUi(this);
}
void PrivacyWebEngineView::clearRequestsList()
requestsListPointer->clear();
// Update the blocked requests action.
- emit(requestBlocked(blockedRequestsVector));
+ Q_EMIT requestBlocked(blockedRequestsVector);
}
void PrivacyWebEngineView::contextMenuEvent(QContextMenuEvent *contextMenuEvent) {
- // Get a handle for the
+ // Get a handle for the WebEngine page.
QWebEnginePage *webEnginePagePointer = page();
// Get a handle for the menu.
- QMenu *contextMenu = webEnginePagePointer->createStandardContextMenu();
+ QMenu *contextMenu = createStandardContextMenu();
// Get the list of context menu actions.
const QList<QAction *> contextMenuActionsList = contextMenu->actions();
void PrivacyWebEngineView::displayHttpPingDialog(const QString &httpPingUrl) const
{
// Display the HTTP Ping blocked dialog.
- emit displayHttpPingBlockedDialog(httpPingUrl);
+ Q_EMIT displayHttpPingBlockedDialog(httpPingUrl);
}
void PrivacyWebEngineView::handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer)
void PrivacyWebEngineView::openWithChromium() const
{
// Open the current URL in Chromium
- QProcess::startDetached("chromium", QStringList(hoveredLinkString));
+ QProcess::startDetached(QLatin1String("chromium"), QStringList(hoveredLinkString));
}
void PrivacyWebEngineView::openWithFirefox() const
{
// Open the current URL in Firefox.
- QProcess::startDetached("firefox-esr", QStringList(hoveredLinkString));
+ QProcess::startDetached(QLatin1String("firefox-esr"), QStringList(hoveredLinkString));
}
void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const
cookieListPointer->remove(cookie);
// Update the cookies action.
- emit numberOfCookiesChanged(cookieListPointer->size());
+ Q_EMIT numberOfCookiesChanged(cookieListPointer->size());
}
void PrivacyWebEngineView::saveHoveredLink(const QString &hoveredLink)
++blockedRequestsVector[TOTAL];
// Update the blocked requests action.
- emit(requestBlocked(blockedRequestsVector));
+ Q_EMIT(requestBlocked(blockedRequestsVector));
}
}
// The public functions.
void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
-signals:
+Q_SIGNALS:
// The signals.
void numberOfCookiesChanged(const int numberOfCookies) const;
void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 <https://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.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
{
// Update the URL line edit.
- emit updateUrlLineEdit(newUrl);
+ Q_EMIT updateUrlLineEdit(newUrl);
// Update the status of the forward and back buttons.
- emit updateBackAction(currentWebEngineHistoryPointer->canGoBack());
- emit updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
+ Q_EMIT updateBackAction(currentWebEngineHistoryPointer->canGoBack());
+ Q_EMIT updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
}
});
// Update the window title if this is the current tab.
if (tabIndex == qTabWidgetPointer->currentIndex())
- emit updateWindowTitle(title);
+ Q_EMIT updateWindowTitle(title);
});
// Connect the loading favorite icon movie to the tab icon.
// Show the progress bar if this is the current tab.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
- emit showProgressBar(0);
+ Q_EMIT showProgressBar(0);
// Start the loading favorite icon movie.
loadingFavoriteIconMoviePointer->start();
// Update the progress bar if this is the current tab.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
- emit showProgressBar(progress);
+ Q_EMIT showProgressBar(progress);
});
// Update the progress bar when a load finishes.
// Hide the progress bar if this is the current tab.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
- emit hideProgressBar();
+ Q_EMIT hideProgressBar();
// Get the index for this tab.
int tabIndex = qTabWidgetPointer->indexOf(splitterPointer);
{
// Only update the zoom actions if this is the current tab.
if (webEnginePagePointer == currentWebEnginePagePointer)
- emit updateZoomActions(webEnginePagePointer->zoomFactor());
+ Q_EMIT updateZoomActions(webEnginePagePointer->zoomFactor());
});
// Display find text results.
connect(webEnginePagePointer, SIGNAL(linkHovered(const QString)), this, SLOT(pageLinkHovered(const QString)));
// Handle file downloads.
- connect(webEngineProfilePointer, SIGNAL(downloadRequested(QWebEngineDownloadItem *)), this, SLOT(showSaveDialog(QWebEngineDownloadItem *)));
+ connect(webEngineProfilePointer, SIGNAL(downloadRequested(QWebEngineDownloadRequest *)), this, SLOT(showSaveDialog(QWebEngineDownloadRequest *)));
// Set the local storage filter.
webEngineCookieStorePointer->setCookieFilter([privacyWebEngineViewPointer](const QWebEngineCookieStore::FilterRequest &filterRequest)
{
// Block all third party local storage requests, including the sneaky ones that don't register a first party URL.
- if (filterRequest.thirdParty || (filterRequest.firstPartyUrl == QStringLiteral("")))
+ if (filterRequest.thirdParty || (filterRequest.firstPartyUrl == QUrl(QLatin1String(""))))
{
//qDebug().noquote().nospace() << "Third-party request blocked: " << filterRequest.origin;
{
// Update the blocked requests action if the specified privacy WebEngine view is the current privacy WebEngine view.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
- emit blockedRequestsUpdated(blockedRequestsVector);
+ Q_EMIT blockedRequestsUpdated(blockedRequestsVector);
});
// Update the cookies action.
{
// Update the cookie action if the specified privacy WebEngine view is the current privacy WebEngine view.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
- emit cookiesChanged(numberOfCookies);
+ Q_EMIT cookiesChanged(numberOfCookies);
});
// Process cookie changes.
// Clear the URL line edit focus so that it populates correctly when opening a new tab from the context menu.
if (removeUrlLineEditFocus)
- emit clearUrlLineEditFocus();
+ Q_EMIT clearUrlLineEditFocus();
- if (urlString != nullptr)
+ // Load the URL if it isn't blank.
+ if (urlString != QLatin1String(""))
privacyWebEngineViewPointer->load(QUrl::fromUserInput(urlString));
// Return the privacy WebEngine view pointer.
searchEngineUrl = SearchEngineHelper::getSearchUrl(Settings::searchEngine());
// Emit the update search engine actions signal.
- emit updateSearchEngineActions(Settings::searchEngine(), true);
+ Q_EMIT updateSearchEngineActions(Settings::searchEngine(), true);
}
void TabWidget::applyDomainSettingsAndReload()
QString searchEngineName = searchEngineActionPointer->text();
// Strip out any `&` characters.
- searchEngineName.remove('&');
+ searchEngineName.remove(QLatin1Char('&'));
// Store the search engine string.
searchEngineUrl = SearchEngineHelper::getSearchUrl(searchEngineName);
// Update the search engine actions.
- emit updateSearchEngineActions(searchEngineName, false);
+ Q_EMIT updateSearchEngineActions(searchEngineName, false);
}
void TabWidget::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const
QString userAgentName = userAgentActionPointer->text();
// Strip out any `&` characters.
- userAgentName.remove('&');
+ userAgentName.remove(QLatin1Char('&'));
// Apply the user agent.
currentWebEngineProfilePointer->setHttpUserAgent(userAgentHelperPointer->getUserAgentFromTranslatedName(userAgentName));
// Update the user agent actions.
- emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), false);
+ Q_EMIT updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), false);
// Reload the website.
currentPrivacyWebEngineViewPointer->reload();
currentPrivacyWebEngineViewPointer->findTextResult = findTextResult;
// Update the UI.
- emit updateFindTextResults(findTextResult);
+ Q_EMIT updateFindTextResults(findTextResult);
}
}
void TabWidget::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const
{
// Make it so.
- emit fullScreenRequested(fullScreenRequest.toggleOn());
+ Q_EMIT fullScreenRequested(fullScreenRequest.toggleOn());
// Accept the request.
fullScreenRequest.accept();
void TabWidget::loadUrlFromLineEdit(QString url) const
{
// Decide if the text is more likely to be a URL or a search.
- if (url.startsWith("file://") || url.startsWith("view-source:")) // The text is likely a file or view source URL.
+ if (url.startsWith(QLatin1String("file://")) || url.startsWith(QLatin1String("view-source:"))) // The text is likely a file or view source URL.
{
// Load the URL.
currentPrivacyWebEngineViewPointer->load(QUrl::fromUserInput(url));
}
- else if (url.contains(".")) // The text is likely a URL.
+ else if (url.contains(QLatin1String("."))) // The text is likely a URL.
{
// Check if the URL does not start with a valid protocol.
- if (!url.startsWith("http"))
+ if (!url.startsWith(QLatin1String("http")))
{
// Add `https://` to the beginning of the URL.
- url = "https://" + url;
+ url = QLatin1String("https://") + url;
}
// Load the URL.
if (currentPrivacyWebEngineViewPointer->isActiveWindow() && currentWebEngineHistoryPointer->canGoBack())
{
// Clear the URL line edit focus.
- emit clearUrlLineEditFocus();
+ Q_EMIT clearUrlLineEditFocus();
// Go back.
currentPrivacyWebEngineViewPointer->back();
if (currentPrivacyWebEngineViewPointer->isActiveWindow() && currentWebEngineHistoryPointer->canGoForward())
{
// Clear the URL line edit focus.
- emit clearUrlLineEditFocus();
+ Q_EMIT clearUrlLineEditFocus();
// Go forward.
currentPrivacyWebEngineViewPointer->forward();
void TabWidget::pageLinkHovered(const QString &linkUrl) const
{
// Emit a signal so that the browser window can update the status bar.
- emit linkHovered(linkUrl);
+ Q_EMIT linkHovered(linkUrl);
}
void TabWidget::stopLoadingFavoriteIconMovie() const
void TabWidget::print() const
{
// Create a printer.
- QPrinter printer;
+ QPrinter *printerPointer = new QPrinter();
// Set the resolution to be 300 dpi.
- printer.setResolution(300);
+ printerPointer->setResolution(300);
// Create a printer dialog.
- QPrintDialog printDialog(&printer, currentPrivacyWebEngineViewPointer);
+ QPrintDialog printDialog(printerPointer, currentPrivacyWebEngineViewPointer);
// Display the dialog and print the page if instructed.
if (printDialog.exec() == QDialog::Accepted)
- printWebpage(&printer);
+ currentPrivacyWebEngineViewPointer->print(printerPointer);
}
void TabWidget::printPreview() const
{
// Create a printer.
- QPrinter printer;
+ QPrinter *printerPointer = new QPrinter();
// Set the resolution to be 300 dpi.
- printer.setResolution(300);
+ printerPointer->setResolution(300);
// Create a print preview dialog.
- QPrintPreviewDialog printPreviewDialog(&printer, currentPrivacyWebEngineViewPointer);
+ QPrintPreviewDialog printPreviewDialog(printerPointer, currentPrivacyWebEngineViewPointer);
// Generate the print preview.
- connect(&printPreviewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(printWebpage(QPrinter *)));
+ auto generatePrintPreview = [this, printerPointer](){
+ // Create an event loop. The print preview must be generated in a loop or nothing is displayed.
+ QEventLoop eventLoop;
- // Display the dialog.
- printPreviewDialog.exec();
-}
+ // Quit the event loop once the print preview has been generated.
+ connect(currentPrivacyWebEngineViewPointer, &QWebEngineView::printFinished, &eventLoop, &QEventLoop::quit);
-void TabWidget::printWebpage(QPrinter *printerPointer) const
-{
- // Create an event loop. For some reason, the print preview doesn't produce any output unless it is run inside an event loop.
- QEventLoop eventLoop;
+ // Generate the print preview for the current webpage.
+ currentPrivacyWebEngineViewPointer->print(printerPointer);
- // Print the webpage, converting the callback above into a `QWebEngineCallback<bool>`.
- // Printing requires that the printer be a pointer, not a reference, or it will crash with much cursing.
- currentWebEnginePagePointer->print(printerPointer, [&eventLoop](bool printSuccess)
- {
- // Instruct the compiler to ignore the unused parameter.
- (void) printSuccess;
+ // Execute the loop.
+ eventLoop.exec();
+ };
- // Quit the loop.
- eventLoop.quit();
- });
+ // Generate the preview.
+ connect(&printPreviewDialog, &QPrintPreviewDialog::paintRequested, this, generatePrintPreview);
- // Execute the loop.
- eventLoop.exec();
+ // Display the dialog.
+ printPreviewDialog.exec();
}
void TabWidget::refresh() const
void TabWidget::saveArchive()
{
// Get the suggested file name.
- QString suggestedFileName = currentPrivacyWebEngineViewPointer->title() + ".mht";
+ QString suggestedFileName = currentPrivacyWebEngineViewPointer->title() + QLatin1String(".mht");
// Get the download directory.
QString downloadDirectory = Settings::downloadDirectory();
qTabWidgetPointer->tabBar()->setVisible(visible);
}
-void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPointer)
+void TabWidget::showSaveDialog(QWebEngineDownloadRequest *webEngineDownloadRequestPointer)
{
// Only show the save dialog if an archive is not currently being saved. Otherwise, two save dialogs will be shown.
if (!savingArchive)
{
// Get the download attributes.
- QUrl downloadUrl = webEngineDownloadItemPointer->url();
- QString mimeTypeString = webEngineDownloadItemPointer->mimeType();
- QString suggestedFileName = webEngineDownloadItemPointer->suggestedFileName();
- int totalBytes = webEngineDownloadItemPointer->totalBytes();
+ QUrl downloadUrl = webEngineDownloadRequestPointer->url();
+ QString mimeTypeString = webEngineDownloadRequestPointer->mimeType();
+ QString suggestedFileName = webEngineDownloadRequestPointer->suggestedFileName();
+ int totalBytes = webEngineDownloadRequestPointer->totalBytes();
// Check to see if Privacy Browser is not running KDE or if local storage (cookies) is enabled.
if (!isRunningKde || currentPrivacyWebEngineViewPointer->localStorageEnabled) // KDE is not running or local storage (cookies) is enabled. Use WebEngine's downloader.
QString saveFileName = saveFilePathFileInfo.fileName();
// Set the download directory and file name.
- webEngineDownloadItemPointer->setDownloadDirectory(absoluteSavePath);
- webEngineDownloadItemPointer->setDownloadFileName(saveFileName);
+ webEngineDownloadRequestPointer->setDownloadDirectory(absoluteSavePath);
+ webEngineDownloadRequestPointer->setDownloadFileName(saveFileName);
// Create a file download notification.
KNotification *fileDownloadNotificationPointer = new KNotification(QLatin1String("FileDownload"));
// Set the notification icon.
fileDownloadNotificationPointer->setIconName(downloadIcon.name());
- // Set the action list cancel button.
- fileDownloadNotificationPointer->setActions(QStringList({i18nc("Download notification action","Cancel")}));
+ // Add the cancel action.
+ KNotificationAction *cancelActionPointer = fileDownloadNotificationPointer->addDefaultAction(i18nc("Download notification action","Cancel"));
// Prevent the notification from being autodeleted if it is closed. Otherwise, the updates to the notification below cause a crash.
fileDownloadNotificationPointer->setAutoDelete(false);
- // Handle clicks on the cancel button.
- connect(fileDownloadNotificationPointer, &KNotification::action1Activated, [webEngineDownloadItemPointer, saveFileName] ()
+ // Handle clicks on the cancel action.
+ connect(cancelActionPointer, &KNotificationAction::activated, [webEngineDownloadRequestPointer, saveFileName] ()
{
// Cancel the download.
- webEngineDownloadItemPointer->cancel();
+ webEngineDownloadRequestPointer->cancel();
// Create a file download notification.
KNotification *canceledDownloadNotificationPointer = new KNotification(QLatin1String("FileDownload"));
});
// Update the notification when the download progresses.
- connect(webEngineDownloadItemPointer, &QWebEngineDownloadItem::downloadProgress, [fileDownloadNotificationPointer, saveFileName] (qint64 bytesReceived, qint64 totalBytes)
+ connect(webEngineDownloadRequestPointer, &QWebEngineDownloadRequest::receivedBytesChanged, [webEngineDownloadRequestPointer, fileDownloadNotificationPointer, saveFileName] ()
{
+ // Get the download request information.
+ qint64 receivedBytes = webEngineDownloadRequestPointer->receivedBytes();
+ qint64 totalBytes = webEngineDownloadRequestPointer->totalBytes();
+
// Set the new text. Total bytes will be 0 if the download size is unknown.
if (totalBytes > 0)
{
// Calculate the download percentage.
- int downloadPercentage = 100 * bytesReceived / totalBytes;
+ int downloadPercentage = 100 * receivedBytes / totalBytes;
// Set the file download notification text.
- fileDownloadNotificationPointer->setText(i18nc("Download progress notification text", "%1\% of %2 downloaded (%3 of %4 bytes)", downloadPercentage, saveFileName,
- bytesReceived, totalBytes));
+ fileDownloadNotificationPointer->setText(i18nc("Download progress notification text", "%1%% of %2 downloaded (%3 of %4 bytes)", downloadPercentage, saveFileName,
+ receivedBytes, totalBytes));
}
else
{
// Set the file download notification text.
- fileDownloadNotificationPointer->setText(i18nc("Download progress notification text", "%1: %2 bytes downloaded", saveFileName, bytesReceived));
+ fileDownloadNotificationPointer->setText(i18nc("Download progress notification text", "%1: %2 bytes downloaded", saveFileName, receivedBytes));
}
// Display the updated notification.
- fileDownloadNotificationPointer->update();
+ fileDownloadNotificationPointer->sendEvent();
});
// Update the notification when the download finishes. The save file name must be copied into the lambda or a crash occurs.
- connect(webEngineDownloadItemPointer, &QWebEngineDownloadItem::finished, [fileDownloadNotificationPointer, saveFileName, saveFilePath] ()
+ connect(webEngineDownloadRequestPointer, &QWebEngineDownloadRequest::isFinishedChanged, [webEngineDownloadRequestPointer, fileDownloadNotificationPointer, saveFileName,
+ saveFilePath] ()
{
- // Set the new text.
- fileDownloadNotificationPointer->setText(i18nc("Download finished notification text", "%1 download finished", saveFileName));
+ // Update the notification if the download is finished.
+ if (webEngineDownloadRequestPointer->isFinished())
+ {
+ // Set the new text.
+ fileDownloadNotificationPointer->setText(i18nc("Download finished notification text", "%1 download finished", saveFileName));
- // Set the URL so the file options will be displayed.
- fileDownloadNotificationPointer->setUrls(QList<QUrl> {QUrl(saveFilePath)});
+ // Set the URL so the file options will be displayed.
+ fileDownloadNotificationPointer->setUrls(QList<QUrl> {QUrl(saveFilePath)});
- // Remove the actions from the notification.
- fileDownloadNotificationPointer->setActions(QStringList());
+ // Remove the actions from the notification.
+ fileDownloadNotificationPointer->clearActions();
- // Set the notification to disappear after a timeout.
- fileDownloadNotificationPointer->setFlags(KNotification::CloseOnTimeout);
+ // Set the notification to disappear after a timeout.
+ fileDownloadNotificationPointer->setFlags(KNotification::CloseOnTimeout);
- // Display the updated notification.
- fileDownloadNotificationPointer->update();
+ // Display the updated notification.
+ fileDownloadNotificationPointer->sendEvent();
+ }
});
// Display the notification.
fileDownloadNotificationPointer->sendEvent();
// Start the download.
- webEngineDownloadItemPointer->accept();
+ webEngineDownloadRequestPointer->accept();
}
else // The file save path is not populated.
{
// Cancel the download.
- webEngineDownloadItemPointer->cancel();
+ webEngineDownloadRequestPointer->cancel();
}
}
else // Cancel was selected.
{
// Cancel the download.
- webEngineDownloadItemPointer->cancel();
+ webEngineDownloadRequestPointer->cancel();
}
}
else // KDE is running and local storage (cookies) is disabled. Use KDE's native downloader.
currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, !currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
// Update the DOM storage action.
- emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
+ Q_EMIT updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
// Reload the website.
currentPrivacyWebEngineViewPointer->reload();
currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, !currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
// Update the JavaScript action.
- emit updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
+ Q_EMIT updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
// Reload the website.
currentPrivacyWebEngineViewPointer->reload();
currentPrivacyWebEngineViewPointer->localStorageEnabled = !currentPrivacyWebEngineViewPointer->localStorageEnabled;
// Update the local storage action.
- emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
+ Q_EMIT updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
// Reload the website.
currentPrivacyWebEngineViewPointer->reload();
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
{
// Update the UI.
- emit easyListStatusChanged(currentPrivacyWebEngineViewPointer->easyListEnabled);
- emit easyPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->easyPrivacyEnabled);
- emit fanboysAnnoyanceListStatusChanged(currentPrivacyWebEngineViewPointer->fanboysAnnoyanceListEnabled);
- emit ultraListStatusChanged(currentPrivacyWebEngineViewPointer->ultraListEnabled);
- emit ultraPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->ultraPrivacyEnabled);
- emit updateDefaultZoomFactor(currentPrivacyWebEngineViewPointer->defaultZoomFactor);
- emit updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String(""));
- emit updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
- emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
- emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
- emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true);
- emit updateZoomActions(currentPrivacyWebEngineViewPointer->zoomFactor());
+ Q_EMIT easyListStatusChanged(currentPrivacyWebEngineViewPointer->easyListEnabled);
+ Q_EMIT easyPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->easyPrivacyEnabled);
+ Q_EMIT fanboysAnnoyanceListStatusChanged(currentPrivacyWebEngineViewPointer->fanboysAnnoyanceListEnabled);
+ Q_EMIT ultraListStatusChanged(currentPrivacyWebEngineViewPointer->ultraListEnabled);
+ Q_EMIT ultraPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->ultraPrivacyEnabled);
+ Q_EMIT updateDefaultZoomFactor(currentPrivacyWebEngineViewPointer->defaultZoomFactor);
+ Q_EMIT updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String(""));
+ Q_EMIT updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
+ Q_EMIT updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
+ Q_EMIT updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
+ Q_EMIT updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true);
+ Q_EMIT updateZoomActions(currentPrivacyWebEngineViewPointer->zoomFactor());
}
}
void TabWidget::updateUiWithTabSettings()
{
// Clear the URL line edit focus.
- emit clearUrlLineEditFocus();
+ Q_EMIT clearUrlLineEditFocus();
// Update the current WebEngine pointers.
currentPrivacyWebEngineViewPointer = qTabWidgetPointer->currentWidget()->findChild<PrivacyWebEngineView *>();
DevToolsWebEngineView *devToolsWebEngineViewPointer = qTabWidgetPointer->currentWidget()->findChild<DevToolsWebEngineView *>();
// Update the actions.
- emit easyListStatusChanged(currentPrivacyWebEngineViewPointer->easyListEnabled);
- emit easyPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->easyPrivacyEnabled);
- emit fanboysAnnoyanceListStatusChanged(currentPrivacyWebEngineViewPointer->fanboysAnnoyanceListEnabled);
- emit ultraListStatusChanged(currentPrivacyWebEngineViewPointer->ultraListEnabled);
- emit ultraPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->ultraPrivacyEnabled);
- emit blockedRequestsUpdated(currentPrivacyWebEngineViewPointer->blockedRequestsVector);
- emit cookiesChanged(currentPrivacyWebEngineViewPointer->cookieListPointer->size());
- emit updateBackAction(currentWebEngineHistoryPointer->canGoBack());
- emit updateDefaultZoomFactor(currentPrivacyWebEngineViewPointer->defaultZoomFactor);
- emit updateDeveloperToolsAction(devToolsWebEngineViewPointer->isVisible());
- emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
- emit updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
- emit updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
- emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
- emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true);
- emit updateZoomActions(currentPrivacyWebEngineViewPointer->zoomFactor());
+ Q_EMIT easyListStatusChanged(currentPrivacyWebEngineViewPointer->easyListEnabled);
+ Q_EMIT easyPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->easyPrivacyEnabled);
+ Q_EMIT fanboysAnnoyanceListStatusChanged(currentPrivacyWebEngineViewPointer->fanboysAnnoyanceListEnabled);
+ Q_EMIT ultraListStatusChanged(currentPrivacyWebEngineViewPointer->ultraListEnabled);
+ Q_EMIT ultraPrivacyStatusChanged(currentPrivacyWebEngineViewPointer->ultraPrivacyEnabled);
+ Q_EMIT blockedRequestsUpdated(currentPrivacyWebEngineViewPointer->blockedRequestsVector);
+ Q_EMIT cookiesChanged(currentPrivacyWebEngineViewPointer->cookieListPointer->size());
+ Q_EMIT updateBackAction(currentWebEngineHistoryPointer->canGoBack());
+ 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);
+ Q_EMIT updateZoomActions(currentPrivacyWebEngineViewPointer->zoomFactor());
// Update the URL.
- emit updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
- emit updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String(""));
- emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->currentUrlText);
+ Q_EMIT updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
+ Q_EMIT updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String(""));
+ Q_EMIT updateUrlLineEdit(QUrl(currentPrivacyWebEngineViewPointer->currentUrlText));
// Update the find text.
- emit updateFindText(currentPrivacyWebEngineViewPointer->findString, currentPrivacyWebEngineViewPointer->findCaseSensitive);
- emit updateFindTextResults(currentPrivacyWebEngineViewPointer->findTextResult);
+ Q_EMIT updateFindText(currentPrivacyWebEngineViewPointer->findString, currentPrivacyWebEngineViewPointer->findCaseSensitive);
+ Q_EMIT updateFindTextResults(currentPrivacyWebEngineViewPointer->findTextResult);
// Update the progress bar.
if (currentPrivacyWebEngineViewPointer->loadProgressInt >= 0)
- emit showProgressBar(currentPrivacyWebEngineViewPointer->loadProgressInt);
+ Q_EMIT showProgressBar(currentPrivacyWebEngineViewPointer->loadProgressInt);
else
- emit hideProgressBar();
+ Q_EMIT hideProgressBar();
}
void TabWidget::useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName)
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 TAB_WIDGET_H
// The public static variables.
static QString webEngineDefaultUserAgent;
-signals:
+Q_SIGNALS:
// The signals.
void addCookie(const QNetworkCookie &cookie) const;
void blockedRequestsUpdated(const QVector<int> blockedRequests) const;
public Q_SLOTS:
// The public slots.
void addCookieToStore(QNetworkCookie cookie, QWebEngineCookieStore *webEngineCookieStorePointer = nullptr) const;
- PrivacyWebEngineView* addTab(const bool removeUrlLineEditFocus = false, const bool adjacent = false, const bool backgroundTab = false, const QString urlString = nullptr);
+ PrivacyWebEngineView* addTab(const bool removeUrlLineEditFocus = false, const bool adjacent = false, const bool backgroundTab = false, const QString urlString = QLatin1String(""));
void applyApplicationSettings();
void applyDomainSettingsAndReload();
void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
void findTextFinished(const QWebEngineFindTextResult &findTextResult);
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
void pageLinkHovered(const QString &linkUrl) const;
- void printWebpage(QPrinter *printerPointer) const;
- void showSaveDialog(QWebEngineDownloadItem *downloadItemPointer);
+ void showSaveDialog(QWebEngineDownloadRequest *downloadRequestPointer);
void stopLoadingFavoriteIconMovie() const;
void updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
void updateUiWithTabSettings();
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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.
inputMethodEventAttributeList.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, endOfDomainNameIndex, urlStringLength - endOfDomainNameIndex, grayTextCharFormat));
// Create an input method event with an empty pre-edit string.
- QInputMethodEvent inputMethodEvent(QString(""), inputMethodEventAttributeList);
+ QInputMethodEvent inputMethodEvent(QLatin1String(""), inputMethodEventAttributeList);
// Apply the URL highlighting.
event(&inputMethodEvent);
-/*
- * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * 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 URLLINEEDIT_H
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 <https://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 "structs/BookmarkStruct.h"
// Qt toolkit headers.
+#include <QActionGroup>
#include <QClipboard>
#include <QContextMenuEvent>
#include <QDBusConnection>
viewBookmarksToolBarActionPointer->setText(i18nc("View bookmarks toolbar action", "View Bookmarks Toolbar"));
domainSettingsActionPointer->setText(i18nc("Domain Settings action", "Domain Settings"));
cookiesActionPointer->setText(i18nc("Cookies action, which also displays the number of cookies", "Cookies - %1", 0));
- blockedRequestsActionPointer->setText("0");
+ blockedRequestsActionPointer->setText(QLatin1String("0"));
findCaseSensitiveActionPointer->setText(i18nc("Find Case Sensitive action", "Find Case Sensitive"));
hideFindTextActionPointer->setText(i18nc("Hide Find Text action (the text should include the language-specific escape keyboard shortcut).", "Hide Find Text (Esc)"));
stopActionPointer->setIcon(QIcon::fromTheme(QLatin1String("process-stop")));
viewSourceActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-choose"), QIcon::fromTheme(QLatin1String("accessories-text-editor"))));
viewSourceInNewTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-choose"), QIcon::fromTheme(QLatin1String("accessories-text-editor"))));
- developerToolsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("add-subtitle"), QIcon::fromTheme("system-run")));
+ developerToolsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("add-subtitle"), QIcon::fromTheme(QLatin1String("system-run"))));
domStorageActionPointer->setIcon(QIcon::fromTheme(QLatin1String("code-class"), QIcon(QLatin1String("/usr/share/icons/gnome/32x32/actions/gtk-unindent-ltr.png"))));
userAgentPrivacyBrowserActionPointer->setIcon(QIcon(QLatin1String(":/icons/privacy-mode.svg")));
userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"),
// Setup the GUI based on the browserwindowui.rc file.
- setupGUI(StandardWindowOption::Default, ("browserwindowui.rc"));
+ setupGUI(StandardWindowOption::Default, (QLatin1String("browserwindowui.rc")));
// Set the open with other browser actions visibility.
openWithFirefoxActionPointer->setVisible(globalFirefoxInstalled);
openWithChromiumActionPointer->setVisible(globalChromiumInstalled);
- // Get lists of the actions' associated widgets.
- QList<QWidget*> userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets();
- QList<QWidget*> searchEngineAssociatedWidgetsPointerList = searchEngineMojeekActionPointer->associatedWidgets();
+ // Get lists of the actions' associated the widgets.
+ QList<QObject*> userAgentAssociatedObjectsPointerList = userAgentPrivacyBrowserActionPointer->associatedObjects();
+ QList<QObject*> searchEngineAssociatedObjectsPointerList = searchEngineMojeekActionPointer->associatedObjects();
// Get the menu widget pointers. It is the second entry, after the main window.
- QWidget *userAgentMenuWidgetPointer = userAgentAssociatedWidgetsPointerList[1];
- QWidget *searchEngineMenuWidgetPointer = searchEngineAssociatedWidgetsPointerList[1];
+ QObject *userAgentMenuObjectPointer = userAgentAssociatedObjectsPointerList[1];
+ QObject *searchEngineMenuObjectPointer = searchEngineAssociatedObjectsPointerList[1];
// Get the menu pointers.
- QMenu *userAgentMenuPointer = qobject_cast<QMenu*>(userAgentMenuWidgetPointer);
- QMenu *searchEngineMenuPointer = qobject_cast<QMenu*>(searchEngineMenuWidgetPointer);
+ QMenu *userAgentMenuPointer = qobject_cast<QMenu*>(userAgentMenuObjectPointer);
+ QMenu *searchEngineMenuPointer = qobject_cast<QMenu*>(searchEngineMenuObjectPointer);
// Get the menu actions.
userAgentMenuActionPointer = userAgentMenuPointer->menuAction();
connect(zoomPlusButtonPointer, SIGNAL(clicked()), this, SLOT(incrementZoom()));
// Remove the padding around the current zoom button text.
- currentZoomButtonPointer->setStyleSheet("padding: 0px;");
+ currentZoomButtonPointer->setStyleSheet(QLatin1String("padding: 0px;"));
// Add the widgets to the far right of the status bar.
statusBarPointer->addPermanentWidget(progressBarPointer);
connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape()));
// Get a handle for the Bookmarks menu.
- bookmarksMenuPointer = qobject_cast<QMenu*>(guiFactory()->container("bookmarks", this));
+ bookmarksMenuPointer = qobject_cast<QMenu*>(guiFactory()->container(QLatin1String("bookmarks"), this));
// Add a separator to the bookmarks menu.
bookmarksMenuPointer->addSeparator();
void BrowserWindow::openWithChromium() const
{
// Open the current URL in Chromium
- QProcess::startDetached("chromium", QStringList(urlLineEditPointer->text()));
+ QProcess::startDetached(QLatin1String("chromium"), QStringList(urlLineEditPointer->text()));
}
void BrowserWindow::openWithFirefox() const
{
// Open the current URL in Firefox.
- QProcess::startDetached("firefox-esr", QStringList(urlLineEditPointer->text()));
+ QProcess::startDetached(QLatin1String("firefox-esr"), QStringList(urlLineEditPointer->text()));
}
void BrowserWindow::populateBookmarksInAllWindows() const
QStringList registeredServiceNames = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
// Get a list of all the Privacy Browser windows, which will be `com.stoutner.privacybrowser-` with the PID appended.
- QStringList privacyBrowserServiceNames = registeredServiceNames.filter("com.stoutner.privacybrowser");
+ QStringList privacyBrowserServiceNames = registeredServiceNames.filter(QLatin1String("com.stoutner.privacybrowser"));
// Reapply domain settings in each window.
for (QString privacyBrowserServiceName : privacyBrowserServiceNames)
{
// Prepare the D-Bus message.
- QDBusMessage dBusMessage = QDBusMessage::createMethodCall(privacyBrowserServiceName, "/privacybrowser/MainWindow_1", "com.stoutner.privacybrowser.BrowserWindow", methodString);
+ QDBusMessage dBusMessage = QDBusMessage::createMethodCall(privacyBrowserServiceName, QLatin1String("/privacybrowser/MainWindow_1"), QLatin1String("com.stoutner.privacybrowser.BrowserWindow"),
+ methodString);
// Make it so.
QDBusConnection::sessionBus().send(dBusMessage);
// Temporarily set the context menu policy to the default.
bookmarksToolBarPointer->setContextMenuPolicy(Qt::DefaultContextMenu);
- // Create a context menu event with the same position.
- QContextMenuEvent *contextMenuEventPointer = new QContextMenuEvent(QContextMenuEvent::Mouse, point);
+ // Create a context menu event with the same position. The global position is set to the current mouse position.
+ QContextMenuEvent *contextMenuEventPointer = new QContextMenuEvent(QContextMenuEvent::Mouse, point, QCursor::pos());
// Send the context menu event to the toolbar.
QCoreApplication::sendEvent(bookmarksToolBarPointer, contextMenuEventPointer);
void BrowserWindow::toggleViewSourceInNewTab() const
{
// Get the current URL.
- QString url = urlLineEditPointer->text();
+ QString urlString = urlLineEditPointer->text();
// Toggle the URL.
- if (url.startsWith(QLatin1String("view-source:"))) // The source is currently being viewed.
+ if (urlString.startsWith(QLatin1String("view-source:"))) // The source is currently being viewed.
{
// Remove `view-source:` from the URL.
- url = url.remove(0, 12);
+ urlString = urlString.remove(0, 12);
}
else // The source is not currently being viewed.
{
// Prepend `view-source:` from the URL.
- url = url.prepend(QLatin1String("view-source:"));
+ urlString = urlString.prepend(QLatin1String("view-source:"));
}
// Add the new tab. `true` removes the URL line edit focus, `true` opens the new tab in an adjacent tab. `false` does not open a background tab.
- tabWidgetPointer->addTab(true, true, false, url);
+ tabWidgetPointer->addTab(true, true, false, urlString);
}
void BrowserWindow::updateBookmarkedAction() const
{
// Update the bookmarked action to reflect the current state.
if (bookmarkedActionPointer->isChecked())
- bookmarkedActionPointer->setIcon(QIcon::fromTheme("starred-symbolic"));
+ bookmarkedActionPointer->setIcon(QIcon::fromTheme(QLatin1String("starred-symbolic")));
else
- bookmarkedActionPointer->setIcon(QIcon::fromTheme("non-starred-symbolic"));
+ bookmarkedActionPointer->setIcon(QIcon::fromTheme(QLatin1String("non-starred-symbolic")));
}
void BrowserWindow::updateRequestsAction(const QVector<int> blockedRequestsVector) const
// Initialize the custom search engine flag.
bool customSearchEngine = false;
- if (searchEngine == "Mojeek") // Mojeek.
+ if (searchEngine == QLatin1String("Mojeek")) // Mojeek.
{
// Check the Mojeek user agent action.
searchEngineMojeekActionPointer->setChecked(true);
// Update the search engine menu action text.
searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Mojeek"));
}
- else if (searchEngine == "Monocles") // Monocles.
+ else if (searchEngine == QLatin1String("Monocles")) // Monocles.
{
// Check the Monocles user agent action.
searchEngineMonoclesActionPointer->setChecked(true);
// Update the search engine menu action text.
searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Monocles"));
}
- else if (searchEngine == "MetaGer") // MetaGer.
+ else if (searchEngine == QLatin1String("MetaGer")) // MetaGer.
{
// Check the MetaGer user agent action.
searchEngineMetagerActionPointer->setChecked(true);
// Update the search engine menu action text.
searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - MetaGer"));
}
- else if (searchEngine == "Google") // Google.
+ else if (searchEngine == QLatin1String("Google")) // Google.
{
// Check the Google user agent action.
searchEngineGoogleActionPointer->setChecked(true);
// Update the search engine menu action text.
searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Google"));
}
- else if (searchEngine == "Bing") // Bing.
+ else if (searchEngine == QLatin1String("Bing")) // Bing.
{
// Check the Bing user agent action.
searchEngineBingActionPointer->setChecked(true);
// Update the search engine menu action text.
searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Bing"));
}
- else if (searchEngine == "Yahoo") // Yahoo.
+ else if (searchEngine == QLatin1String("Yahoo")) // Yahoo.
{
// Check the Yahoo user agent action.
searchEngineYahooActionPointer->setChecked(true);
void BrowserWindow::updateUrlLineEdit(const QUrl &newUrl)
{
// Get the new URL string in encoded form, which displays punycode.
- QString newUrlString = newUrl.toEncoded();
+ QString newUrlString = QLatin1String(newUrl.toEncoded());
// Update the view source actions.
if (newUrlString.startsWith(QLatin1String("view-source:"))) // The source is currently being viewed.
userAgentPrivacyBrowserActionPointer->setChecked(true);
// Update the user agent menu action icon.
- userAgentMenuActionPointer->setIcon(QIcon(":/icons/privacy-mode.svg"));
+ userAgentMenuActionPointer->setIcon(QIcon(QLatin1String(":/icons/privacy-mode.svg")));
// Update the user agent menu action text.
userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Privacy Browser"));
-/*
- * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2022-2024 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 <https://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 BROWSER_WINDOW_H