From: Soren Stoutner Date: Wed, 11 Dec 2024 17:21:04 +0000 (-0700) Subject: Migrate to Qt6 and KF6. https://redmine.stoutner.com/issues/1223 X-Git-Tag: v0.7~2 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=e8e79f137e35e9d0373b12a412b1f51404527bc0;p=PrivacyBrowserPC.git Migrate to Qt6 and KF6. https://redmine.stoutner.com/issues/1223 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bdc5413..bded855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,20 @@ -# Copyright 2022-2024 Soren Stoutner . +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: 2022-2024 Soren Stoutner # # This file is part of 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 . +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . # Set the minimum CMake version. @@ -23,8 +24,8 @@ cmake_minimum_required(VERSION 3.16) 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) @@ -53,7 +54,7 @@ include(FeatureSummary) #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 @@ -64,7 +65,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS ) # 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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86bf000..a5e0a2f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,19 +1,20 @@ -# Copyright 2022-2024 Soren Stoutner . +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: 2022-2024 Soren Stoutner # # This file is part of 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 . +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . # Create the executable and add the resources. add_executable(privacybrowser resources.qrc) @@ -59,24 +60,24 @@ ki18n_wrap_ui(privacybrowser # 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. diff --git a/src/databases/BookmarksDatabase.cpp b/src/databases/BookmarksDatabase.cpp index 1050ba7..af5bfef 100644 --- a/src/databases/BookmarksDatabase.cpp +++ b/src/databases/BookmarksDatabase.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -24,16 +24,16 @@ 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() {} @@ -44,7 +44,7 @@ void BookmarksDatabase::addDatabase() 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. @@ -52,8 +52,11 @@ void BookmarksDatabase::addDatabase() // 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(); @@ -66,8 +69,11 @@ void BookmarksDatabase::addDatabase() { // 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. @@ -76,15 +82,15 @@ void BookmarksDatabase::addDatabase() 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()) @@ -93,8 +99,11 @@ void BookmarksDatabase::addDatabase() 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. @@ -116,21 +125,20 @@ void BookmarksDatabase::addBookmark(const BookmarkStruct *bookmarkStructPointer) 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(); @@ -148,23 +156,22 @@ void BookmarksDatabase::addFolder(const BookmarkStruct *bookmarkStructPointer) 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(); @@ -179,10 +186,10 @@ void BookmarksDatabase::deleteBookmark(const int databaseId) 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(); @@ -197,10 +204,11 @@ void BookmarksDatabase::deleteBookmarks(const QString url) 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(); @@ -209,10 +217,10 @@ void BookmarksDatabase::deleteBookmarks(const QString url) 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(); @@ -250,10 +258,10 @@ double BookmarksDatabase::generateFolderId() 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(); @@ -277,10 +285,11 @@ QList* BookmarksDatabase::getAllFolderUrls(const double folderId) 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(); @@ -320,10 +329,10 @@ BookmarkStruct* BookmarksDatabase::getBookmark(const int databaseId) 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(); @@ -369,7 +378,7 @@ std::list* BookmarksDatabase::getBookmarks() 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(); @@ -438,10 +447,11 @@ QList* BookmarksDatabase::getBookmarksInFolderExcept(const doubl } // 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(); @@ -503,7 +513,7 @@ QString BookmarksDatabase::getFavoriteIconBase64String(const QIcon &favoriteIcon 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; @@ -521,10 +531,11 @@ QList* BookmarksDatabase::getFolderContents(const double folderI 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(); @@ -577,10 +588,10 @@ QList* BookmarksDatabase::getFolderContentsDatabaseIds(const double folderI 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(); @@ -611,10 +622,11 @@ QList *BookmarksDatabase::getFolderContentsDatabaseIdsRecursively(const dou 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(); @@ -649,10 +661,10 @@ int BookmarksDatabase::getFolderDatabaseId(const double folderId) 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(); @@ -676,10 +688,10 @@ double BookmarksDatabase::getFolderId(const int databaseId) 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(); @@ -703,10 +715,10 @@ int BookmarksDatabase::getFolderItemCount(const double folderId) 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(); @@ -740,10 +752,10 @@ double BookmarksDatabase::getParentFolderId(const int databaseId) 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(); @@ -767,10 +779,11 @@ QList* BookmarksDatabase::getSubfolders(const double folderId) 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(); @@ -822,10 +835,11 @@ bool BookmarksDatabase::isBookmarked(const QString url) 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(); @@ -849,10 +863,10 @@ bool BookmarksDatabase::isFolder(const int databaseId) 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(); @@ -873,21 +887,21 @@ void BookmarksDatabase::updateBookmark(const BookmarkStruct *bookmarkStructPoint 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(); @@ -902,13 +916,13 @@ void BookmarksDatabase::updateBookmarkName(const int databaseId, const QString & 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(); @@ -923,13 +937,13 @@ void BookmarksDatabase::updateBookmarkUrl(const int databaseId, const QString &b 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(); @@ -944,13 +958,13 @@ void BookmarksDatabase::updateDisplayOrder(const int databaseId, const int displ 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(); @@ -968,10 +982,11 @@ void BookmarksDatabase::updateFolderContentsDisplayOrder(const double folderId) 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(); @@ -1000,15 +1015,15 @@ void BookmarksDatabase::updateParentFolderAndDisplayOrder(const int databaseId, 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(); diff --git a/src/databases/BookmarksDatabase.h b/src/databases/BookmarksDatabase.h index 932a1e4..8ab1abc 100644 --- a/src/databases/BookmarksDatabase.h +++ b/src/databases/BookmarksDatabase.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef BOOKMARKSDATABASE_H diff --git a/src/databases/CookiesDatabase.cpp b/src/databases/CookiesDatabase.cpp index e8a870b..a392dee 100644 --- a/src/databases/CookiesDatabase.cpp +++ b/src/databases/CookiesDatabase.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2023 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -24,16 +24,16 @@ 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() {} @@ -44,7 +44,7 @@ void CookiesDatabase::addDatabase() 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. @@ -52,8 +52,11 @@ void CookiesDatabase::addDatabase() // 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(); @@ -70,8 +73,11 @@ void CookiesDatabase::addDatabase() // 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. @@ -80,15 +86,15 @@ void CookiesDatabase::addDatabase() 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()) @@ -97,8 +103,11 @@ void CookiesDatabase::addDatabase() 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. @@ -125,25 +134,24 @@ void CookiesDatabase::addCookie(const QNetworkCookie &cookie) 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(); @@ -162,7 +170,7 @@ int CookiesDatabase::cookieCount() 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(); @@ -193,7 +201,7 @@ void CookiesDatabase::deleteAllCookies() 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(); @@ -208,15 +216,15 @@ void CookiesDatabase::deleteCookie(const QNetworkCookie &cookie) 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(); @@ -234,7 +242,7 @@ QList* CookiesDatabase::getCookies() 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(); @@ -277,10 +285,10 @@ QNetworkCookie* CookiesDatabase::getCookieById(const int &id) 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(); @@ -316,15 +324,15 @@ bool CookiesDatabase::isDurable(const QNetworkCookie &cookie) 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(); @@ -345,19 +353,19 @@ bool CookiesDatabase::isUpdate(const QNetworkCookie &cookie) 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(); @@ -403,23 +411,23 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &cookie) 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(); @@ -437,15 +445,15 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &oldCookie, const QNetwo 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(); @@ -457,25 +465,25 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &oldCookie, const QNetwo 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(); diff --git a/src/databases/CookiesDatabase.h b/src/databases/CookiesDatabase.h index b81557b..43def21 100644 --- a/src/databases/CookiesDatabase.h +++ b/src/databases/CookiesDatabase.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2023 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2023 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef COOKIESDATABASE_H diff --git a/src/databases/DomainsDatabase.cpp b/src/databases/DomainsDatabase.cpp index ba761ed..f6d643b 100644 --- a/src/databases/DomainsDatabase.cpp +++ b/src/databases/DomainsDatabase.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -26,21 +26,21 @@ 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() {} @@ -51,7 +51,7 @@ void DomainsDatabase::addDatabase() 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. @@ -59,8 +59,11 @@ void DomainsDatabase::addDatabase() // 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(); @@ -77,8 +80,11 @@ void DomainsDatabase::addDatabase() // 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]]; @@ -87,8 +93,12 @@ void DomainsDatabase::addDatabase() // 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]]; @@ -97,9 +107,12 @@ void DomainsDatabase::addDatabase() // 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]]; @@ -108,8 +121,11 @@ void DomainsDatabase::addDatabase() // 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]]; @@ -118,8 +134,11 @@ void DomainsDatabase::addDatabase() // 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]]; @@ -135,7 +154,8 @@ void DomainsDatabase::addDatabase() 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(); @@ -218,17 +238,17 @@ void DomainsDatabase::addDatabase() 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(); @@ -241,20 +261,26 @@ void DomainsDatabase::addDatabase() // 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. @@ -263,20 +289,20 @@ void DomainsDatabase::addDatabase() 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()) @@ -285,8 +311,11 @@ void DomainsDatabase::addDatabase() 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. @@ -314,35 +343,35 @@ void DomainsDatabase::addDomain(const QString &domainName, const int javaScriptI 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(); @@ -360,7 +389,7 @@ QSqlQuery DomainsDatabase::getDomainQuery(const QString &hostname) 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(); @@ -388,24 +417,24 @@ QSqlQuery DomainsDatabase::getDomainQuery(const QString &hostname) 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(); diff --git a/src/databases/DomainsDatabase.h b/src/databases/DomainsDatabase.h index eaa4b68..4cce539 100644 --- a/src/databases/DomainsDatabase.h +++ b/src/databases/DomainsDatabase.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef DOMAINS_DATABASE_H diff --git a/src/dialogs/AddBookmarkDialog.cpp b/src/dialogs/AddBookmarkDialog.cpp index 041ca3d..991962c 100644 --- a/src/dialogs/AddBookmarkDialog.cpp +++ b/src/dialogs/AddBookmarkDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -105,7 +105,7 @@ AddBookmarkDialog::AddBookmarkDialog(QWidget *parentWidgetPointer, const QString 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())); @@ -144,7 +144,7 @@ void AddBookmarkDialog::addBookmark() BookmarksDatabase::addBookmark(bookmarkStructPointer); // Update the list of bookmarks in the menu and toolbar. - emit bookmarkAdded(); + Q_EMIT bookmarkAdded(); // Close the dialog. close(); diff --git a/src/dialogs/AddBookmarkDialog.h b/src/dialogs/AddBookmarkDialog.h index 7d38628..e320518 100644 --- a/src/dialogs/AddBookmarkDialog.h +++ b/src/dialogs/AddBookmarkDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef ADDBOOKMARKDIALOG_H @@ -38,7 +38,7 @@ public: // 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; diff --git a/src/dialogs/AddFolderDialog.cpp b/src/dialogs/AddFolderDialog.cpp index 7462930..b558c4b 100644 --- a/src/dialogs/AddFolderDialog.cpp +++ b/src/dialogs/AddFolderDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -94,7 +94,7 @@ AddFolderDialog::AddFolderDialog(QWidget *parentWidgetPointer, const QIcon &curr 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())); @@ -139,7 +139,7 @@ void AddFolderDialog::addFolder() BookmarksDatabase::addFolder(bookmarkStructPointer); // Update the list of bookmarks in the menu and toolbar. - emit folderAdded(); + Q_EMIT folderAdded(); // Close the dialog. close(); diff --git a/src/dialogs/AddFolderDialog.h b/src/dialogs/AddFolderDialog.h index e0673a3..ecdae3c 100644 --- a/src/dialogs/AddFolderDialog.h +++ b/src/dialogs/AddFolderDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef ADDFOLDERDIALOG_H @@ -38,7 +38,7 @@ public: // The primary constructor. explicit AddFolderDialog(QWidget *parentWidgetPointer, const QIcon ¤tWebsiteFavoriteIcon, const double parentFolderId); -signals: +Q_SIGNALS: // The signals. void folderAdded() const; diff --git a/src/dialogs/AddOrEditCookieDialog.cpp b/src/dialogs/AddOrEditCookieDialog.cpp index bb07c42..52a27d8 100644 --- a/src/dialogs/AddOrEditCookieDialog.cpp +++ b/src/dialogs/AddOrEditCookieDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -77,11 +77,11 @@ AddOrEditCookieDialog::AddOrEditCookieDialog(QWidget *parentWidgetPointer, const // 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); @@ -124,7 +124,7 @@ void AddOrEditCookieDialog::saveCookie() { // Delete the old cookie if this is an edit dialog. if (isEditDialog) - emit deleteCookie(originalCookie); + Q_EMIT deleteCookie(originalCookie); // Create the variables. QNetworkCookie cookie; @@ -170,7 +170,7 @@ void AddOrEditCookieDialog::saveCookie() } // Add the cookie to the store, the list, and the tree. - emit addCookie(cookie, isDurable); + Q_EMIT addCookie(cookie, isDurable); // Close the dialog. close(); @@ -201,3 +201,4 @@ void AddOrEditCookieDialog::updateUi() const saveButtonPointer->setDisabled(domainLineEditPointer->text().isEmpty() || nameLineEditPointer->text().isEmpty() || pathLineEditPointer->text().isEmpty() || valueLineEditPointer->text().isEmpty()); } + diff --git a/src/dialogs/AddOrEditCookieDialog.h b/src/dialogs/AddOrEditCookieDialog.h index cb641c9..087b111 100644 --- a/src/dialogs/AddOrEditCookieDialog.h +++ b/src/dialogs/AddOrEditCookieDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022, 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef ADDOREDITCOOKIEDIALOG_H @@ -39,7 +39,7 @@ public: 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; diff --git a/src/dialogs/BookmarksDialog.cpp b/src/dialogs/BookmarksDialog.cpp index 683d240..d4349aa 100644 --- a/src/dialogs/BookmarksDialog.cpp +++ b/src/dialogs/BookmarksDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -136,7 +136,7 @@ void BookmarksDialog::deleteItems() const populateBookmarks(); // Emit the bookmark updated signal to redraw the bookmarks in the menu and toolbar. - emit bookmarkUpdated(); + Q_EMIT bookmarkUpdated(); } void BookmarksDialog::populateBookmarks() const @@ -258,7 +258,7 @@ void BookmarksDialog::refreshBookmarks() 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 @@ -415,7 +415,7 @@ void BookmarksDialog::updateBookmarkFromTree(QStandardItem *modifiedStandardItem } // Emit the bookmark updated signal. - emit bookmarkUpdated(); + Q_EMIT bookmarkUpdated(); } void BookmarksDialog::updateSelection() const diff --git a/src/dialogs/BookmarksDialog.h b/src/dialogs/BookmarksDialog.h index 0df0903..028aa33 100644 --- a/src/dialogs/BookmarksDialog.h +++ b/src/dialogs/BookmarksDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef BOOKMARKSDIALOG_H @@ -46,7 +46,7 @@ public: static const int IS_FOLDER_COLUMN = 4; static const int FOLDER_ID_COLUMN = 5; -signals: +Q_SIGNALS: // The signals. void bookmarkUpdated() const; diff --git a/src/dialogs/CookiesDialog.cpp b/src/dialogs/CookiesDialog.cpp index 57e5ed7..db65776 100644 --- a/src/dialogs/CookiesDialog.cpp +++ b/src/dialogs/CookiesDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -70,20 +70,20 @@ bool cookieSortPredicate(const QNetworkCookie &leftHandCookie, const QNetworkCoo 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) @@ -167,7 +167,7 @@ CookiesDialog::CookiesDialog(std::list *originalCookieListPointe cookieListPointer->sort(cookieSortPredicate); // Create the current domain string. - QString currentDomainString = ""; + QString currentDomainString = QLatin1String(""); // Create the current domain item pointer. QStandardItem *currentDomainItemPointer; @@ -201,13 +201,13 @@ CookiesDialog::CookiesDialog(std::list *originalCookieListPointe QList 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); @@ -259,7 +259,7 @@ CookiesDialog::CookiesDialog(std::list *originalCookieListPointe 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())); @@ -300,7 +300,7 @@ CookiesDialog::CookiesDialog(std::list *originalCookieListPointe 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(); @@ -332,15 +332,15 @@ void CookiesDialog::addCookieFromDialog(const QNetworkCookie &cookie, const bool 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; @@ -360,15 +360,15 @@ void CookiesDialog::addCookieFromDialog(const QNetworkCookie &cookie, const bool 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. @@ -398,7 +398,7 @@ void CookiesDialog::addCookieFromDialog(const QNetworkCookie &cookie, const bool } // 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. @@ -406,12 +406,12 @@ void CookiesDialog::addCookieFromDialog(const QNetworkCookie &cookie, const bool // 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); @@ -507,7 +507,7 @@ void CookiesDialog::deleteCookie(const QModelIndex &modelIndex, const bool &dele 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) @@ -557,7 +557,7 @@ void CookiesDialog::deleteCookieFromDatabase(const QNetworkCookie &cookie) const 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); @@ -591,7 +591,7 @@ void CookiesDialog::deleteCookieFromDialog(const QNetworkCookie &cookie) const 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() @@ -642,7 +642,7 @@ void CookiesDialog::showDeleteAllMessageBox() const if (deleteDurableCookiesCheckBox.isChecked()) // Delete everything. { // Delete all the cookies. - emit deleteAllCookies(); + Q_EMIT deleteAllCookies(); // Clear the tree model. treeModelPointer->clear(); diff --git a/src/dialogs/CookiesDialog.h b/src/dialogs/CookiesDialog.h index 5319897..4127ef1 100644 --- a/src/dialogs/CookiesDialog.h +++ b/src/dialogs/CookiesDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef COOKIESDIALOG_H @@ -39,7 +39,7 @@ public: // The primary constructor. explicit CookiesDialog(std::list *cookieListPointer); -signals: +Q_SIGNALS: // The signals. void addCookie(const QNetworkCookie &cookie) const; void deleteAllCookies() const; diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index dd10f48..cfe8248 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -219,7 +219,7 @@ void DomainSettingsDialog::apply() const updateButtons(); // Emit the domain settings updated signal. - emit domainSettingsUpdated(); + Q_EMIT domainSettingsUpdated(); } void DomainSettingsDialog::cancel() @@ -408,7 +408,7 @@ void DomainSettingsDialog::ok() domainsTableModelPointer->submitAll(); // Emit the domain settings updated signal. - emit domainSettingsUpdated(); + Q_EMIT domainSettingsUpdated(); // Close the dialog. accept(); @@ -641,7 +641,7 @@ void DomainSettingsDialog::populateUserAgentLabel(const QString &userAgentName) else { // Display the user agent name in bold. - userAgentLabelPointer->setText("" + userAgentName + ""); + userAgentLabelPointer->setText(QLatin1String("") + userAgentName + QLatin1String("")); // Set the palette. userAgentWidgetPointer->setPalette(highlightedPalette); @@ -696,7 +696,7 @@ void DomainSettingsDialog::showAddMessageBox() updateButtons(); // Emit the domain settings updated signal. - emit domainSettingsUpdated(); + Q_EMIT domainSettingsUpdated(); } } @@ -742,7 +742,7 @@ void DomainSettingsDialog::showDeleteAllMessageBox() const updateButtons(); // Emit the domain settings updated signal. - emit domainSettingsUpdated(); + Q_EMIT domainSettingsUpdated(); } } @@ -807,7 +807,7 @@ void DomainSettingsDialog::showDeleteMessageBox() const updateButtons(); // Emit the domain settings updated signal. - emit domainSettingsUpdated(); + Q_EMIT domainSettingsUpdated(); } } diff --git a/src/dialogs/DomainSettingsDialog.h b/src/dialogs/DomainSettingsDialog.h index 6453044..d14a21b 100644 --- a/src/dialogs/DomainSettingsDialog.h +++ b/src/dialogs/DomainSettingsDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022, 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef DOMAIN_SETTINGS_DIALOG_H @@ -46,7 +46,7 @@ public: static const int ADD_DOMAIN; static const int EDIT_DOMAIN; -signals: +Q_SIGNALS: void domainSettingsUpdated() const; private Q_SLOTS: diff --git a/src/dialogs/DurableCookiesDialog.cpp b/src/dialogs/DurableCookiesDialog.cpp index f076985..58beddd 100644 --- a/src/dialogs/DurableCookiesDialog.cpp +++ b/src/dialogs/DurableCookiesDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -138,7 +138,7 @@ void DurableCookiesDialog::beforeDelete(int row) const 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 @@ -156,7 +156,7 @@ 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. @@ -196,7 +196,7 @@ void DurableCookiesDialog::newCookie(QSqlRecord &sqlRecord) const 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() @@ -235,5 +235,5 @@ void DurableCookiesDialog::updateUi() const applyButtonPointer->setEnabled(durableCookiesTableModelPointer->isDirty()); // Update the parent UI. - emit updateParentUi(); + Q_EMIT updateParentUi(); } diff --git a/src/dialogs/DurableCookiesDialog.h b/src/dialogs/DurableCookiesDialog.h index 64294f8..023473c 100644 --- a/src/dialogs/DurableCookiesDialog.h +++ b/src/dialogs/DurableCookiesDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022, 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef DURABLECOOKIESDIALOG_H @@ -35,7 +35,7 @@ public: // 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; diff --git a/src/dialogs/EditBookmarkDialog.cpp b/src/dialogs/EditBookmarkDialog.cpp index bad010e..01ac4d2 100644 --- a/src/dialogs/EditBookmarkDialog.cpp +++ b/src/dialogs/EditBookmarkDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -180,7 +180,7 @@ void EditBookmarkDialog::save() BookmarksDatabase::updateFolderContentsDisplayOrder(bookmarkStructPointer->parentFolderId); // Emit the bookmark saved signal. - emit bookmarkSaved(); + Q_EMIT bookmarkSaved(); // Close the dialog. close(); diff --git a/src/dialogs/EditBookmarkDialog.h b/src/dialogs/EditBookmarkDialog.h index f862bc0..dbb91af 100644 --- a/src/dialogs/EditBookmarkDialog.h +++ b/src/dialogs/EditBookmarkDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef EDITBOOKMARKDIALOG_H @@ -38,7 +38,7 @@ public: // The primary constructor. explicit EditBookmarkDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon ¤tWebsiteFavoriteIcon); -signals: +Q_SIGNALS: // The signals. void bookmarkSaved() const; diff --git a/src/dialogs/EditFolderDialog.cpp b/src/dialogs/EditFolderDialog.cpp index bae0965..5ad5f05 100644 --- a/src/dialogs/EditFolderDialog.cpp +++ b/src/dialogs/EditFolderDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -178,7 +178,7 @@ void EditFolderDialog::save() BookmarksDatabase::updateFolderContentsDisplayOrder(folderBookmarkStructPointer->parentFolderId); // Emit the folder saved signal. - emit folderSaved(); + Q_EMIT folderSaved(); // Close the dialog. close(); diff --git a/src/dialogs/EditFolderDialog.h b/src/dialogs/EditFolderDialog.h index 899d5af..1436350 100644 --- a/src/dialogs/EditFolderDialog.h +++ b/src/dialogs/EditFolderDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef EDITFOLDERDIALOG_H @@ -37,7 +37,7 @@ public: // The primary constructor. explicit EditFolderDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon ¤tWebsiteFavoriteIcon); -signals: +Q_SIGNALS: // The signals. void folderSaved() const; diff --git a/src/dialogs/SaveDialog.cpp b/src/dialogs/SaveDialog.cpp index dac011c..e94f38a 100644 --- a/src/dialogs/SaveDialog.cpp +++ b/src/dialogs/SaveDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -76,9 +76,9 @@ SaveDialog::SaveDialog(QWidget *parentWidgetPointer, QUrl &url, QString &mimeTyp mimeGraphicsScenePointer->addPixmap(mimeTypeIcon.pixmap(64, 64)); // Populate the labels. - urlLabelPointer->setText("" + downloadUrl.toString() + ""); - filetypeLabelPointer->setText("" + mimeType.comment() + ""); - mimeTypeLabelPointer->setText("" + mimeTypeString + ""); + urlLabelPointer->setText(QLatin1String("") + downloadUrl.toString() + QLatin1String("")); + filetypeLabelPointer->setText(QLatin1String("") + mimeType.comment() + QLatin1String("")); + mimeTypeLabelPointer->setText(QLatin1String("") + mimeTypeString + QLatin1String("")); // Populate the download size label. if (totalBytes == -1) // The file size is unknown. @@ -114,7 +114,7 @@ SaveDialog::SaveDialog(QWidget *parentWidgetPointer, QUrl &url, QString &mimeTyp void SaveDialog::showFilePicker() { // Show the file picker dialog. - emit useNativeKdeDownloader(downloadUrl, suggestedFileName); + Q_EMIT useNativeKdeDownloader(downloadUrl, suggestedFileName); // Close the dialog. reject(); diff --git a/src/dialogs/SaveDialog.h b/src/dialogs/SaveDialog.h index a994d18..ab6f48f 100644 --- a/src/dialogs/SaveDialog.h +++ b/src/dialogs/SaveDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022, 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef SAVEDIALOG_H @@ -23,7 +23,7 @@ // Qt toolkit headers. #include #include -#include +#include class SaveDialog : public QDialog { @@ -34,7 +34,7 @@ public: // 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); diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp index 7fc0f54..701d5e2 100644 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -95,7 +95,7 @@ SettingsDialog::SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton 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(); @@ -120,7 +120,7 @@ SettingsDialog::SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton 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"); @@ -167,7 +167,7 @@ SettingsDialog::SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton 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); @@ -184,7 +184,7 @@ SettingsDialog::SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton coreConfigSkeletonPointer->save(); // Emit the spell check languages updated signal. - emit spellCheckLanguagesUpdated(); + Q_EMIT spellCheckLanguagesUpdated(); } }; @@ -209,7 +209,7 @@ void SettingsDialog::showDownloadDirectoryBrowseDialog() 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. { diff --git a/src/dialogs/SettingsDialog.h b/src/dialogs/SettingsDialog.h index bf56e18..0777ed3 100644 --- a/src/dialogs/SettingsDialog.h +++ b/src/dialogs/SettingsDialog.h @@ -1,20 +1,20 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef SETTINGSDIALOG_H @@ -36,7 +36,7 @@ public: // The primary constructor. explicit SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton *coreConfigSkeletonPointer); -signals: +Q_SIGNALS: void spellCheckLanguagesUpdated() const; private Q_SLOTS: diff --git a/src/filters/MouseEventFilter.cpp b/src/filters/MouseEventFilter.cpp index 1d08396..f1c647c 100644 --- a/src/filters/MouseEventFilter.cpp +++ b/src/filters/MouseEventFilter.cpp @@ -1,20 +1,20 @@ -/* - * Copyright © 2022 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -44,14 +44,14 @@ bool MouseEventFilter::eventFilter(QObject *objectPointer, QEvent *eventPointer) { 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; diff --git a/src/filters/MouseEventFilter.h b/src/filters/MouseEventFilter.h index 4e4cc4f..d51da78 100644 --- a/src/filters/MouseEventFilter.h +++ b/src/filters/MouseEventFilter.h @@ -1,20 +1,20 @@ -/* - * Copyright © 2022 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef MOUSEEVENTFILTER_H @@ -32,7 +32,7 @@ public: // The primary constructor. MouseEventFilter(); -signals: +Q_SIGNALS: // The signals. void mouseBack() const; void mouseForward() const; diff --git a/src/helpers/FilterListHelper.cpp b/src/helpers/FilterListHelper.cpp index 51f5c0c..59367cc 100644 --- a/src/helpers/FilterListHelper.cpp +++ b/src/helpers/FilterListHelper.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -564,7 +564,7 @@ bool FilterListHelper::checkDomain(QWebEngineUrlRequestInfo &urlRequestInfo, Req 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)) @@ -580,7 +580,7 @@ bool FilterListHelper::checkDomain(QWebEngineUrlRequestInfo &urlRequestInfo, Req 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)) @@ -918,7 +918,7 @@ FilterListStruct* FilterListHelper::populateFilterList(const QString &filterList 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. // `csp` specifies a Content Security Policy, which isn't handled by Privacy Browser. @@ -951,7 +951,7 @@ FilterListStruct* FilterListHelper::populateFilterList(const QString &filterList 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. diff --git a/src/helpers/FilterListHelper.h b/src/helpers/FilterListHelper.h index df7477d..93cf4c3 100644 --- a/src/helpers/FilterListHelper.h +++ b/src/helpers/FilterListHelper.h @@ -1,20 +1,20 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef FILTER_LIST_HELPER_H diff --git a/src/helpers/SearchEngineHelper.cpp b/src/helpers/SearchEngineHelper.cpp index 3b6a616..6433c5b 100644 --- a/src/helpers/SearchEngineHelper.cpp +++ b/src/helpers/SearchEngineHelper.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022, 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022, 2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -25,29 +25,29 @@ SearchEngineHelper::SearchEngineHelper() {} 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 { diff --git a/src/helpers/SearchEngineHelper.h b/src/helpers/SearchEngineHelper.h index bab9e51..1e464a8 100644 --- a/src/helpers/SearchEngineHelper.h +++ b/src/helpers/SearchEngineHelper.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef SEARCHENGINEHELPER_H diff --git a/src/interceptors/UrlRequestInterceptor.cpp b/src/interceptors/UrlRequestInterceptor.cpp index 251ef76..ffdacd2 100644 --- a/src/interceptors/UrlRequestInterceptor.cpp +++ b/src/interceptors/UrlRequestInterceptor.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -34,14 +34,14 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques { // 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(); @@ -67,7 +67,7 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques 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; } @@ -98,7 +98,7 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques // Reapply the domain settings if the host is changing. if (requestingHost != requestedHost) - emit applyDomainSettings(requestedHost); + Q_EMIT applyDomainSettings(requestedHost); } break; @@ -110,5 +110,5 @@ void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &urlReques } // Send the request struct to the privacy WebEngine view. - emit requestProcessed(requestStructPointer); + Q_EMIT requestProcessed(requestStructPointer); } diff --git a/src/interceptors/UrlRequestInterceptor.h b/src/interceptors/UrlRequestInterceptor.h index 06e450d..0fffa2b 100644 --- a/src/interceptors/UrlRequestInterceptor.h +++ b/src/interceptors/UrlRequestInterceptor.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef URL_REQUEST_INTERCEPTOR_H @@ -39,7 +39,7 @@ public: // 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; diff --git a/src/main.cpp b/src/main.cpp index 4aca922..13a1ee0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. diff --git a/src/widgets/DraggableTreeView.cpp b/src/widgets/DraggableTreeView.cpp index bbe0868..0deada6 100644 --- a/src/widgets/DraggableTreeView.cpp +++ b/src/widgets/DraggableTreeView.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -228,7 +228,7 @@ void DraggableTreeView::dropEvent(QDropEvent *dropEvent) BookmarksDatabase::updateFolderContentsDisplayOrder(parentFolderId); // Emit the bookmarks moved signal. - emit bookmarksMoved(); + Q_EMIT bookmarksMoved(); } QList* DraggableTreeView::getRootSelectedDatabaseIds(QList *selectedDatabaseIdsPointer) const diff --git a/src/widgets/DraggableTreeView.h b/src/widgets/DraggableTreeView.h index 961d2fa..aed5689 100644 --- a/src/widgets/DraggableTreeView.h +++ b/src/widgets/DraggableTreeView.h @@ -1,20 +1,20 @@ -/* - * Copyright 2023-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef DRAGGABLETREEVIEW_H @@ -32,7 +32,7 @@ public: // The default contructor. explicit DraggableTreeView(QWidget *parentWidget = nullptr); -signals: +Q_SIGNALS: // The signals. void bookmarksMoved() const; diff --git a/src/widgets/PrivacyWebEngineView.cpp b/src/widgets/PrivacyWebEngineView.cpp index 1b5d2e7..945c007 100644 --- a/src/widgets/PrivacyWebEngineView.cpp +++ b/src/widgets/PrivacyWebEngineView.cpp @@ -83,7 +83,7 @@ void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const CookiesDatabase::updateCookie(cookie); // Update the cookies action. - emit numberOfCookiesChanged(cookieListPointer->size()); + Q_EMIT numberOfCookiesChanged(cookieListPointer->size()); } void PrivacyWebEngineView::applyDomainSettingsWithoutReloading(const QString &hostname) @@ -221,7 +221,7 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo httpAuthenticationDialogsDisplayed = 0; // Update the UI. - emit updateUi(this); + Q_EMIT updateUi(this); } void PrivacyWebEngineView::clearRequestsList() @@ -238,15 +238,15 @@ 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 contextMenuActionsList = contextMenu->actions(); @@ -349,7 +349,7 @@ QWebEngineView* PrivacyWebEngineView::createWindow(QWebEnginePage::WebWindowType 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) @@ -370,13 +370,13 @@ void PrivacyWebEngineView::handleAuthenticationRequest(const QUrl &requestUrl, Q 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 @@ -387,7 +387,7 @@ void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) co cookieListPointer->remove(cookie); // Update the cookies action. - emit numberOfCookiesChanged(cookieListPointer->size()); + Q_EMIT numberOfCookiesChanged(cookieListPointer->size()); } void PrivacyWebEngineView::saveHoveredLink(const QString &hoveredLink) @@ -420,7 +420,7 @@ void PrivacyWebEngineView::storeRequest(RequestStruct *requestStructPointer) ++blockedRequestsVector[TOTAL]; // Update the blocked requests action. - emit(requestBlocked(blockedRequestsVector)); + Q_EMIT(requestBlocked(blockedRequestsVector)); } } diff --git a/src/widgets/PrivacyWebEngineView.h b/src/widgets/PrivacyWebEngineView.h index 3225642..5c7e9ae 100644 --- a/src/widgets/PrivacyWebEngineView.h +++ b/src/widgets/PrivacyWebEngineView.h @@ -74,7 +74,7 @@ public: // 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; diff --git a/src/widgets/TabWidget.cpp b/src/widgets/TabWidget.cpp index 7caccb1..4213bf2 100644 --- a/src/widgets/TabWidget.cpp +++ b/src/widgets/TabWidget.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -234,11 +234,11 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const 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()); } }); @@ -253,7 +253,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const // 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. @@ -297,7 +297,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const // 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(); @@ -311,7 +311,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const // 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. @@ -325,7 +325,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const // 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); @@ -386,7 +386,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const { // 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. @@ -399,13 +399,13 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const 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; @@ -457,7 +457,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const { // 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. @@ -465,7 +465,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const { // 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. @@ -497,9 +497,10 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const // 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. @@ -530,7 +531,7 @@ void TabWidget::applyApplicationSettings() 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() @@ -554,13 +555,13 @@ void TabWidget::applyOnTheFlySearchEngine(QAction *searchEngineActionPointer) 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 @@ -569,13 +570,13 @@ 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(); @@ -702,7 +703,7 @@ void TabWidget::findTextFinished(const QWebEngineFindTextResult &findTextResult) currentPrivacyWebEngineViewPointer->findTextResult = findTextResult; // Update the UI. - emit updateFindTextResults(findTextResult); + Q_EMIT updateFindTextResults(findTextResult); } } @@ -715,7 +716,7 @@ void TabWidget::forward() const void TabWidget::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const { // Make it so. - emit fullScreenRequested(fullScreenRequest.toggleOn()); + Q_EMIT fullScreenRequested(fullScreenRequest.toggleOn()); // Accept the request. fullScreenRequest.accept(); @@ -796,18 +797,18 @@ void TabWidget::loadInitialWebsite() 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. @@ -826,7 +827,7 @@ void TabWidget::mouseBack() const if (currentPrivacyWebEngineViewPointer->isActiveWindow() && currentWebEngineHistoryPointer->canGoBack()) { // Clear the URL line edit focus. - emit clearUrlLineEditFocus(); + Q_EMIT clearUrlLineEditFocus(); // Go back. currentPrivacyWebEngineViewPointer->back(); @@ -839,7 +840,7 @@ void TabWidget::mouseForward() const if (currentPrivacyWebEngineViewPointer->isActiveWindow() && currentWebEngineHistoryPointer->canGoForward()) { // Clear the URL line edit focus. - emit clearUrlLineEditFocus(); + Q_EMIT clearUrlLineEditFocus(); // Go forward. currentPrivacyWebEngineViewPointer->forward(); @@ -849,7 +850,7 @@ void TabWidget::mouseForward() const 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 @@ -861,55 +862,50 @@ 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`. - // 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 @@ -930,7 +926,7 @@ void TabWidget::reloadAndBypassCache() 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(); @@ -963,16 +959,16 @@ void TabWidget::setTabBarVisible(const bool visible) const 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. @@ -1011,8 +1007,8 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin 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")); @@ -1029,17 +1025,17 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin // 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")); @@ -1058,63 +1054,72 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin }); // 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(saveFilePath)}); + // Set the URL so the file options will be displayed. + fileDownloadNotificationPointer->setUrls(QList {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. @@ -1185,7 +1190,7 @@ void TabWidget::toggleDomStorage() const 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(); @@ -1239,7 +1244,7 @@ void TabWidget::toggleJavaScript() const 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(); @@ -1251,7 +1256,7 @@ void TabWidget::toggleLocalStorage() currentPrivacyWebEngineViewPointer->localStorageEnabled = !currentPrivacyWebEngineViewPointer->localStorageEnabled; // Update the local storage action. - emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled); + Q_EMIT updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled); // Reload the website. currentPrivacyWebEngineViewPointer->reload(); @@ -1296,25 +1301,25 @@ void TabWidget::updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWeb 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(); @@ -1328,37 +1333,37 @@ void TabWidget::updateUiWithTabSettings() DevToolsWebEngineView *devToolsWebEngineViewPointer = qTabWidgetPointer->currentWidget()->findChild(); // 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) diff --git a/src/widgets/TabWidget.h b/src/widgets/TabWidget.h index 8963df3..9bb2183 100644 --- a/src/widgets/TabWidget.h +++ b/src/widgets/TabWidget.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef TAB_WIDGET_H @@ -74,7 +74,7 @@ public: // The public static variables. static QString webEngineDefaultUserAgent; -signals: +Q_SIGNALS: // The signals. void addCookie(const QNetworkCookie &cookie) const; void blockedRequestsUpdated(const QVector blockedRequests) const; @@ -109,7 +109,7 @@ signals: 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); @@ -144,8 +144,7 @@ private Q_SLOTS: 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(); diff --git a/src/widgets/UrlLineEdit.cpp b/src/widgets/UrlLineEdit.cpp index 04de23b..6a8ee91 100644 --- a/src/widgets/UrlLineEdit.cpp +++ b/src/widgets/UrlLineEdit.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -101,7 +101,7 @@ void UrlLineEdit::setText(const QString &urlString) 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); diff --git a/src/widgets/UrlLineEdit.h b/src/widgets/UrlLineEdit.h index f57232a..efb296a 100644 --- a/src/widgets/UrlLineEdit.h +++ b/src/widgets/UrlLineEdit.h @@ -1,20 +1,20 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024 Soren Stoutner * - * This file is part of Privacy Browser PC . + * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef URLLINEEDIT_H diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index 66196ca..ef1ecab 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ // Application headers. @@ -38,6 +38,7 @@ #include "structs/BookmarkStruct.h" // Qt toolkit headers. +#include #include #include #include @@ -232,7 +233,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer) 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)")); @@ -251,7 +252,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer) 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"), @@ -439,23 +440,23 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer) // 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 userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets(); - QList searchEngineAssociatedWidgetsPointerList = searchEngineMojeekActionPointer->associatedWidgets(); + // Get lists of the actions' associated the widgets. + QList userAgentAssociatedObjectsPointerList = userAgentPrivacyBrowserActionPointer->associatedObjects(); + QList 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(userAgentMenuWidgetPointer); - QMenu *searchEngineMenuPointer = qobject_cast(searchEngineMenuWidgetPointer); + QMenu *userAgentMenuPointer = qobject_cast(userAgentMenuObjectPointer); + QMenu *searchEngineMenuPointer = qobject_cast(searchEngineMenuObjectPointer); // Get the menu actions. userAgentMenuActionPointer = userAgentMenuPointer->menuAction(); @@ -576,7 +577,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer) 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); @@ -620,7 +621,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer) connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape())); // Get a handle for the Bookmarks menu. - bookmarksMenuPointer = qobject_cast(guiFactory()->container("bookmarks", this)); + bookmarksMenuPointer = qobject_cast(guiFactory()->container(QLatin1String("bookmarks"), this)); // Add a separator to the bookmarks menu. bookmarksMenuPointer->addSeparator(); @@ -1179,13 +1180,13 @@ void BrowserWindow::newWindow() const 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 @@ -1457,13 +1458,14 @@ void BrowserWindow::runMethodInAllWindows(const QString &methodString) 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); @@ -1594,8 +1596,8 @@ void BrowserWindow::showBookmarkContextMenu(const QPoint &point) // 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); @@ -1835,31 +1837,31 @@ void BrowserWindow::toggleViewBookmarksToolBar() 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 blockedRequestsVector) const @@ -1983,7 +1985,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, 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); @@ -1994,7 +1996,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const // 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); @@ -2005,7 +2007,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const // 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); @@ -2016,7 +2018,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const // 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); @@ -2027,7 +2029,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const // 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); @@ -2038,7 +2040,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const // 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); @@ -2090,7 +2092,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const 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. @@ -2143,7 +2145,7 @@ void BrowserWindow::updateUserAgentActions(const QString &userAgent, const bool 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")); diff --git a/src/windows/BrowserWindow.h b/src/windows/BrowserWindow.h index eb708f9..4b8cc0b 100644 --- a/src/windows/BrowserWindow.h +++ b/src/windows/BrowserWindow.h @@ -1,20 +1,20 @@ -/* - * Copyright 2022-2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2022-2024 Soren Stoutner * * This file is part of 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef BROWSER_WINDOW_H