]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Move the Settings Dialog to its own class. https://redmine.stoutner.com/issues/1151
authorSoren Stoutner <soren@stoutner.com>
Sat, 13 Jan 2024 21:58:06 +0000 (14:58 -0700)
committerSoren Stoutner <soren@stoutner.com>
Sat, 13 Jan 2024 21:58:06 +0000 (14:58 -0700)
27 files changed:
src/dialogs/AddBookmarkDialog.cpp
src/dialogs/AddBookmarkDialog.h
src/dialogs/AddFolderDialog.cpp
src/dialogs/AddFolderDialog.h
src/dialogs/AddOrEditCookieDialog.cpp
src/dialogs/AddOrEditCookieDialog.h
src/dialogs/BookmarksDialog.cpp
src/dialogs/BookmarksDialog.h
src/dialogs/CMakeLists.txt
src/dialogs/CookiesDialog.cpp
src/dialogs/CookiesDialog.h
src/dialogs/DomainSettingsDialog.cpp
src/dialogs/DomainSettingsDialog.h
src/dialogs/DurableCookiesDialog.cpp
src/dialogs/DurableCookiesDialog.h
src/dialogs/EditBookmarkDialog.cpp
src/dialogs/EditBookmarkDialog.h
src/dialogs/EditFolderDialog.cpp
src/dialogs/EditFolderDialog.h
src/dialogs/SaveDialog.cpp
src/dialogs/SaveDialog.h
src/dialogs/SettingsDialog.cpp [new file with mode: 0644]
src/dialogs/SettingsDialog.h [new file with mode: 0644]
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index 4c91c2c2138f7a84b9f445341bde5ad616f5be46..e35759b0929393e36b9305d46a1bcf23890ee93a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -30,7 +30,8 @@
 #include <QPushButton>
 
 // Construct the class.
-AddBookmarkDialog::AddBookmarkDialog(const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon, const double parentFolderId) : QDialog(nullptr)
+AddBookmarkDialog::AddBookmarkDialog(QWidget *parentWidgetPointer, const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon, const double parentFolderId) :
+                                     QDialog(parentWidgetPointer)
 {
     // Set the window title.
     setWindowTitle(i18nc("The add bookmark dialog window title.", "Add Bookmark"));
index 311f1396cc68a6c220f17019c68b92134d1c32e5..7d38628407c6ceb6b17fa0aab0af792e08ba490e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -36,7 +36,7 @@ class AddBookmarkDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit AddBookmarkDialog(const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon, const double parentFolderId);
+    explicit AddBookmarkDialog(QWidget *parentWidgetPointer, const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon, const double parentFolderId);
 
 signals:
     // The signals.
index ec41ce36fbdfccee6c9e42f66c7f5b1c04fdef74..7462930bca1c17e5c0b3fd78a28388605083fb80 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -28,7 +28,7 @@
 #include <QFileDialog>
 
 // Construct the class.
-AddFolderDialog::AddFolderDialog(const QIcon &currentWebsiteFavoriteIcon, const double parentFolderId) : QDialog(nullptr)
+AddFolderDialog::AddFolderDialog(QWidget *parentWidgetPointer, const QIcon &currentWebsiteFavoriteIcon, const double parentFolderId) : QDialog(parentWidgetPointer)
 {
     // Set the window title.
     setWindowTitle(i18nc("The add folder dialog window title.", "Add Folder"));
index 3397b68cf9f8063996e46ed4cf0b9f9c80a92e0a..e0673a30f57c32ef543c833535674db981963a87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -36,7 +36,7 @@ class AddFolderDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit AddFolderDialog(const QIcon &currentWebsiteFavoriteIcon, const double parentFolderId);
+    explicit AddFolderDialog(QWidget *parentWidgetPointer, const QIcon &currentWebsiteFavoriteIcon, const double parentFolderId);
 
 signals:
     // The signals.
index eba44b8748b7fdc09d1cc577f04b8b75f4c20bcf..bb07c421fc4f6eab6bb4d00031be7fb3b06af2ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -34,7 +34,7 @@ const int AddOrEditCookieDialog::AddCookie = 0;
 const int AddOrEditCookieDialog::EditCookie = 1;
 
 // Construct the class.
-AddOrEditCookieDialog::AddOrEditCookieDialog(const int &dialogType, const QNetworkCookie *cookiePointer, const bool &isDurable) : QDialog(nullptr)
+AddOrEditCookieDialog::AddOrEditCookieDialog(QWidget *parentWidgetPointer, const int dialogType, const QNetworkCookie *cookiePointer, const bool isDurable) : QDialog(parentWidgetPointer)
 {
     // Set the dialog window title according to the dialog type.
     if (dialogType == AddCookie)
index 895b14ab0e099ae541ce152df788bcac2bd9de87..cb641c951a2759c1d4d75c29a058f5904a2d94c7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -33,7 +33,7 @@ class AddOrEditCookieDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit AddOrEditCookieDialog(const int &dialogType, const QNetworkCookie *cookiePointer = nullptr, const bool &isDurable = false);
+    explicit AddOrEditCookieDialog(QWidget *parentWidgetPointer, const int dialogType, const QNetworkCookie *cookiePointer = nullptr, const bool isDurable = false);
 
     // The public static constants.
     static const int AddCookie;
index 0fa2b4f983f63721973139ad0b3f363d8265c789..683d24059e69be00037ca100c7c032036dfd2ece 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -34,8 +34,8 @@
 #include <QStandardItemModel>
 
 // Construct the class.
-BookmarksDialog::BookmarksDialog(QString currentWebsiteTitle, QString currentWebsiteUrl, QIcon currentWebsiteFavorieIcon) :
-                                 QDialog(nullptr), websiteFavoriteIcon(currentWebsiteFavorieIcon), websiteTitle(currentWebsiteTitle), websiteUrl(currentWebsiteUrl)
+BookmarksDialog::BookmarksDialog(QWidget *parentWidgetPointer, QIcon currentWebsiteFavorieIcon, QString currentWebsiteTitle, QString currentWebsiteUrl) :
+                                 QDialog(parentWidgetPointer), websiteFavoriteIcon(currentWebsiteFavorieIcon), websiteTitle(currentWebsiteTitle), websiteUrl(currentWebsiteUrl)
 {
     // Set the dialog window title.
     setWindowTitle(i18nc("The bookmarks dialog window title", "Bookmarks"));
@@ -301,7 +301,7 @@ void BookmarksDialog::selectSubfolderContents(const QModelIndex &parentModelInde
     }
 }
 
-void BookmarksDialog::showAddBookmarkDialog() const
+void BookmarksDialog::showAddBookmarkDialog()
 {
     // Return the most recently selected index.
     QModelIndex currentIndex = treeSelectionModelPointer->currentIndex();
@@ -322,7 +322,7 @@ void BookmarksDialog::showAddBookmarkDialog() const
     }
 
     // Instantiate an add bookmark dialog.
-    AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(websiteTitle, websiteUrl, websiteFavoriteIcon, parentFolderId);
+    AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(this, websiteTitle, websiteUrl, websiteFavoriteIcon, parentFolderId);
 
     // Update the displayed bookmarks when a new one is added.
     connect(addBookmarkDialogPointer, SIGNAL(bookmarkAdded()), this, SLOT(refreshBookmarks()));
@@ -331,7 +331,7 @@ void BookmarksDialog::showAddBookmarkDialog() const
     addBookmarkDialogPointer->show();
 }
 
-void BookmarksDialog::showAddFolderDialog() const
+void BookmarksDialog::showAddFolderDialog()
 {
     // Get the most recently selected index.
     QModelIndex currentIndex = treeSelectionModelPointer->currentIndex();
@@ -352,7 +352,7 @@ void BookmarksDialog::showAddFolderDialog() const
     }
 
     // Instantiate an add folder dialog.
-    AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(websiteFavoriteIcon, parentFolderId);
+    AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(this, websiteFavoriteIcon, parentFolderId);
 
     // Update the displayed bookmarks when a folder is added.
     connect(addFolderDialogPointer, SIGNAL(folderAdded()), this, SLOT(refreshBookmarks()));
@@ -370,7 +370,7 @@ void BookmarksDialog::showEditDialog()
     if (currentIndex.siblingAtColumn(IS_FOLDER_COLUMN).data().toInt() == 1)  // The selected item is a folder.
     {
         // Instantiate an edit folder dialog.
-        QDialog *editFolderDialogPointer = new EditFolderDialog(currentIndex.siblingAtColumn(DATABASE_ID_COLUMN).data().toInt(), websiteFavoriteIcon);
+        QDialog *editFolderDialogPointer = new EditFolderDialog(this, currentIndex.siblingAtColumn(DATABASE_ID_COLUMN).data().toInt(), websiteFavoriteIcon);
 
         // Show the dialog.
         editFolderDialogPointer->show();
@@ -381,7 +381,7 @@ void BookmarksDialog::showEditDialog()
     else  // The selected item is a bookmark.
     {
         // Instantiate an edit bookmark dialog.
-        QDialog *editBookmarkDialogPointer = new EditBookmarkDialog(currentIndex.siblingAtColumn(DATABASE_ID_COLUMN).data().toInt(), websiteFavoriteIcon);
+        QDialog *editBookmarkDialogPointer = new EditBookmarkDialog(this, currentIndex.siblingAtColumn(DATABASE_ID_COLUMN).data().toInt(), websiteFavoriteIcon);
 
         // Show the dialog.
         editBookmarkDialogPointer->show();
index 78a48963da485afde9e6fc259e5cdccd50753e53..0df090333a48033842db0375c42522bcd1566aa4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -36,7 +36,7 @@ class BookmarksDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit BookmarksDialog(QString currentWebsiteTitle, QString currentWebsiteUrl, QIcon currentWebsiteFavoriteIcon);
+    BookmarksDialog(QWidget *parentWidgetPointer, QIcon currentWebsiteFavorieIcon, QString currentWebsiteTitle, QString currentWebsiteUrl);
 
     // The public constants.
     static const int NAME_COLUMN = 0;
@@ -54,8 +54,8 @@ private Q_SLOTS:
     // The private slots.
     void deleteItems() const;
     void refreshBookmarks() const;
-    void showAddBookmarkDialog() const;
-    void showAddFolderDialog() const;
+    void showAddBookmarkDialog();
+    void showAddFolderDialog();
     void showEditDialog();
     void updateBookmarkFromTree(QStandardItem *modifiedStandardItem);
     void updateSelection() const;
index 4b72f5c6c382a72138abd69c839f099720b202b0..32ac52343234e9c25b3218b75ce29669cc37a31e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+# Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
 #
 # This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
 #
@@ -28,4 +28,5 @@ target_sources(privacybrowser PRIVATE
     EditBookmarkDialog.cpp
     EditFolderDialog.cpp
     SaveDialog.cpp
+    SettingsDialog.cpp
 )
index 4ca8c1c63a937c027923fafafec90e1d89b63e98..57e5ed718c770e28b8a86c18fb760945df5cd5f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -594,10 +594,10 @@ void CookiesDialog::deleteCookieFromDialog(const QNetworkCookie &cookie) const
     emit deleteCookie(cookie);
 }
 
-void CookiesDialog::showAddCookieDialog() const
+void CookiesDialog::showAddCookieDialog()
 {
     // Instantiate an add cookie dialog.
-    QDialog *addCookieDialogPointer = new AddOrEditCookieDialog(AddOrEditCookieDialog::AddCookie);
+    QDialog *addCookieDialogPointer = new AddOrEditCookieDialog(this, AddOrEditCookieDialog::AddCookie);
 
     // Show the dialog.
     addCookieDialogPointer->show();
@@ -744,10 +744,10 @@ void CookiesDialog::showDeleteCookieMessageBox() const
     }
 }
 
-void CookiesDialog::showDurableCookiesDialog() const
+void CookiesDialog::showDurableCookiesDialog()
 {
     // Instantiate a durable cookies dialog.
-    QDialog *durableCookiesDialogPointer = new DurableCookiesDialog();
+    QDialog *durableCookiesDialogPointer = new DurableCookiesDialog(this);
 
     // Show the dialog.
     durableCookiesDialogPointer->show();
@@ -758,7 +758,7 @@ void CookiesDialog::showDurableCookiesDialog() const
     connect(durableCookiesDialogPointer, SIGNAL(updateParentUi()), this, SLOT(updateUi()));
 }
 
-void CookiesDialog::showEditCookieDialog() const
+void CookiesDialog::showEditCookieDialog()
 {
     // Get the current model index.
     QModelIndex currentIndex = treeSelectionModelPointer->currentIndex();
@@ -783,7 +783,7 @@ void CookiesDialog::showEditCookieDialog() const
     }
 
     // Instantiate an edit cookie dialog.
-    QDialog *editCookieDialogPointer = new AddOrEditCookieDialog(AddOrEditCookieDialog::EditCookie, &cookieToEdit, currentIndex.siblingAtColumn(1).data().toString() == i18n("yes"));
+    QDialog *editCookieDialogPointer = new AddOrEditCookieDialog(this, AddOrEditCookieDialog::EditCookie, &cookieToEdit, currentIndex.siblingAtColumn(1).data().toString() == i18n("yes"));
 
     // Show the dialog.
     editCookieDialogPointer->show();
index be4acda067f80a9706e1a4364bb1f2f037e3bb57..5319897e68bd5a2cb77c91d52873941961347347 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -50,11 +50,11 @@ private Q_SLOTS:
     void addCookieFromDialog(const QNetworkCookie &cookie, const bool &isDurable) const;
     void deleteCookieFromDatabase(const QNetworkCookie &cookie) const;
     void deleteCookieFromDialog(const QNetworkCookie &cookie) const;
-    void showAddCookieDialog() const;
+    void showAddCookieDialog();
     void showDeleteAllMessageBox() const;
     void showDeleteCookieMessageBox() const;
-    void showDurableCookiesDialog() const;
-    void showEditCookieDialog() const;
+    void showDurableCookiesDialog();
+    void showEditCookieDialog();
     void updateUi() const;
 
 private:
index 13791f0be162b28f2517a7d9e16f7aa0667efc91..0907a18c184550cc73a59722f015456bc6d04fef 100644 (file)
@@ -34,7 +34,7 @@ const int DomainSettingsDialog::SHOW_ALL_DOMAINS = 0;
 const int DomainSettingsDialog::EDIT_DOMAIN = 1;
 
 // Construct the class.
-DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr)
+DomainSettingsDialog::DomainSettingsDialog(QWidget *parentWidgetPointer, const int &startType, const QString &domainName) : QDialog(parentWidgetPointer)
 {
     // Set the window title.
     setWindowTitle(i18nc("The domain settings dialog window title", "Domain Settings"));
index 153701663f4f61f0e4a52fd9fb30d300d620efdd..a78d6e3d3fd8468cecbeb43cd1d3d6c05d203c0f 100644 (file)
@@ -39,7 +39,7 @@ class DomainSettingsDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit DomainSettingsDialog(const int &startType = SHOW_ALL_DOMAINS, const QString &domainName = QStringLiteral(""));
+    explicit DomainSettingsDialog(QWidget *parentWidgetPointer, const int &startType = SHOW_ALL_DOMAINS, const QString &domainName = QStringLiteral(""));
 
     // The public static int constants.
     static const int SHOW_ALL_DOMAINS;
index abc21e98e4573dc10a5ed0ab1add3e34f2e20c6d..f07698597e62c61f70189ae830d0ed0549dedae7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -26,7 +26,7 @@
 // KDE Frameworks headers.
 #include <KLocalizedString>
 
-DurableCookiesDialog::DurableCookiesDialog() : QDialog(nullptr)
+DurableCookiesDialog::DurableCookiesDialog(QWidget *parentWidgetPointer) : QDialog(parentWidgetPointer)
 {
     // Set the dialog window title.
     setWindowTitle(i18nc("The durable cookies dialog window title", "Durable Cookies"));
index e611d58fa44a58e3b5030baa143e58f939817c82..64294f820a0defcf0081b36092f936a6c090e899 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright Â© 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -33,7 +33,7 @@ class DurableCookiesDialog : public QDialog
 
 public:
     // The default constructor.
-    explicit DurableCookiesDialog();
+    explicit DurableCookiesDialog(QWidget *parentWidgetPointer);
 
 signals:
     // The signals.
index a0c0c773dbbcf5d1e9e727b33f6d9d00b7162122..bad010e8aaa7ee8f2c90d49dcf3029ed9cd800b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -26,7 +26,7 @@
 #include <QFileDialog>
 
 // Construct the class.
-EditBookmarkDialog::EditBookmarkDialog(const int databaseId, QIcon &currentWebsiteFavoriteIcon) : QDialog(nullptr), bookmarkDatabaseId(databaseId)
+EditBookmarkDialog::EditBookmarkDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon &currentWebsiteFavoriteIcon) : QDialog(parentWidgetPointer), bookmarkDatabaseId(databaseId)
 {
     // Set the window title.
     setWindowTitle(i18nc("The edit bookmark dialog window title.", "Edit Bookmark"));
index bbba43e3cbd33ea1ba09e9070939bbfa27afb0e1..f862bc0ce23a854d5ba35452d82c29b39caa23c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -36,7 +36,7 @@ class EditBookmarkDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit EditBookmarkDialog(const int databaseId, QIcon &currentWebsiteFavoriteIcon);
+    explicit EditBookmarkDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon &currentWebsiteFavoriteIcon);
 
 signals:
     // The signals.
index 428544404a49dbb35ef1df1eb1e8b94f409b0dc6..950e502a7790db72eba97e633dd0e2d09b9bb2cf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -26,7 +26,7 @@
 #include <QFileDialog>
 
 // Construct the class.
-EditFolderDialog::EditFolderDialog(const int databaseId, QIcon &currentWebsiteFavoriteIcon) : QDialog(nullptr), folderDatabaseId(databaseId)
+EditFolderDialog::EditFolderDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon &currentWebsiteFavoriteIcon) : QDialog(parentWidgetPointer), folderDatabaseId(databaseId)
 {
     // Set the window title.
     setWindowTitle(i18nc("The edit folder dialog window title.", "Edit Folder"));
index ac203d8c07cb81242a8e1064bffd99c1894fbd04..8f3832417fe8a77c490aa4a48bb08e29d8f612a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -35,7 +35,7 @@ class EditFolderDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit EditFolderDialog(const int databaseId, QIcon &currentWebsiteFavoriteIcon);
+    explicit EditFolderDialog(QWidget *parentWidgetPointer, const int databaseId, QIcon &currentWebsiteFavoriteIcon);
 
 signals:
     // The signals.
index 5e969164e508e2b13f0c7fbfedb5ae169ddb2510..dac011c86fe25d2a07dbb7dc2e015cb69b634202 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -30,7 +30,8 @@
 #include <QShortcut>
 #include <QStandardPaths>
 
-SaveDialog::SaveDialog(QUrl &url, QString &mimeTypeString, int totalBytes, QString fileName, bool nativeDownloader): downloadUrl(url), suggestedFileName(fileName)
+SaveDialog::SaveDialog(QWidget *parentWidgetPointer, QUrl &url, QString &mimeTypeString, int totalBytes, QString fileName, bool nativeDownloader) :
+                       QDialog(parentWidgetPointer), downloadUrl(url), suggestedFileName(fileName)
 {
     // Set the dialog window title.
     setWindowTitle(i18nc("The save dialog window title", "Save"));
@@ -118,4 +119,3 @@ void SaveDialog::showFilePicker()
     // Close the dialog.
     reject();
 }
-
index a3ce8416b18b27835b5d5cc2e35b6caa8d869e34..a994d18e69d62ac0a75622ece363660e32b7c98f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022, 2024 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -32,7 +32,7 @@ class SaveDialog : public QDialog
 
 public:
     // The primary constructor.
-    explicit SaveDialog(QUrl &url, QString &mimeTypeString, int totalBytes, QString fileName = QString(), bool nativeDownloader = false);
+    explicit SaveDialog(QWidget *parentWidgetPointer, QUrl &url, QString &mimeTypeString, int totalBytes, QString fileName = QString(), bool nativeDownloader = false);
 
 signals:
     // The signals.
diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp
new file mode 100644 (file)
index 0000000..1f3fb79
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ *
+ * Privacy Browser PC is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Application headers.
+#include "Settings.h"
+#include "SettingsDialog.h"
+#include "helpers/SearchEngineHelper.h"
+#include "helpers/UserAgentHelper.h"
+#include "ui_SettingsGeneral.h"
+#include "ui_SettingsPrivacy.h"
+#include "ui_SettingsSpellCheck.h"
+
+// Qt toolkit headers.
+#include <QDir>
+#include <QFileDialog>
+
+SettingsDialog::SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton *coreConfigSkeletonPointer) :
+                               KConfigDialog(parentWidgetPointer, QLatin1String("settings"), coreConfigSkeletonPointer)
+{
+    // Instantiate the settings UI.
+    Ui::PrivacySettings privacySettingsUi;
+    Ui::GeneralSettings generalSettingsUi;
+    Ui::SpellCheckSettings spellCheckSettingsUi;
+
+    // Create the settings widgets.
+    QWidget *privacySettingsWidgetPointer = new QWidget;
+    QWidget *generalSettingsWidgetPointer = new QWidget;
+    QWidget *spellCheckSettingsWidgetPointer = new QWidget;
+
+    // Setup the UI to display the settings widgets.
+    privacySettingsUi.setupUi(privacySettingsWidgetPointer);
+    generalSettingsUi.setupUi(generalSettingsWidgetPointer);
+    spellCheckSettingsUi.setupUi(spellCheckSettingsWidgetPointer);
+
+    // Get handles for the widgets.
+    QCheckBox *javaScriptCheckBoxPointer = privacySettingsUi.kcfg_javaScriptEnabled;
+    QCheckBox *localStorageCheckBoxPointer = privacySettingsUi.kcfg_localStorageEnabled;
+    QCheckBox *domStorageCheckBoxPointer = privacySettingsUi.kcfg_domStorageEnabled;
+    QComboBox *userAgentComboBoxPointer = privacySettingsUi.kcfg_userAgent;
+    userAgentLabelPointer = privacySettingsUi.userAgentLabel;
+    QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine;
+    searchEngineLabelPointer = generalSettingsUi.searchEngineLabel;
+    downloadDirectoryComboBoxPointer = generalSettingsUi.kcfg_downloadDirectory;
+    QPushButton *browseButtonPointer = generalSettingsUi.browseButton;
+    QListWidget *spellCheckListWidgetPointer = spellCheckSettingsUi.spellCheckListWidget;
+
+    // Create a save spell check languages lambda.
+    auto updateCheckBoxes = [javaScriptCheckBoxPointer, localStorageCheckBoxPointer, domStorageCheckBoxPointer] ()
+    {
+        // Only enable the DOM storage check box if both JavaScript and local storage are checked.
+        domStorageCheckBoxPointer->setEnabled(javaScriptCheckBoxPointer->isChecked() && localStorageCheckBoxPointer->isChecked());
+    };
+
+    // Update the status of the DOM storage check box when either JavaScript or local storage are changed.
+    connect(javaScriptCheckBoxPointer, &QCheckBox::stateChanged, this, updateCheckBoxes);
+    connect(localStorageCheckBoxPointer, &QCheckBox::stateChanged, this, updateCheckBoxes);
+
+    // Populate the combo box labels.
+    updateUserAgentLabel(userAgentComboBoxPointer->currentText());
+    updateSearchEngineLabel(searchEngineComboBoxPointer->currentText());
+
+    // Update the labels when the combo boxes change.
+    connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateUserAgentLabel(const QString)));
+    connect(searchEngineComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateSearchEngineLabel(const QString)));
+
+    // Connect the download directory directory browse button.
+    connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(showDownloadDirectoryBrowseDialog()));
+
+    // Create a dictionaries QDir from the `QTWEBENGINE_DICTIONARIES_PATH` environment variable.
+    QDir dictionariesDir = QDir(qEnvironmentVariable("QTWEBENGINE_DICTIONARIES_PATH"));
+
+    // Get a dictionaries string list.
+    QStringList dictionariesStringList = dictionariesDir.entryList(QStringList(QLatin1String("*.bdic")), QDir::Files | QDir::NoSymLinks);
+
+    // Remove the `.bdic` file extensions from the dictionaries list.
+    dictionariesStringList.replaceInStrings(QLatin1String(".bdic"), QLatin1String(""));
+
+    // Get a list of the enabled spell check languages.
+    QStringList enabledSpellCheckLanguagesList = Settings::spellCheckLanguages();
+
+    // Add each dictionary to the spell check list widget.
+    foreach(QString dictionaryString, dictionariesStringList)
+    {
+        // Create a new list widget item pointer.
+        QListWidgetItem *listWidgetItemPointer = new QListWidgetItem();
+
+        // Create a dictionary check box widget with the name of the dictionary string.
+        QCheckBox *dictionaryCheckBoxWidget = new QCheckBox(dictionaryString);
+
+        // Check the language if it is currently enabled.
+        if (enabledSpellCheckLanguagesList.contains(dictionaryString))
+            dictionaryCheckBoxWidget->setCheckState(Qt::Checked);
+        else
+            dictionaryCheckBoxWidget->setCheckState(Qt::Unchecked);
+
+        // Add the list widget item to the spell check list widget.
+        spellCheckListWidgetPointer->addItem(listWidgetItemPointer);
+
+        // Set the list widget item check box widget.
+        spellCheckListWidgetPointer->setItemWidget(listWidgetItemPointer, dictionaryCheckBoxWidget);
+    }
+
+    // Create a settings icon string.
+    QString settingsIconString;
+
+    // Get a settings icon that matches the theme.
+    if (QIcon::hasThemeIcon("breeze-settings"))
+    {
+        // KDE uses breeze-settings.
+        settingsIconString = QLatin1String("breeze-settings");
+    }
+    else
+    {
+        // Gnome uses preferences-desktop.
+        settingsIconString = QLatin1String("preferences-desktop");
+    }
+
+    // Add the settings widgets as config dialog pages.
+    addPage(privacySettingsWidgetPointer, i18nc("Settings tab title", "Privacy"), QLatin1String("privacybrowser"));
+    addPage(generalSettingsWidgetPointer, i18nc("Settings tab title", "General"), settingsIconString);
+    addPage(spellCheckSettingsWidgetPointer, i18nc("Settings tab title", "Spell Check"), QLatin1String("tools-check-spelling"));
+
+    // Get handles for the buttons.
+    QPushButton *applyButtonPointer = button(QDialogButtonBox::Apply);
+    QPushButton *okButtonPointer = button(QDialogButtonBox::Ok);
+
+    // Prevent interaction with the parent window while the dialog is open.
+    setWindowModality(Qt::WindowModal);
+
+    // Create a save spell check languages lambda.
+    auto saveSpellCheckLanguages = [spellCheckListWidgetPointer, coreConfigSkeletonPointer, this] ()
+    {
+        // Create a list of enabled languages.
+        QStringList newSpellCheckLanguages = QStringList();
+
+        // Get a count of all the languages.
+        int allLanguagesCount = spellCheckListWidgetPointer->count();
+
+        // Get a list of all the checked languages.
+        for (int i = 0; i < allLanguagesCount; ++i) {
+            // Get the language item.
+            QListWidgetItem *languageItemPointer = spellCheckListWidgetPointer->item(i);
+
+            // Get the language check box.
+            QCheckBox *languageCheckBoxPointer = qobject_cast<QCheckBox*>(spellCheckListWidgetPointer->itemWidget(languageItemPointer));
+
+            // Add the item to the enabled languages if it is checked.
+            if (languageCheckBoxPointer->checkState() == Qt::Checked)
+            {
+                // Get the text.
+                QString languageString = languageCheckBoxPointer->text();
+
+                // Remove all instances of `&`, which may have been added automatically when creating the check box text.
+                languageString.remove(QChar('&'));
+
+                // Add the language string to the list.
+                newSpellCheckLanguages.append(languageString);
+            }
+        }
+
+        // Update the spell check languages.
+        if (Settings::spellCheckLanguages() != newSpellCheckLanguages)
+        {
+            // Update the spell check languages.
+            Settings::setSpellCheckLanguages(newSpellCheckLanguages);
+
+            // Write the settings to disk.
+            coreConfigSkeletonPointer->save();
+
+            // Emit the spell check languages updated signal.
+            emit spellCheckLanguagesUpdated();
+        }
+    };
+
+    // Process clicks on the buttons.
+    connect(applyButtonPointer, &QPushButton::clicked, this, saveSpellCheckLanguages);
+    connect(okButtonPointer, &QPushButton::clicked, this, saveSpellCheckLanguages);
+}
+
+void SettingsDialog::showDownloadDirectoryBrowseDialog()
+{
+    // Get the current download directory.
+    QString currentDownloadDirectory = downloadDirectoryComboBoxPointer->currentText();
+
+    // Resolve the system download directory if specified.
+    if (currentDownloadDirectory == QStringLiteral("System Download Directory"))
+        currentDownloadDirectory = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
+
+    // Get the new download directory.
+    QString newDownloadDirectory = QFileDialog::getExistingDirectory(this, i18nc("Select download directory dialog caption", "Select Download Directory"), currentDownloadDirectory);
+
+    // Populate the download directory combo box according to the new download location.
+    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");
+    }
+    else if (newDownloadDirectory != QStringLiteral(""))  // A different directory was selected.
+    {
+        // Populate the download location.
+        downloadDirectoryComboBoxPointer->setCurrentText(newDownloadDirectory);
+    }
+}
+
+void SettingsDialog::updateSearchEngineLabel(const QString &searchEngineString) const
+{
+    // Update the search engine label.
+    searchEngineLabelPointer->setText(SearchEngineHelper::getSearchUrl(searchEngineString));
+}
+
+void SettingsDialog::updateUserAgentLabel(const QString &userAgentDatabaseName) const
+{
+    // Update the user agent label.
+    userAgentLabelPointer->setText(UserAgentHelper::getUserAgentFromDatabaseName(userAgentDatabaseName));
+}
diff --git a/src/dialogs/SettingsDialog.h b/src/dialogs/SettingsDialog.h
new file mode 100644 (file)
index 0000000..bf56e18
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2024 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ *
+ * Privacy Browser PC is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+// KDE Framework headers.
+#include <KConfigDialog>
+
+// Qt toolkit headers.
+#include <QComboBox>
+#include <QLabel>
+
+class SettingsDialog : public KConfigDialog
+{
+    // Include the Q_OBJECT macro.
+    Q_OBJECT
+
+public:
+    // The primary constructor.
+    explicit SettingsDialog(QWidget *parentWidgetPointer, KCoreConfigSkeleton *coreConfigSkeletonPointer);
+
+signals:
+    void spellCheckLanguagesUpdated() const;
+
+private Q_SLOTS:
+    void showDownloadDirectoryBrowseDialog();
+    void updateSearchEngineLabel(const QString &searchEngineString) const;
+    void updateUserAgentLabel(const QString &userAgentDatabaseName) const;
+
+private:
+    // The private variables.
+    QComboBox *downloadDirectoryComboBoxPointer;
+    QLabel *searchEngineLabelPointer;
+    QLabel *userAgentLabelPointer;
+};
+#endif
index 58ccfc65281af538a445d44411e174973dc44113..bdc541c6bbb187877ff137aac6d2d477c171711a 100644 (file)
@@ -967,7 +967,7 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin
         if (!isRunningKde || currentPrivacyWebEngineViewPointer->localStorageEnabled)  // KDE is not running or local storage (cookies) is enabled.  Use WebEngine's downloader.
         {
             // Instantiate the save dialog.
-            SaveDialog *saveDialogPointer = new SaveDialog(downloadUrl, mimeTypeString, totalBytes);
+            SaveDialog *saveDialogPointer = new SaveDialog(this, downloadUrl, mimeTypeString, totalBytes);
 
             // Display the save dialog.
             int saveDialogResult = saveDialogPointer->exec();
@@ -1110,7 +1110,7 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin
             // This must use the show command to launch a separate dialog which cancels WebEngine's automatic background download of the file to a temporary location.
         {
             // Instantiate the save dialog.  `true` instructs it to use the native downloader
-            SaveDialog *saveDialogPointer = new SaveDialog(downloadUrl, mimeTypeString, totalBytes, suggestedFileName, true);
+            SaveDialog *saveDialogPointer = new SaveDialog(this, downloadUrl, mimeTypeString, totalBytes, suggestedFileName, true);
 
             // Connect the save button.
             connect(saveDialogPointer, SIGNAL(useNativeKdeDownloader(QUrl &, QString &)), this, SLOT(useNativeKdeDownloader(QUrl &, QString &)));
index 7dbb581f401a27f09ce2f665ec54d83fce81a6e9..4b06c640f5f1080e795b5567ba8ff58446e04985 100644 (file)
@@ -52,7 +52,6 @@ public:
 
     // The public functions.
     void applyOnTheFlyZoomFactor(const double zoomFactorDouble) const;
-    void applySpellCheckLanguages() const;
     PrivacyWebEngineView* loadBlankInitialWebsite();
     void loadInitialWebsite();
     void findPrevious(const QString &text) const;
@@ -106,6 +105,7 @@ public Q_SLOTS:
     void applyDomainSettingsAndReload();
     void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
     void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
+    void applySpellCheckLanguages() const;
     void back() const;
     void deleteAllCookies() const;
     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
index 7533432ec50d8a8cabc7268142e63240044f9394..88f9894aeebb71ca1f43c5ae14c55d9878f8e1f0 100644 (file)
@@ -20,9 +20,6 @@
 // Application headers.
 #include "BrowserWindow.h"
 #include "Settings.h"
-#include "ui_SettingsGeneral.h"
-#include "ui_SettingsPrivacy.h"
-#include "ui_SettingsSpellCheck.h"
 #include "databases/BookmarksDatabase.h"
 #include "databases/DomainsDatabase.h"
 #include "dialogs/AddBookmarkDialog.h"
@@ -32,6 +29,7 @@
 #include "dialogs/DomainSettingsDialog.h"
 #include "dialogs/EditBookmarkDialog.h"
 #include "dialogs/EditFolderDialog.h"
+#include "dialogs/SettingsDialog.h"
 #include "helpers/SearchEngineHelper.h"
 #include "helpers/UserAgentHelper.h"
 #include "structs/BookmarkStruct.h"
@@ -39,6 +37,7 @@
 // KDE Frameworks headers.
 #include <KActionCollection>
 #include <KColorScheme>
+#include <KLocalizedString>
 #include <KXMLGUIFactory>
 
 // Qt toolkit headers.
@@ -47,8 +46,9 @@
 #include <QDBusConnection>
 #include <QDBusConnectionInterface>
 #include <QDBusMessage>
-#include <QFileDialog>
+#include <QGuiApplication>
 #include <QInputDialog>
+#include <QLayout>
 #include <QNetworkCookie>
 #include <QMenuBar>
 #include <QMessageBox>
@@ -592,7 +592,7 @@ void BrowserWindow::addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double
     QAction *addBookmarkActionPointer = menuPointer->addAction(QIcon::fromTheme(QLatin1String("bookmark-new")), i18nc("The add bookmark action", "Add Bookmark"), [=]
         {
             // Instantiate an add bookmark dialog.
-            AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl(),
+            AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(this, tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl(),
                                                                                 tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
 
             // Update the displayed bookmarks when a new one is added.
@@ -607,7 +607,7 @@ void BrowserWindow::addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double
     QAction *addFolderActionPointer = menuPointer->addAction(QIcon::fromTheme(QLatin1String("folder-add")), i18nc("The add folder action", "Add Folder"), [=]
         {
             // Instantiate an add folder dialog.
-            AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
+            AddFolderDialog *addFolderDialogPointer = new AddFolderDialog(this, tabWidgetPointer->getCurrentTabFavoritIcon(), folderId);
 
             // Update the displayed bookmarks when a folder is added.
             connect(addFolderDialogPointer, SIGNAL(folderAdded()), this, SLOT(populateBookmarksInAllWindows()));
@@ -678,7 +678,7 @@ void BrowserWindow::addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double
                 QIcon currentTabFavoriteIcon = tabWidgetPointer->getCurrentTabFavoritIcon();
 
                 // Instantiate an edit folder dialog.
-                QDialog *editFolderDialogPointer = new EditFolderDialog(folderDatabaseId, currentTabFavoriteIcon);
+                QDialog *editFolderDialogPointer = new EditFolderDialog(this, folderDatabaseId, currentTabFavoriteIcon);
 
                 // Show the dialog.
                 editFolderDialogPointer->show();
@@ -769,7 +769,7 @@ void BrowserWindow::addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double
     finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, deleteFolderActionPointer));
 }
 
-void BrowserWindow::addOrEditDomainSettings() const
+void BrowserWindow::addOrEditDomainSettings()
 {
     // Remove the focus from the URL line edit.
     urlLineEditPointer->clearFocus();
@@ -813,7 +813,7 @@ void BrowserWindow::addOrEditDomainSettings() const
     }
 
     // Create the domain settings dialog pointer.
-    DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
+    DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog(this, DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
 
     // Reload the tabs when domain settings are updated.
     connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
@@ -864,10 +864,10 @@ void BrowserWindow::decrementZoom()
     updateZoomActions(currentZoomFactorDouble);
 }
 
-void BrowserWindow::editBookmarks() const
+void BrowserWindow::editBookmarks()
 {
     // Instantiate an edit bookmarks dialog.
-    BookmarksDialog *bookmarksDialogPointer = new BookmarksDialog(tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl(), tabWidgetPointer->getCurrentTabFavoritIcon());
+    BookmarksDialog *bookmarksDialogPointer = new BookmarksDialog(this, tabWidgetPointer->getCurrentTabFavoritIcon(), tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl());
 
     // Update the displayed bookmarks when edited.
     connect(bookmarksDialogPointer, SIGNAL(bookmarkUpdated()), this, SLOT(populateBookmarksInAllWindows()));
@@ -1397,7 +1397,7 @@ void BrowserWindow::showBookmarkContextMenu(const QPoint &point)
                     QIcon currentTabFavoriteIcon = tabWidgetPointer->getCurrentTabFavoritIcon();
 
                     // Instantiate an edit bookmark dialog.
-                    QDialog *editBookmarkDialogPointer = new EditBookmarkDialog(databaseId, currentTabFavoriteIcon);
+                    QDialog *editBookmarkDialogPointer = new EditBookmarkDialog(this, databaseId, currentTabFavoriteIcon);
 
                     // Show the dialog.
                     editBookmarkDialogPointer->show();
@@ -1481,39 +1481,13 @@ void BrowserWindow::showCookiesDialog()
     connect(cookiesDialogPointer, SIGNAL(deleteCookie(QNetworkCookie)), tabWidgetPointer, SLOT(deleteCookieFromStore(QNetworkCookie)));
 }
 
-void BrowserWindow::showDownloadDirectoryBrowseDialog() const
-{
-    // Get the current download directory.
-    QString currentDownloadDirectory = downloadDirectoryComboBoxPointer->currentText();
-
-    // Resolve the system download directory if specified.
-    if (currentDownloadDirectory == QStringLiteral("System Download Directory"))
-        currentDownloadDirectory = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
-
-    // Get the new download directory.
-    QString newDownloadDirectory = QFileDialog::getExistingDirectory(configDialogPointer, i18nc("Select download directory dialog caption", "Select Download Directory"),
-                                                                     currentDownloadDirectory);
-
-    // Populate the download directory combo box according to the new download location.
-    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");
-    }
-    else if (newDownloadDirectory != QStringLiteral(""))  // A different directory was selected.
-    {
-        // Populate the download location.
-        downloadDirectoryComboBoxPointer->setCurrentText(newDownloadDirectory);
-    }
-}
-
-void BrowserWindow::showDomainSettingsDialog() const
+void BrowserWindow::showDomainSettingsDialog()
 {
     // Remove the focus from the URL line edit.
     urlLineEditPointer->clearFocus();
 
     // Instantiate the domain settings dialog.
-    DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog();
+    DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog(this);
 
     // Reload the tabs when domain settings are updated.
     connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
@@ -1558,186 +1532,28 @@ void BrowserWindow::showProgressBar(const int &progress) const
 
 void BrowserWindow::showSettingsDialog()
 {
-    // Create the settings widgets.
-    QWidget *privacySettingsWidgetPointer = new QWidget;
-    QWidget *generalSettingsWidgetPointer = new QWidget;
-    QWidget *spellCheckSettingsWidgetPointer = new QWidget;
-
-    // Instantiate the settings UI.
-    Ui::PrivacySettings privacySettingsUi;
-    Ui::GeneralSettings generalSettingsUi;
-    Ui::SpellCheckSettings spellCheckSettingsUi;
-
-    // Setup the UI to display the settings widgets.
-    privacySettingsUi.setupUi(privacySettingsWidgetPointer);
-    generalSettingsUi.setupUi(generalSettingsWidgetPointer);
-    spellCheckSettingsUi.setupUi(spellCheckSettingsWidgetPointer);
-
-    // Get handles for the widgets.
-    QCheckBox *javaScriptCheckBoxPointer = privacySettingsUi.kcfg_javaScriptEnabled;
-    QCheckBox *localStorageCheckBoxPointer = privacySettingsUi.kcfg_localStorageEnabled;
-    QCheckBox *domStorageCheckBoxPointer = privacySettingsUi.kcfg_domStorageEnabled;
-    QComboBox *userAgentComboBoxPointer = privacySettingsUi.kcfg_userAgent;
-    userAgentLabelPointer = privacySettingsUi.userAgentLabel;
-    QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine;
-    searchEngineLabelPointer = generalSettingsUi.searchEngineLabel;
-    downloadDirectoryComboBoxPointer = generalSettingsUi.kcfg_downloadDirectory;
-    QPushButton *browseButtonPointer = generalSettingsUi.browseButton;
-    QListWidget *spellCheckListWidgetPointer = spellCheckSettingsUi.spellCheckListWidget;
-
-    // Create a save spell check languages lambda.
-    auto updateCheckBoxes = [javaScriptCheckBoxPointer, localStorageCheckBoxPointer, domStorageCheckBoxPointer] ()
-    {
-        // Only enable the DOM storage check box if both JavaScript and local storage are checked.
-        domStorageCheckBoxPointer->setEnabled(javaScriptCheckBoxPointer->isChecked() && localStorageCheckBoxPointer->isChecked());
-    };
-
-    // Update the status of the DOM storage check box when either JavaScript or local storage are changed.
-    connect(javaScriptCheckBoxPointer, &QCheckBox::stateChanged, this, updateCheckBoxes);
-    connect(localStorageCheckBoxPointer, &QCheckBox::stateChanged, this, updateCheckBoxes);
-
-    // Populate the combo box labels.
-    updateUserAgentLabel(userAgentComboBoxPointer->currentText());
-    updateSearchEngineLabel(searchEngineComboBoxPointer->currentText());
-
-    // Update the labels when the combo boxes change.
-    connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateUserAgentLabel(const QString)));
-    connect(searchEngineComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateSearchEngineLabel(const QString)));
-
-    // Connect the download directory directory browse button.
-    connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(showDownloadDirectoryBrowseDialog()));
-
-    // Create a dictionaries QDir from the `QTWEBENGINE_DICTIONARIES_PATH` environment variable.
-    QDir dictionariesDir = QDir(qEnvironmentVariable("QTWEBENGINE_DICTIONARIES_PATH"));
-
-    // Get a dictionaries string list.
-    QStringList dictionariesStringList = dictionariesDir.entryList(QStringList(QLatin1String("*.bdic")), QDir::Files | QDir::NoSymLinks);
-
-    // Remove the `.bdic` file extensions from the dictionaries list.
-    dictionariesStringList.replaceInStrings(QLatin1String(".bdic"), QLatin1String(""));
-
-    // Get a list of the enabled spell check languages.
-    QStringList enabledSpellCheckLanguagesList = Settings::spellCheckLanguages();
-
-    // Add each dictionary to the spell check list widget.
-    foreach(QString dictionaryString, dictionariesStringList)
-    {
-        // Create a new list widget item pointer.
-        QListWidgetItem *listWidgetItemPointer = new QListWidgetItem();
-
-        // Create a dictionary check box widget with the name of the dictionary string.
-        QCheckBox *dictionaryCheckBoxWidget = new QCheckBox(dictionaryString);
-
-        // Check the language if it is currently enabled.
-        if (enabledSpellCheckLanguagesList.contains(dictionaryString))
-            dictionaryCheckBoxWidget->setCheckState(Qt::Checked);
-        else
-            dictionaryCheckBoxWidget->setCheckState(Qt::Unchecked);
-
-        // Add the list widget item to the spell check list widget.
-        spellCheckListWidgetPointer->addItem(listWidgetItemPointer);
-
-        // Set the list widget item check box widget.
-        spellCheckListWidgetPointer->setItemWidget(listWidgetItemPointer, dictionaryCheckBoxWidget);
-    }
-
     // Get a handle for the KConfig skeleton.
     KConfigSkeleton *kConfigSkeletonPointer = Settings::self();
 
-    // Instantiate a settings config dialog from the settings.kcfg file.
-    configDialogPointer = new KConfigDialog(this, QLatin1String("settings"), kConfigSkeletonPointer);
+    // Instantiate a settings dialog.
+    SettingsDialog *settingsDialogPointer = new SettingsDialog(this, kConfigSkeletonPointer);
 
-    // Create a settings icon string.
-    QString settingsIconString;
-
-    // Get a settings icon that matches the theme.
-    if (QIcon::hasThemeIcon("breeze-settings"))
-    {
-        // KDE uses breeze-settings.
-        settingsIconString = QLatin1String("breeze-settings");
-    }
-    else
-    {
-        // Gnome uses preferences-desktop.
-        settingsIconString = QLatin1String("preferences-desktop");
-    }
-
-    // Add the settings widgets as config dialog pages.
-    configDialogPointer->addPage(privacySettingsWidgetPointer, i18nc("Settings tab title", "Privacy"), QLatin1String("privacybrowser"));
-    configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("Settings tab title", "General"), settingsIconString);
-    configDialogPointer->addPage(spellCheckSettingsWidgetPointer, i18nc("Settings tab title", "Spell Check"), QLatin1String("tools-check-spelling"));
-
-    // Get handles for the buttons.
-    QPushButton *applyButtonPointer = configDialogPointer->button(QDialogButtonBox::Apply);
-    QPushButton *okButtonPointer = configDialogPointer->button(QDialogButtonBox::Ok);
-
-    // Prevent interaction with the parent window while the dialog is open.
-    configDialogPointer->setWindowModality(Qt::WindowModal);
-
-    // Make it so.
-    configDialogPointer->show();
+    // Show the dialog
+    settingsDialogPointer->show();
 
     // TODO.  KConfigDialog does not respect expanding size policies.  <https://redmine.stoutner.com/issues/823>
-    //configDialogPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    //settingsDialogPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     //privacySettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     //generalSettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-    //configDialogPointer->adjustSize();
+    //settingsDialogPointer->adjustSize();
 
     // Expand the config dialog.
-    configDialogPointer->resize(1000, 500);
-
-    // Create a save spell check languages lambda.
-    auto saveSpellCheckLanguages = [spellCheckListWidgetPointer, kConfigSkeletonPointer, this] ()
-    {
-        // Create a list of enabled languages.
-        QStringList newSpellCheckLanguages = QStringList();
-
-        // Get a count of all the languages.
-        int allLanguagesCount = spellCheckListWidgetPointer->count();
-
-        // Get a list of all the checked languages.
-        for (int i = 0; i < allLanguagesCount; ++i) {
-            // Get the language item.
-            QListWidgetItem *languageItemPointer = spellCheckListWidgetPointer->item(i);
-
-            // Get the language check box.
-            QCheckBox *languageCheckBoxPointer = qobject_cast<QCheckBox*>(spellCheckListWidgetPointer->itemWidget(languageItemPointer));
-
-            // Add the item to the enabled languages if it is checked.
-            if (languageCheckBoxPointer->checkState() == Qt::Checked)
-            {
-                // Get the text.
-                QString languageString = languageCheckBoxPointer->text();
-
-                // Remove all instances of `&`, which may have been added automatically when creating the check box text.
-                languageString.remove(QChar('&'));
-
-                // Add the language string to the list.
-                newSpellCheckLanguages.append(languageString);
-            }
-        }
-
-        // Update the spell check languages.
-        if (Settings::spellCheckLanguages() != newSpellCheckLanguages)
-        {
-            // Update the spell check languages.
-            Settings::setSpellCheckLanguages(newSpellCheckLanguages);
-
-            // Write the settings to disk.
-            kConfigSkeletonPointer->save();
-        }
-
-        // Apply the spell check languages.
-        tabWidgetPointer->applySpellCheckLanguages();
-    };
-
-    // Process
-    connect(applyButtonPointer, &QPushButton::clicked, this, saveSpellCheckLanguages);
-    connect(okButtonPointer, &QPushButton::clicked, this, saveSpellCheckLanguages);
+    settingsDialogPointer->resize(1000, 500);
 
     // Apply the settings handled by KConfig.
-    connect(configDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyApplicationSettings()));
-    connect(configDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
+    connect(settingsDialogPointer, SIGNAL(spellCheckLanguagesUpdated()), tabWidgetPointer, SLOT(applySpellCheckLanguages()));
+    connect(settingsDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyApplicationSettings()));
+    connect(settingsDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
 }
 
 QSize BrowserWindow::sizeHint() const
@@ -2081,12 +1897,6 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const
     }
 }
 
-void BrowserWindow::updateSearchEngineLabel(const QString &searchEngineString) const
-{
-    // Update the search engine label.
-    searchEngineLabelPointer->setText(SearchEngineHelper::getSearchUrl(searchEngineString));
-}
-
 void BrowserWindow::updateUrlLineEdit(const QUrl &newUrl)
 {
     // Get the new URL string in encoded form, which displays punycode.
@@ -2265,12 +2075,6 @@ void BrowserWindow::updateUserAgentActions(const QString &userAgent, const bool
     }
 }
 
-void BrowserWindow::updateUserAgentLabel(const QString &userAgentDatabaseName) const
-{
-    // Update the user agent label.
-    userAgentLabelPointer->setText(UserAgentHelper::getUserAgentFromDatabaseName(userAgentDatabaseName));
-}
-
 void BrowserWindow::updateViewBookmarksToolBarCheckbox(const bool visible)
 {
     // Update the view bookmarks toolbar checkbox.
index eedc2502c693e0aea3179a82b8bc185e6f36b4ce..74e31b88dc6947359f7c695fb7fa16ff9f918329 100644 (file)
@@ -55,11 +55,11 @@ public Q_SLOTS:
 
 private Q_SLOTS:
     // The private slots.
-    void addOrEditDomainSettings() const;
+    void addOrEditDomainSettings();
     void back() const;
     void clearUrlLineEditFocus() const;
     void decrementZoom();
-    void editBookmarks() const;
+    void editBookmarks();
     void escape() const;
     void findNext() const;
     void findPrevious() const;
@@ -77,8 +77,7 @@ private Q_SLOTS:
     void reloadAndBypassCache() const;
     void showBookmarkContextMenu(const QPoint &point);
     void showCookiesDialog();
-    void showDownloadDirectoryBrowseDialog() const;
-    void showDomainSettingsDialog() const;
+    void showDomainSettingsDialog();
     void showFindTextActions() const;
     void showProgressBar(const int &progress) const;
     void showSettingsDialog();
@@ -103,9 +102,7 @@ private Q_SLOTS:
     void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus);
     void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus);
     void updateZoomActions(const double zoomFactorDouble);
-    void updateSearchEngineLabel(const QString &searchEngineString) const;
     void updateUrlLineEdit(const QUrl &newUrl);
-    void updateUserAgentLabel(const QString &userAgentDatabaseName) const;
     void updateViewBookmarksToolBarCheckbox(const bool visible);
     void updateWindowTitle(const QString &title);
     void zoomDefault();
@@ -123,7 +120,6 @@ private:
     QList<QPair<QMenu *, QAction *> *> bookmarksToolBarSubfolderActionList;
     bool bookmarksToolBarIsVisible = false;
     bool bookmarksToolBarUninitialized = true;
-    KConfigDialog *configDialogPointer;
     QAction *cookiesActionPointer;
     QUrl currentUrl;
     QPushButton *currentZoomButtonPointer;
@@ -133,7 +129,6 @@ private:
     double defaultZoomFactorDouble;
     QAction *developerToolsActionPointer;
     QAction *domStorageActionPointer;
-    QComboBox *downloadDirectoryComboBoxPointer;
     QList<QPair<QMenu *, QAction *> *> finalBookmarkFolderMenuActionList;
     QAction *findCaseSensitiveActionPointer;
     QAction *findNextActionPointer;
@@ -154,7 +149,6 @@ private:
     QPalette positiveBackgroundPalette;
     QProgressBar *progressBarPointer;
     QAction *refreshActionPointer;
-    QLabel *searchEngineLabelPointer;
     QAction *searchEngineMenuActionPointer;
     QAction *searchEngineMojeekActionPointer;
     QAction *searchEngineMonoclesActionPointer;
@@ -164,7 +158,6 @@ private:
     QAction *searchEngineYahooActionPointer;
     QAction *searchEngineCustomActionPointer;
     QAction *stopActionPointer;
-    QLabel *userAgentLabelPointer;
     QAction *userAgentMenuActionPointer;
     QAction *userAgentPrivacyBrowserActionPointer;
     QAction *userAgentWebEngineDefaultActionPointer;