]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Partial bookmark implementation. https://redmine.stoutner.com/issues/968
authorSoren Stoutner <soren@stoutner.com>
Sun, 13 Aug 2023 02:46:20 +0000 (19:46 -0700)
committerSoren Stoutner <soren@stoutner.com>
Sun, 13 Aug 2023 02:49:32 +0000 (19:49 -0700)
25 files changed:
src/CMakeLists.txt
src/databases/BookmarksDatabase.cpp [new file with mode: 0644]
src/databases/BookmarksDatabase.h [new file with mode: 0644]
src/databases/CMakeLists.txt
src/databases/CookiesDatabase.cpp
src/dialogs/AddBookmarkDialog.cpp [new file with mode: 0644]
src/dialogs/AddBookmarkDialog.h [new file with mode: 0644]
src/dialogs/AddOrEditCookieDialog.cpp
src/dialogs/AddOrEditCookieDialog.h
src/dialogs/BookmarksDialog.cpp [new file with mode: 0644]
src/dialogs/BookmarksDialog.h [new file with mode: 0644]
src/dialogs/CMakeLists.txt
src/dialogs/CookiesDialog.cpp
src/dialogs/CookiesDialog.h
src/main.cpp
src/structs/BookmarkStruct.h [new file with mode: 0644]
src/ui.rcs/browserwindowui.rc
src/uis/AddBookmarkDialog.ui [new file with mode: 0644]
src/uis/AddOrEditCookieDialog.ui
src/uis/BookmarksDialog.ui [new file with mode: 0644]
src/uis/CookiesDialog.ui
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index af21d5aa483acdd6c524bc7e3f13c53644901dfc..f96399a0612a29de893a31325b1e593a30add3fb 100644 (file)
@@ -35,8 +35,10 @@ kconfig_add_kcfg_files(privacybrowser settings/Settings.kcfgc)
 
 # Use KDE Frameworks to handle internationalization of the following UI files.
 ki18n_wrap_ui(privacybrowser
+    uis/AddBookmarkDialog.ui
     uis/AddOrEditCookieDialog.ui
     uis/AddTabWidget.ui
+    uis/BookmarksDialog.ui
     uis/CookiesDialog.ui
     uis/DomainSettingsDialog.ui
     uis/DurableCookiesDialog.ui
diff --git a/src/databases/BookmarksDatabase.cpp b/src/databases/BookmarksDatabase.cpp
new file mode 100644 (file)
index 0000000..c290682
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2023 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 "BookmarksDatabase.h"
+
+// Define the private static schema constants.
+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";
+
+// Construct the class.
+BookmarksDatabase::BookmarksDatabase() {}
+
+void BookmarksDatabase::addDatabase()
+{
+    // Add the bookmarks database.
+    QSqlDatabase bookmarksDatabase = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), CONNECTION_NAME);
+
+    // Set the database name.
+    bookmarksDatabase.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/bookmarks.db");
+
+    // Open the database.
+    if (bookmarksDatabase.open())  // Opening the database succeeded.
+    {
+        // Check to see if the bookmarks table already exists.
+        if (bookmarksDatabase.tables().contains(BOOKMARKS_TABLE))  // The bookmarks table already exists.
+        {
+            // Query the database schema version.
+            QSqlQuery schemaVersionQuery = bookmarksDatabase.exec(QStringLiteral("PRAGMA user_version"));
+
+            // Move to the first record.
+            schemaVersionQuery.first();
+
+            // Get the current schema version.
+            int currentSchemaVersion = schemaVersionQuery.value(0).toInt();
+
+            // Check to see if the schema has been updated.
+            if (currentSchemaVersion < SCHEMA_VERSION)
+            {
+                // Run the schema update code.
+
+                // Update the schema version.
+                bookmarksDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+            }
+        }
+        else  // The bookmarks table does not exist.
+        {
+            // Instantiate a create table query.
+            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)");
+
+            // Execute the query.
+            if (!createTableQuery.exec())
+            {
+                // Log any errors.
+                qDebug().noquote().nospace() << "Error creating table:  " << bookmarksDatabase.lastError();
+            }
+
+            // Set the schema version.
+            bookmarksDatabase.exec("PRAGMA user_version = " + QString::number(SCHEMA_VERSION));
+        }
+    }
+    else  // Opening the database failed.
+    {
+        // Write the last database error message to the debug output.
+        qDebug().noquote().nospace() << "Error opening database:  " << bookmarksDatabase.lastError();
+    }
+};
+
+void BookmarksDatabase::addBookmark(const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon)
+{
+    // Get a handle for the bookmarks database.
+    QSqlDatabase bookmarksDatabase = QSqlDatabase::database(CONNECTION_NAME);
+
+    // Get a favorite icon pixmap.
+    QPixmap favoriteIconPixmap = favoriteIcon.pixmap(32, 32);
+
+    // Create a favorite icon byte array.
+    QByteArray favoriteIconByteArray;
+
+    // Create a favorite icon buffer.
+    QBuffer favoriteIconBuffer(&favoriteIconByteArray);
+
+    // Open the buffer.
+    favoriteIconBuffer.open(QIODevice::WriteOnly);
+
+    // Convert the favorite icon pixmap into a byte array in PNG format.
+    favoriteIconPixmap.save(&favoriteIconBuffer, "PNG");
+
+    // Close the buffer.
+    favoriteIconBuffer.close();
+
+    // Convert the favorite icon byte array to a base 64 string.
+    QString favoriteIconBase64String = favoriteIconByteArray.toBase64();
+
+    // Instantiate an add bookmark query.
+    QSqlQuery addBookmarkQuery(bookmarksDatabase);
+
+    // Prepare the add bookmark query.
+    addBookmarkQuery.prepare("INSERT INTO " + BOOKMARKS_TABLE + " (" +
+                              BOOKMARK_NAME + ", " +
+                              BOOKMARK_URL + ", " +
+                              FAVORITE_ICON + ") "
+                              "VALUES (:bookmark_name, :bookmark_url, :favorite_icon)"
+    );
+
+    // Bind the values.
+    addBookmarkQuery.bindValue(":bookmark_name", bookmarkName);
+    addBookmarkQuery.bindValue(":bookmark_url", bookmarkUrl);
+    addBookmarkQuery.bindValue(":favorite_icon", favoriteIconBase64String);
+
+    // Execute the query.
+    addBookmarkQuery.exec();
+}
+
+std::list<BookmarkStruct>* BookmarksDatabase::getBookmarks()
+{
+    // Get a handle for the bookmarks database.
+    QSqlDatabase bookmarksDatabase = QSqlDatabase::database(CONNECTION_NAME);
+
+    // Instantiate a bookmarks query.
+    QSqlQuery bookmarksQuery(bookmarksDatabase);
+
+    // Set the query to be forward only, which is more performant.
+    bookmarksQuery.setForwardOnly(true);
+
+    // Prepare the bookmarks query.
+    bookmarksQuery.prepare("SELECT * FROM " + BOOKMARKS_TABLE);
+
+    // Execute the query.
+    bookmarksQuery.exec();
+
+    // Create a bookmark list.
+    std::list<BookmarkStruct> *bookmarkListPointer = new std::list<BookmarkStruct>;
+
+    // Populate the bookmark list.
+    while (bookmarksQuery.next())
+    {
+        // Create a bookmark struct.
+        struct BookmarkStruct bookmarkStruct;
+
+        // Get the favorite icon base 64 bute array.
+        QByteArray favoriteIconByteArray = QByteArray::fromBase64(bookmarksQuery.value(FAVORITE_ICON).toByteArray());
+
+        // Create a favorite icon pixmap.
+        QPixmap favoriteIconPixmap;
+
+        // Load the pixmap from byte array.
+        favoriteIconPixmap.loadFromData(favoriteIconByteArray);
+
+        // Populate the bookmark struct.
+        bookmarkStruct.id = bookmarksQuery.value(ID).toInt();
+        bookmarkStruct.bookmarkName = bookmarksQuery.value(BOOKMARK_NAME).toString();
+        bookmarkStruct.bookmarkUrl = bookmarksQuery.value(BOOKMARK_URL).toString();
+        bookmarkStruct.favoriteIcon = QIcon(favoriteIconPixmap);
+
+        // Add the bookmark to the list.
+        bookmarkListPointer->push_back(bookmarkStruct);
+    }
+
+    // Return the bookmark list.
+    return bookmarkListPointer;
+}
+
+void BookmarksDatabase::updateBookmarkName(const int bookmarkId, const QString &bookmarkName)
+{
+    // Get a handle for the bookmarks database.
+    QSqlDatabase bookmarksDatabase = QSqlDatabase::database(CONNECTION_NAME);
+
+    // Instantiate an update bookmark name query.
+    QSqlQuery updateBookmarkNameQuery(bookmarksDatabase);
+
+    // Prepare the update bookmark name query.
+    updateBookmarkNameQuery.prepare("UPDATE " + BOOKMARKS_TABLE +
+                                    " SET " + BOOKMARK_NAME + " = :bookmark_name " +
+                                    "WHERE " + ID + " = :id");
+
+    // Bind the values.
+    updateBookmarkNameQuery.bindValue(":bookmark_name", bookmarkName);
+    updateBookmarkNameQuery.bindValue(":id", bookmarkId);
+
+    // Execute the query.
+    updateBookmarkNameQuery.exec();
+}
+
+void BookmarksDatabase::updateBookmarkUrl(const int bookmarkId, const QString &bookmarkUrl)
+{
+    // Get a handle for the bookmarks database.
+    QSqlDatabase bookmarksDatabase = QSqlDatabase::database(CONNECTION_NAME);
+
+    // Instantiate an update bookmark URL query.
+    QSqlQuery updateBookmarkUrlQuery(bookmarksDatabase);
+
+    // Prepare the update bookmark URL query.
+    updateBookmarkUrlQuery.prepare("UPDATE " + BOOKMARKS_TABLE +
+                                   " SET " + BOOKMARK_URL + " = :bookmark_url " +
+                                   "WHERE " + ID + " = :id");
+
+    // Bind the values.
+    updateBookmarkUrlQuery.bindValue(":bookmark_url", bookmarkUrl);
+    updateBookmarkUrlQuery.bindValue(":id", bookmarkId);
+
+    // Execute the query.
+    updateBookmarkUrlQuery.exec();
+}
diff --git a/src/databases/BookmarksDatabase.h b/src/databases/BookmarksDatabase.h
new file mode 100644 (file)
index 0000000..d0f743a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2023 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 BOOKMARKSDATABASE_H
+#define BOOKMARKSDATABASE_H
+
+// Application headers.
+#include "structs/BookmarkStruct.h"
+
+// Qt framework headers.
+#include <QtSql>
+
+class BookmarksDatabase
+{
+public:
+    // The default constructor.
+    BookmarksDatabase();
+
+    // The public functions.
+    static void addBookmark(const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon);
+    static void addDatabase();
+    static std::list<BookmarkStruct>* getBookmarks();
+    static void updateBookmarkName(const int bookmarkId, const QString &bookmarkName);
+    static void updateBookmarkUrl(const int bookmarkId, const QString &bookmarkUrl);
+
+    // The public constants.
+    static const QString CONNECTION_NAME;
+    static const QString BOOKMARK_NAME;
+    static const QString BOOKMARKS_TABLE;
+    static const QString BOOKMARK_URL;
+    static const QString DISPLAY_ORDER;
+    static const QString FAVORITE_ICON;
+    static const QString FOLDER_ID;
+    static const QString ID;
+    static const QString IS_FOLDER;
+    static const QString PARENT_FOLDER_ID;
+
+    private:
+    // The private static constants.
+    static const int SCHEMA_VERSION;
+};
+#endif
index e38dbd2a44e9a99528ffd71823ceb6de96366bb1..5f40f9938ce3aed79f8b3ac2ad4665f8e93db48c 100644 (file)
@@ -18,6 +18,7 @@
 
 # List the sources to include in the executable.
 target_sources(privacybrowser PRIVATE
+    BookmarksDatabase.cpp
     CookiesDatabase.cpp
     DomainsDatabase.cpp
 )
index dcb6f0b13cf95797b51c67f9a0e756736c42b707..e8a870b82d15b00a034e05ccf1e233efb3cc9097 100644 (file)
@@ -230,7 +230,7 @@ QList<QNetworkCookie*>* CookiesDatabase::getCookies()
     // Instantiate a cookies query.
     QSqlQuery cookiesQuery(cookiesDatabase);
 
-    // Set the query to be forward only.
+    // Set the query to be forward only, which is more performant.
     cookiesQuery.setForwardOnly(true);
 
     // Prepare the cookies query.
@@ -402,7 +402,7 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &cookie)
     // Create the update cookie query.
     QSqlQuery updateCookieQuery(cookiesDatabase);
 
-    // Prepare the edit cookie query.
+    // Prepare the update cookie query.
     updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
                               " SET " + EXPIRATION_DATE + " = :expiration_date , " +
                               HTTP_ONLY + " = :http_only , " +
diff --git a/src/dialogs/AddBookmarkDialog.cpp b/src/dialogs/AddBookmarkDialog.cpp
new file mode 100644 (file)
index 0000000..cc0d132
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2023 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 "AddBookmarkDialog.h"
+#include "ui_AddBookmarkDialog.h"
+#include "databases/BookmarksDatabase.h"
+
+// KDE Framework headers.
+#include <KLocalizedString>
+
+// Qt toolkit headers.
+#include <QPushButton>
+
+// Construct the class.
+AddBookmarkDialog::AddBookmarkDialog(const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon) : QDialog(nullptr), icon(favoriteIcon)
+{
+    // Set the window title.
+    setWindowTitle(i18nc("The add bookmark dialog window title.", "Add Bookmark"));
+
+    // Set the window modality.
+    setWindowModality(Qt::WindowModality::ApplicationModal);
+
+    // Instantiate the bookmarks dialog UI.
+    Ui::AddBookmarkDialog addBookmarkDialogUi;
+
+    // Setup the UI.
+    addBookmarkDialogUi.setupUi(this);
+
+    // Get handles for the widgets.
+    QGraphicsView *favoriteIconGraphicsViewPointer = addBookmarkDialogUi.favoriteIconGraphicsView;
+    bookmarkNamePointer = addBookmarkDialogUi.bookmarkNameLineEdit;
+    bookmarkUrlPointer = addBookmarkDialogUi.bookmarkUrlLineEdit;
+    QDialogButtonBox *dialogButtonBoxPointer = addBookmarkDialogUi.dialogButtonBox;
+
+    // Create a graphics scene.
+    QGraphicsScene *favoriteIconGraphicsScenePointer = new QGraphicsScene(this);
+
+    // Set the graphics scene.
+    favoriteIconGraphicsViewPointer->setScene(favoriteIconGraphicsScenePointer);
+
+    // Set the background of the graphics view to be the same as the window
+    favoriteIconGraphicsViewPointer->setBackgroundRole(QPalette::Window);
+
+    // Add the MIME type icon to the scene.
+    favoriteIconGraphicsScenePointer->addPixmap(favoriteIcon.pixmap(32, 32));
+
+    // Populate the line edits.
+    bookmarkNamePointer->setText(bookmarkName);
+    bookmarkUrlPointer->setText(bookmarkUrl);
+
+    // Scroll the the beginning of the line edits.
+    bookmarkNamePointer->setCursorPosition(0);
+    bookmarkUrlPointer->setCursorPosition(0);
+
+    // Add buttons to the dialog button box.
+    QPushButton *addBookmarkButtonPointer = dialogButtonBoxPointer->addButton(i18nc("The add bookmark button", "Add"), QDialogButtonBox::AcceptRole);
+
+    // Set the button icons.
+    addBookmarkButtonPointer->setIcon(QIcon::fromTheme("list-add"));
+
+    // Connect the buttons.
+    connect(dialogButtonBoxPointer, SIGNAL(accepted()), this, SLOT(addBookmark()));
+    connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+void AddBookmarkDialog::addBookmark()
+{
+    // Add the bookmark.
+    BookmarksDatabase::addBookmark(bookmarkNamePointer->text(), bookmarkUrlPointer->text(), icon);
+
+    // Close the dialog.
+    close();
+}
+
diff --git a/src/dialogs/AddBookmarkDialog.h b/src/dialogs/AddBookmarkDialog.h
new file mode 100644 (file)
index 0000000..2cee8b9
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2023 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 ADDBOOKMARKDIALOG_H
+#define ADDBOOKMARKDIALOG_H
+
+// Qt toolkit headers.
+#include <QDialog>
+#include <QIcon>
+#include <QLineEdit>
+
+class AddBookmarkDialog : public QDialog
+{
+    // Include the Q_OBJECT macro.
+    Q_OBJECT
+
+public:
+    // The primary constructor.
+    explicit AddBookmarkDialog(const QString &bookmarkName, const QString &bookmarkUrl, const QIcon &favoriteIcon);
+
+private Q_SLOTS:
+    // The private slots.
+    void addBookmark();
+
+private:
+    // The private widgets.
+    QLineEdit *bookmarkNamePointer;
+    QLineEdit *bookmarkUrlPointer;
+
+    // The private variables.
+    const QIcon icon;
+};
+#endif
index e39303e8e7094230d63cf6db49615fcb0686e8d5..eba44b8748b7fdc09d1cc577f04b8b75f4c20bcf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright Â© 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -49,7 +49,7 @@ AddOrEditCookieDialog::AddOrEditCookieDialog(const int &dialogType, const QNetwo
     // Set the window modality.
     setWindowModality(Qt::WindowModality::ApplicationModal);
 
-    // Instantiate the cookie settings dialog UI.
+    // Instantiate the cookie dialog UI.
     Ui::AddOrEditCookieDialog addOrEditCookieDialogUi;
 
     // Setup the UI.
@@ -83,6 +83,12 @@ AddOrEditCookieDialog::AddOrEditCookieDialog(const int &dialogType, const QNetwo
         secureCheckBoxPointer->setChecked(originalCookie.isSecure());
         valueLineEditPointer->setText(originalCookie.value());
 
+        // Scroll to the beginning of the line edits.
+        domainLineEditPointer->setCursorPosition(0);
+        nameLineEditPointer->setCursorPosition(0);
+        pathLineEditPointer->setCursorPosition(0);
+        valueLineEditPointer->setCursorPosition(0);
+
         // Populate the expiration date if it exists.
         if (!originalCookie.isSessionCookie())
         {
@@ -167,7 +173,7 @@ void AddOrEditCookieDialog::saveCookie()
     emit addCookie(cookie, isDurable);
 
     // Close the dialog.
-    reject();
+    close();
 }
 
 void AddOrEditCookieDialog::updateExpirationDateTimeState(const int &newState) const
index d00e3f7596d06169420df8240a1baacb18f190fc..895b14ab0e099ae541ce152df788bcac2bd9de87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright Â© 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
diff --git a/src/dialogs/BookmarksDialog.cpp b/src/dialogs/BookmarksDialog.cpp
new file mode 100644 (file)
index 0000000..509fade
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2023 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 "BookmarksDialog.h"
+#include "ui_BookmarksDialog.h"
+#include "databases/BookmarksDatabase.h"
+
+// KDE Frameworks headers.
+#include <KLocalizedString>
+
+// Qt toolkit headers.
+#include <QDebug>
+#include <QStandardItemModel>
+#include <QTreeView>
+
+// Construct the class.
+BookmarksDialog::BookmarksDialog() : QDialog(nullptr)
+{
+    // Set the dialog window title.
+    setWindowTitle(i18nc("The bookmarks dialog window title", "Bookmarks"));
+
+    // Set the window modality.
+    setWindowModality(Qt::WindowModality::ApplicationModal);
+
+    // Instantiate the bookmarks settings dialog UI.
+    Ui::BookmarksDialog bookmarksDialogUi;
+
+    // Setup the UI.
+    bookmarksDialogUi.setupUi(this);
+
+    // Get the list of bookmarks.
+    std::list<BookmarkStruct> *bookmarksListPointer = BookmarksDatabase::getBookmarks();
+
+    // Get a handle for the tree view.
+    QTreeView *treeViewPointer = bookmarksDialogUi.treeView;
+
+    // Initialize the tree model.
+    QStandardItemModel *treeModelPointer = new QStandardItemModel();
+
+    // Set the column count.
+    treeModelPointer->setColumnCount(3);
+
+    // Set the tree header data.  The first column is the database ID, which is not displayed.
+    treeModelPointer->setHeaderData(1, Qt::Horizontal, i18nc("The bookmark Name header.", "Name"));
+    treeModelPointer->setHeaderData(2, Qt::Horizontal, i18nc("The bookmark URL header.", "URL"));
+
+    // Populate the bookmarks tree view.
+    for (BookmarkStruct bookmarkStruct : *bookmarksListPointer)
+    {
+        // Create a list for the bookmark items.
+        QList<QStandardItem*> bookmarkItemList;
+
+        // Create the bookmark items.
+        QStandardItem *idItemPointer = new QStandardItem(QString::number(bookmarkStruct.id));
+        QStandardItem *nameItemPointer = new QStandardItem(bookmarkStruct.favoriteIcon, bookmarkStruct.bookmarkName);
+        QStandardItem *urlItemPointer = new QStandardItem(bookmarkStruct.bookmarkUrl);
+
+        // Populate the cookie standard item list.
+        bookmarkItemList.append(idItemPointer);
+        bookmarkItemList.append(nameItemPointer);
+        bookmarkItemList.append(urlItemPointer);
+
+        // Add the cookie to the tree.
+        treeModelPointer->appendRow(bookmarkItemList);
+    }
+
+    // Auto resize the headers.
+    treeViewPointer->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+
+    // Indicate that all the rows are the same height, which improves performance.
+    treeViewPointer->setUniformRowHeights(true);
+
+    // Set the tree model.
+    treeViewPointer->setModel(treeModelPointer);
+
+    // Hide the database ID column.
+    treeViewPointer->setColumnHidden(0, true);
+
+    // Get handles for the buttons.
+    QDialogButtonBox *dialogButtonBoxPointer = bookmarksDialogUi.dialogButtonBox;
+
+    // Connect the buttons.
+    connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(reject()));
+
+    // Monitor editing of data in the tree model.
+    connect(treeModelPointer, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateBookmarkFromTree(QStandardItem*)));
+}
+
+void BookmarksDialog::updateBookmarkFromTree(QStandardItem *modifiedStandardItem)
+{
+    // Get the model index of the modified item.
+    QModelIndex modifiedItemModelIndex = modifiedStandardItem->index();
+
+    // Get the model index of the database ID.
+    QModelIndex databaseIdModelIndex = modifiedItemModelIndex.siblingAtColumn(0);
+
+    // Get the database ID.
+    int databaseId = databaseIdModelIndex.data().toInt();
+
+    // Check to see if the bookmark name or the URL was edited.
+    if (modifiedStandardItem->column() == 1)  // The bookmark name was edited.
+    {
+        // Update the bookmark name.
+        BookmarksDatabase::updateBookmarkName(databaseId, modifiedStandardItem->text());
+    }
+    else  // The bookmark URL was edited.
+    {
+        // Update the bookmark URL.
+        BookmarksDatabase::updateBookmarkUrl(databaseId, modifiedStandardItem->text());
+    }
+
+    // Emit the bookmark updated signal.
+    emit bookmarkUpdated();
+}
diff --git a/src/dialogs/BookmarksDialog.h b/src/dialogs/BookmarksDialog.h
new file mode 100644 (file)
index 0000000..3e2713e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2023 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 BOOKMARKSDIALOG_H
+#define BOOKMARKSDIALOG_H
+
+// Application headers.
+#include "structs/BookmarkStruct.h"
+
+// Qt toolkit headers.
+#include <QDialog>
+#include <QStandardItem>
+
+class BookmarksDialog : public QDialog
+{
+    // Include the Q_OBJECT macro.
+    Q_OBJECT
+
+public:
+    // The primary constructor.
+    explicit BookmarksDialog();
+
+signals:
+    // The signals.
+    void bookmarkUpdated() const;
+
+private Q_SLOTS:
+    // The private slots.
+    void updateBookmarkFromTree(QStandardItem *modifiedStandardItem);
+};
+#endif
index d30f067e8dc27a383480eecd4c908ebd33d4d0b6..b5d7cfd4229f9707451111c3fa40f11bdacc2e42 100644 (file)
@@ -18,7 +18,9 @@
 
 # List the sources to include in the executable.
 target_sources(privacybrowser PRIVATE
+    AddBookmarkDialog.cpp
     AddOrEditCookieDialog.cpp
+    BookmarksDialog.cpp
     CookiesDialog.cpp
     DomainSettingsDialog.cpp
     DurableCookiesDialog.cpp
index 693eb3c20fa8c006c7480f5e18d44c11aac20653..3dc357f7e68bab2a9d05a68945dfe5e1218b3a80 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright Â© 2022-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -202,11 +202,11 @@ CookiesDialog::CookiesDialog(std::list<QNetworkCookie> *originalCookieListPointe
 
         // Create the cookie items.
         QStandardItem *nameItemPointer = new QStandardItem(QString(cookie.name()));
-        QStandardItem *durableItemPointer = new QStandardItem(QString(isDurable ? i18n("yes") : i18n("no")));
-        QStandardItem *pathItemPointer = new QStandardItem(QString(cookie.path()));
-        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 *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()));
 
         // Populate the cookie standard item list.
@@ -231,7 +231,7 @@ CookiesDialog::CookiesDialog(std::list<QNetworkCookie> *originalCookieListPointe
     // Don't elide the Value field (or any other field).
     treeViewPointer->setTextElideMode(Qt::ElideNone);
 
-    // Indicate that all the rows are the same height, wich improves performance.
+    // Indicate that all the rows are the same height, which improves performance.
     treeViewPointer->setUniformRowHeights(true);
 
     // Disable editing in the tree view.
index 36a7d722fc722cc6a25bbd50eaf981d4d2e67eb6..be4acda067f80a9706e1a4364bb1f2f037e3bb57 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright Â© 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
index d90258c15e5e86a256cbfd100f7eb348b4d37e8c..c39eb883cb04bf8c282d1a38fa113c5a72633cf7 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 // Application headers.
+#include "databases/BookmarksDatabase.h"
 #include "databases/CookiesDatabase.h"
 #include "databases/DomainsDatabase.h"
 #include "windows/BrowserWindow.h"
@@ -87,8 +88,9 @@ int main(int argc, char *argv[])
     QDir().mkdir(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first());
 
     // Add the databases.
-    DomainsDatabase::addDatabase();
+    BookmarksDatabase::addDatabase();
     CookiesDatabase::addDatabase();
+    DomainsDatabase::addDatabase();
 
     // Create the main window.
     BrowserWindow *browserWindowPointer = new BrowserWindow();
diff --git a/src/structs/BookmarkStruct.h b/src/structs/BookmarkStruct.h
new file mode 100644 (file)
index 0000000..2819174
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023 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 BOOKMARKSTRUCT_H
+#define BOOKMARKSTRUCT_H
+
+// Qt framework headers.
+#include <QIcon>
+#include <QString>
+
+struct BookmarkStruct
+{
+    int id;
+    QString bookmarkName;
+    QString bookmarkUrl;
+    QIcon favoriteIcon;
+};
+#endif
index 1a79d69cb1e888d80b578b34f998f1684ac5926d..c0e5a196febaec95eeb999728fe8e947ef196bc7 100644 (file)
             </Menu>
         </Menu>
 
+        <!-- Bookmarks. -->
+        <Menu name="bookmarks">
+            <Action name="view_bookmarks_toolbar" />
+
+            <Separator />
+        </Menu>
+
         <!-- Settings. -->
         <Menu name="settings">
             <Action name="domain_settings" />
         <Action name="find_case_sensitive" />
         <Action name="hide_find_actions" />
     </ToolBar>
+
+    <!-- The bookmarks toolbar. -->
+    <ToolBar name="bookmarks_toolbar" iconText="icontextright" newline="true" hidden="true"> <text>Bookmarks Toolbar</text> </ToolBar>
 </gui>
diff --git a/src/uis/AddBookmarkDialog.ui b/src/uis/AddBookmarkDialog.ui
new file mode 100644 (file)
index 0000000..b6dc2cf
--- /dev/null
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Copyright 2023 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/>. -->
+
+<ui version="4.0">
+  <class>AddBookmarkDialog</class>
+
+  <widget class="QWidget">
+    <layout class="QVBoxLayout">
+
+      <!-- First row. -->
+      <item>
+        <layout class="QHBoxLayout">
+          <property name="alignment">
+            <enum>Qt::AlignLeft</enum>
+          </property>
+
+          <!-- Icon. -->
+          <item>
+            <widget class="QGraphicsView"  name="favoriteIconGraphicsView">
+              <property name="sizePolicy">
+                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                  <horstretch>0</horstretch>
+                  <verstretch>0</verstretch>
+                </sizepolicy>
+              </property>
+
+              <property name="maximumSize">
+                <size>
+                  <width>32</width>
+                  <height>32</height>
+                </size>
+              </property>
+
+              <property name="frameShape">
+                <enum>QFrame::NoFrame</enum>
+              </property>
+
+              <property name="alignment">
+                <set>Qt::AlignCenter</set>
+              </property>
+            </widget>
+          </item>
+
+          <!-- Spacer label. -->
+          <item>
+            <widget class="QLabel">
+              <property name="textFormat">
+                <enum>Qt::RichText</enum>
+              </property>
+
+              <property name="text">
+                <string>&amp;nbsp;</string>
+              </property>
+            </widget>
+          </item>
+
+          <!-- Bookmark name.  -->
+          <item>
+            <widget class="QLabel">
+              <property name="toolTip">
+                <string>The name of the bookmark.</string>
+              </property>
+
+              <property name="text">
+                <string>Bookmark name</string>
+              </property>
+            </widget>
+          </item>
+
+          <item>
+            <widget class="QLineEdit" name="bookmarkNameLineEdit" />
+          </item>
+        </layout>
+      </item>
+
+      <!-- Second row. -->
+      <item>
+        <layout class="QHBoxLayout">
+          <property name="alignment">
+            <enum>Qt::AlignLeft</enum>
+          </property>
+
+          <!-- Bookmark URL. -->
+          <item>
+            <widget class="QLabel">
+              <property name="toolTip">
+                <string>The URL of the bookmark.</string>
+              </property>
+
+              <property name="text">
+                <string>Bookmark URL</string>
+              </property>
+            </widget>
+          </item>
+
+          <item>
+            <widget class="QLineEdit" name="bookmarkUrlLineEdit">
+              <property name="sizePolicy">
+                <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+                  <horstretch>0</horstretch>
+                  <verstretch>0</verstretch>
+                </sizepolicy>
+              </property>
+
+              <property name="minimumSize">
+                <size>
+                  <width>700</width>
+                  <height>0</height>
+                </size>
+              </property>
+            </widget>
+          </item>
+        </layout>
+      </item>
+
+      <!-- Spacer. -->
+      <item>
+        <spacer>
+          <property name="orientation">
+            <enum>Qt::Vertical</enum>
+          </property>
+        </spacer>
+      </item>
+
+      <!-- Dialog buttons. -->
+      <item>
+        <widget class="QDialogButtonBox" name="dialogButtonBox">
+          <property name="standardButtons">
+            <set>QDialogButtonBox::Cancel</set>
+          </property>
+        </widget>
+      </item>
+    </layout>
+  </widget>
+</ui>
index 658cb8d596715be8ea7ab1f1fb81c26a9fcbe408..779b8fb395db60a87f536238b21f2f3836e1590b 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
-  Copyright Â© 2022 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2022 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
 
diff --git a/src/uis/BookmarksDialog.ui b/src/uis/BookmarksDialog.ui
new file mode 100644 (file)
index 0000000..8510878
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Copyright 2023 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/>. -->
+
+<ui version="4.0">
+    <class>BookmarksDialog</class>
+
+    <widget class="QWidget">
+        <property name="geometry">
+            <rect>
+                <x>0</x>
+                <y>0</y>
+                <height>1000</height>
+                <width>1500</width>
+            </rect>
+        </property>
+
+        <layout class="QVBoxLayout">
+            <!-- Tree view. -->
+            <item>
+                <widget class="QTreeView" name="treeView" />
+            </item>
+
+            <!-- Buttons. -->
+            <item>
+                <layout class="QHBoxLayout">
+                    <!-- Close button - dialog button box. -->
+                    <item>
+                        <widget class="QDialogButtonBox" name="dialogButtonBox">
+                            <property name="standardButtons">
+                                <set>QDialogButtonBox::Close</set>
+                            </property>
+                        </widget>
+                    </item>
+                </layout>
+            </item>
+        </layout>
+    </widget>
+</ui>
index 78492451b6a5d2b8e82602fbc6dda585a00d069e..32529cb4460ad467ff636782cdb55b8e24fea52e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
-  Copyright 2022 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
 
@@ -21,7 +21,6 @@
 <ui version="4.0">
     <class>CookiesDialog</class>
 
-
     <widget class="QWidget">
         <property name="geometry">
             <rect>
index dd11a6776c0f0fdc798fe4492879ff2ce5a84a08..2f4582a9b2e6943af0b7c32982823315ae400aa0 100644 (file)
@@ -673,6 +673,24 @@ std::list<QNetworkCookie>* TabWidget::getCookieList() const
     return currentPrivacyWebEngineViewPointer->cookieListPointer;
 }
 
+QIcon TabWidget::getCurrentTabFavoritIcon() const
+{
+    // Return the current Privacy WebEngine favorite icon.
+    return currentPrivacyWebEngineViewPointer->favoriteIcon;
+}
+
+QString TabWidget::getCurrentTabTitle() const
+{
+    // Return the current Privacy WebEngine title.
+    return currentPrivacyWebEngineViewPointer->title();
+}
+
+QString TabWidget::getCurrentTabUrl() const
+{
+    // Return the current Privacy WebEngine URL as a string.
+    return currentPrivacyWebEngineViewPointer->url().toString();
+}
+
 QString& TabWidget::getDomainSettingsName() const
 {
     // Return the domain settings name.
index 8af311328cd4d0b5113ac9f98722238f06c9fcbb..e036a2429f3640b1f8831856a1f678bc8f035587 100644 (file)
@@ -57,6 +57,9 @@ public:
     void loadInitialWebsite();
     void findPrevious(const QString &text) const;
     std::list<QNetworkCookie>* getCookieList() const;
+    QIcon getCurrentTabFavoritIcon() const;
+    QString getCurrentTabTitle() const;
+    QString getCurrentTabUrl() const;
     QString& getDomainSettingsName() const;
     void setTabBarVisible(const bool visible) const;
     void toggleDomStorage() const;
index b897aa9d4106658bc2801fb8220f7ba107604920..c8c766da4e2586ead8fbfa4bf23f620cf0339f9e 100644 (file)
 #include "ui_SettingsGeneral.h"
 #include "ui_SettingsPrivacy.h"
 #include "ui_SettingsSpellCheck.h"
+#include "databases/BookmarksDatabase.h"
+#include "dialogs/AddBookmarkDialog.h"
+#include "dialogs/BookmarksDialog.h"
 #include "dialogs/CookiesDialog.h"
 #include "dialogs/DomainSettingsDialog.h"
 #include "helpers/SearchEngineHelper.h"
 #include "helpers/UserAgentHelper.h"
+#include "structs/BookmarkStruct.h"
 
 // KDE Frameworks headers.
 #include <KActionCollection>
 #include <KColorScheme>
-#include <KToolBar>
+#include <KXMLGUIFactory>
 
 // Qt toolkit headers.
 #include <QFileDialog>
@@ -69,6 +73,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     QAction *backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer);
     QAction *forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer);
     KStandardAction::home(this, SLOT(home()), actionCollectionPointer);
+    KStandardAction::addBookmark(this, SLOT(addBookmark()), actionCollectionPointer);
+    QAction *editBookmarksActionPointer = KStandardAction::editBookmarks(this, SLOT(editBookmarks()), actionCollectionPointer);
     KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollectionPointer);
     KStandardAction::find(this, SLOT(showFindTextActions()), actionCollectionPointer);
     findNextActionPointer = KStandardAction::findNext(this, SLOT(findNext()), actionCollectionPointer);
@@ -81,6 +87,9 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     QAction *reloadAndBypassCacheActionPointer = actionCollectionPointer->addAction(QLatin1String("reload_and_bypass_cache"));
     viewSourceActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source"));
     viewSourceInNewTabActionPointer = actionCollectionPointer->addAction(QLatin1String("view_source_in_new_tab"));
+    javaScriptActionPointer = actionCollectionPointer->addAction(QLatin1String("javascript"));
+    localStorageActionPointer = actionCollectionPointer->addAction(QLatin1String("local_storage"));
+    domStorageActionPointer = actionCollectionPointer->addAction(QLatin1String("dom_storage"));
     userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_privacy_browser"));
     userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_webengine_default"));
     userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_linux"));
@@ -98,11 +107,9 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     searchEngineBingActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_bing"));
     searchEngineYahooActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_yahoo"));
     searchEngineCustomActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_custom"));
+    viewBookmarksToolBarActionPointer = actionCollectionPointer->addAction(QLatin1String("view_bookmarks_toolbar"));
     QAction *domainSettingsActionPointer = actionCollectionPointer->addAction(QLatin1String("domain_settings"));
     cookiesActionPointer = actionCollectionPointer->addAction(QLatin1String("cookies"));
-    javaScriptActionPointer = actionCollectionPointer->addAction(QLatin1String("javascript"));
-    localStorageActionPointer = actionCollectionPointer->addAction(QLatin1String("local_storage"));
-    domStorageActionPointer = actionCollectionPointer->addAction(QLatin1String("dom_storage"));
     findCaseSensitiveActionPointer = actionCollectionPointer->addAction(QLatin1String("find_case_sensitive"));
     hideFindTextActionPointer = actionCollectionPointer->addAction(QLatin1String("hide_find_actions"));
 
@@ -150,6 +157,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     searchEngineBingActionPointer->setCheckable(true);
     searchEngineYahooActionPointer->setCheckable(true);
     searchEngineCustomActionPointer->setCheckable(true);
+    viewBookmarksToolBarActionPointer->setCheckable(true);
 
     // Instantiate the user agent helper.
     UserAgentHelper *userAgentHelperPointer = new UserAgentHelper();
@@ -161,6 +169,9 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     newWindowActionPointer->setText(i18nc("New window action", "New Window"));
     zoomDefaultActionPointer->setText(i18nc("Zoom default action", "Zoom Default"));
     reloadAndBypassCacheActionPointer->setText(i18nc("Reload and bypass cache action", "Reload and Bypass Cache"));
+    javaScriptActionPointer->setText(i18nc("JavaScript action", "JavaScript"));
+    localStorageActionPointer->setText(i18nc("The Local Storage action", "Local Storage"));
+    domStorageActionPointer->setText(i18nc("DOM Storage action", "DOM Storage"));
     userAgentPrivacyBrowserActionPointer->setText(userAgentHelperPointer->PRIVACY_BROWSER_TRANSLATED);
     userAgentWebEngineDefaultActionPointer->setText(userAgentHelperPointer->WEB_ENGINE_DEFAULT_TRANSLATED);
     userAgentFirefoxLinuxActionPointer->setText(userAgentHelperPointer->FIREFOX_LINUX_TRANSLATED);
@@ -175,11 +186,9 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     searchEngineGoogleActionPointer->setText(i18nc("Search engine", "Google"));
     searchEngineBingActionPointer->setText(i18nc("Search engine", "Bing"));
     searchEngineYahooActionPointer->setText(i18nc("Search engine", "Yahoo"));
+    viewBookmarksToolBarActionPointer->setText(i18nc("View bookmarks toolbar", "View Bookmarks Toolbar"));
     domainSettingsActionPointer->setText(i18nc("Domain Settings action", "Domain Settings"));
     cookiesActionPointer->setText(i18nc("The Cookies action, which also displays the number of cookies", "Cookies - %1", 0));
-    javaScriptActionPointer->setText(i18nc("JavaScript action", "JavaScript"));
-    localStorageActionPointer->setText(i18nc("The Local Storage action", "Local Storage"));
-    domStorageActionPointer->setText(i18nc("DOM Storage action", "DOM Storage"));
     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)"));
 
@@ -191,6 +200,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     reloadAndBypassCacheActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-refresh")));
     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"))));
+    domStorageActionPointer->setIcon(QIcon::fromTheme(QLatin1String("code-class"), QIcon(QLatin1String("/usr/share/icons/gnome/32x32/actions/gtk-unindent-ltr.png"))));
     userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode.svg"));
     userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("qtlogo"), QIcon::fromTheme(QLatin1String("user-group-properties"), QIcon::fromTheme(QLatin1String("contact-new")))));
     userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr"), QIcon::fromTheme(QLatin1String("user-group-properties"),
@@ -210,9 +220,9 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     searchEngineYahooActionPointer->setIcon(QIcon::fromTheme(QLatin1String("im-yahoo"), QIcon::fromTheme(QLatin1String("edit-find"))));
     searchEngineCustomActionPointer->setIcon(QIcon::fromTheme(QLatin1String("edit-find")));
     zoomFactorActionPointer->setIcon(QIcon::fromTheme(QLatin1String("zoom-fit-best")));
+    viewBookmarksToolBarActionPointer->setIcon(QIcon::fromTheme(QLatin1String("bookmarks")));
     domainSettingsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("settings-configure"), QIcon::fromTheme(QLatin1String("preferences-desktop"))));
     cookiesActionPointer->setIcon(QIcon::fromTheme(QLatin1String("preferences-web-browser-cookies"), QIcon::fromTheme(QLatin1String("appointment-new"))));
-    domStorageActionPointer->setIcon(QIcon::fromTheme(QLatin1String("code-class"), QIcon(QLatin1String("/usr/share/icons/gnome/32x32/actions/gtk-unindent-ltr.png"))));
     findCaseSensitiveActionPointer->setIcon(QIcon::fromTheme(QLatin1String("format-text-lowercase"), QIcon::fromTheme(QLatin1String("/usr/share/icons/gnome/32x32/apps/fonts.png"))));
     hideFindTextActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-close-symbolic")));
 
@@ -245,6 +255,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     QKeySequence ctrlShiftBKeySequence = QKeySequence(i18nc("The Bing search engine key sequence.", "Ctrl+Shift+B"));
     QKeySequence ctrlShiftYKeySequence = QKeySequence(i18nc("The Yahoo search engine key sequence.", "Ctrl+Shift+Y"));
     QKeySequence ctrlShiftCKeySequence = QKeySequence(i18nc("The custom search engine key sequence.", "Ctrl+Shift+C"));
+    QKeySequence ctrlAltShiftBKeySequence = QKeySequence(i18nc("The edit bookmarks key sequence.", "Ctrl+Alt+Shift+B"));
+    QKeySequence ctrlAltBKeySequence = QKeySequence(i18nc("The view bookmarks toolbar key sequence.", "Ctrl+Alt+B"));
     QKeySequence ctrlShiftDKeySequence = QKeySequence(i18nc("The domain settings key sequence.", "Ctrl+Shift+D"));
     QKeySequence ctrlSemicolonKeySequence = QKeySequence(i18nc("The cookies dialog key sequence.", "Ctrl+;"));
 
@@ -277,6 +289,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     actionCollectionPointer->setDefaultShortcut(searchEngineBingActionPointer, ctrlShiftBKeySequence);
     actionCollectionPointer->setDefaultShortcut(searchEngineYahooActionPointer, ctrlShiftYKeySequence);
     actionCollectionPointer->setDefaultShortcut(searchEngineCustomActionPointer, ctrlShiftCKeySequence);
+    actionCollectionPointer->setDefaultShortcut(editBookmarksActionPointer, ctrlAltShiftBKeySequence);
+    actionCollectionPointer->setDefaultShortcut(viewBookmarksToolBarActionPointer, ctrlAltBKeySequence);
     actionCollectionPointer->setDefaultShortcut(domainSettingsActionPointer, ctrlShiftDKeySequence);
     actionCollectionPointer->setDefaultShortcut(cookiesActionPointer, ctrlSemicolonKeySequence);
 
@@ -288,6 +302,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     connect(viewSourceActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewSource()));
     connect(viewSourceInNewTabActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewSourceInNewTab()));
     connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser()));
+    connect(viewBookmarksToolBarActionPointer, SIGNAL(triggered()), this, SLOT(toggleViewBookmarksToolBar()));
     connect(cookiesActionPointer, SIGNAL(triggered()), this, SLOT(showCookiesDialog()));
     connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(showDomainSettingsDialog()));
 
@@ -344,6 +359,10 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     // Get handles for the toolbars.
     navigationToolBarPointer = toolBar(QLatin1String("navigation_toolbar"));
     urlToolBarPointer = toolBar(QLatin1String("url_toolbar"));
+    bookmarksToolBarPointer = toolBar(QLatin1String("bookmarks_toolbar"));
+
+    // Populate the view bookmarks toolbar checkbox.
+    connect(bookmarksToolBarPointer, SIGNAL(visibilityChanged(bool)), this, SLOT(updateViewBookmarksToolBarCheckbox(bool)));
 
     // Create the line edits.
     urlLineEditPointer = new KLineEdit();
@@ -480,6 +499,19 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     connect(f11ShortcutPointer, SIGNAL(activated()), fullScreenActionPointer, SLOT(trigger()));
     connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape()));
 
+    // Get a handle for the Bookmarks menu.
+    bookmarksMenuPointer = qobject_cast<QMenu*>(guiFactory()->container("bookmarks", this));
+
+    // Add a separator to the bookmarks menu.
+    bookmarksMenuPointer->addSeparator();
+
+    // Initialize the current bookmarks lists.
+    bookmarksMenuCurrentActionList = QList<QAction*>();
+    bookmarksToolBarCurrentActionList = QList<QAction*>();
+
+    // Populate the bookmarks.
+    populateBookmarks();
+
     // Populate the UI.
     // This must be done here, because otherwise, if a URL is loaded, like a local file, that does not trigger a call to TabWidget::applyDomainSettings, the UI will not be fully populated.
     updateJavaScriptAction(Settings::javaScriptEnabled());
@@ -493,6 +525,15 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
         tabWidgetPointer->loadInitialWebsite();
 }
 
+void BrowserWindow::addBookmark() const
+{
+    // Instantiate an add bookmark dialog.
+    AddBookmarkDialog *addBookmarkDialogPointer = new AddBookmarkDialog(tabWidgetPointer->getCurrentTabTitle(), tabWidgetPointer->getCurrentTabUrl(), tabWidgetPointer->getCurrentTabFavoritIcon());
+
+    // Show the dialog.
+    addBookmarkDialogPointer->show();
+}
+
 void BrowserWindow::addOrEditDomainSettings() const
 {
     // Remove the focus from the URL line edit.
@@ -554,6 +595,18 @@ void BrowserWindow::decrementZoom()
     updateZoomActions(currentZoomFactor);
 }
 
+void BrowserWindow::editBookmarks() const
+{
+    // Instantiate an edit bookmarks dialog.
+    BookmarksDialog *bookmarksDialogPointer = new BookmarksDialog();
+
+    // Update the displayed bookmarks when edited.
+    connect(bookmarksDialogPointer, SIGNAL(bookmarkUpdated()), this, SLOT(populateBookmarks()));
+
+    // Show the dialog.
+    bookmarksDialogPointer->show();
+}
+
 void BrowserWindow::escape() const
 {
     // Process the escape according to the status of the browser.
@@ -611,26 +664,49 @@ void BrowserWindow::fullScreenRequested(const bool toggleOn)
     // Toggle full screen mode.
     if (toggleOn)  // Turn full screen mode on.
     {
-        // Set the window to be full screen.
+        // Enable full screen mode.
         fullScreenActionPointer->setFullScreen(window(), true);
 
-        // Hide all the bars.
-        menuBar()->setVisible(false);
-        navigationToolBarPointer->setVisible(false);
-        urlToolBarPointer->setVisible(false);
-        tabWidgetPointer->setTabBarVisible(false);
-        statusBar()->setVisible(false);
+        // Hide the menu bar if specified.
+        if (Settings::fullScreenHideMenuBar())
+            menuBar()->setVisible(false);
+
+        // Hide the toolbars if specified.
+        if (Settings::fullScreenHideToolBars())
+        {
+            navigationToolBarPointer->setVisible(false);
+            urlToolBarPointer->setVisible(false);
+            bookmarksToolBarPointer->setVisible(false);
+        }
+
+        // Hide the tab bar if specified.
+        if (Settings::fullScreenHideTabBar())
+            tabWidgetPointer->setTabBarVisible(false);
+
+        // Hide the status bar if specified.
+        if (Settings::fullScreenHideStatusBar())
+            statusBar()->setVisible(false);
     }
-    else  // Turn full screen mode off.
+    else  // Disable full screen browsing mode.
     {
-        // Set the window to not be full screen.
+        // Disable full screen mode.
         fullScreenActionPointer->setFullScreen(window(), false);
 
-        // Show all the bars.
+        // Show the menu bar.
         menuBar()->setVisible(true);
+
+        // Show the toolbars.
         navigationToolBarPointer->setVisible(true);
         urlToolBarPointer->setVisible(true);
+
+        // Only show the bookmarks toolbar if it was previously visible.
+        if (bookmarksToolBarIsVisible)
+            bookmarksToolBarPointer->setVisible(true);
+
+        // Show the tab bar.
         tabWidgetPointer->setTabBarVisible(true);
+
+        // Show the status bar.
         statusBar()->setVisible(true);
     }
 }
@@ -707,6 +783,73 @@ void BrowserWindow::newWindow() const
     (new BrowserWindow)->show();
 }
 
+void BrowserWindow::populateBookmarks()
+{
+    // Remove all the current menu bookmarks.
+    for (QAction *bookmarkAction : bookmarksMenuCurrentActionList)
+    {
+        // Remove the bookmark.
+        bookmarksMenuPointer->removeAction(bookmarkAction);
+    }
+
+    // Remove all the current toolbar bookmarks.
+    for (QAction *bookmarkAction : bookmarksToolBarCurrentActionList)
+    {
+        // Remove the bookmark.
+        bookmarksToolBarPointer->removeAction(bookmarkAction);
+    }
+
+    // Clear the current bookmark lists.
+    bookmarksMenuCurrentActionList.clear();
+    bookmarksToolBarCurrentActionList.clear();
+
+    // Get a list of the bookmarks.
+    std::list<BookmarkStruct> *bookmarkListPointer = BookmarksDatabase::getBookmarks();
+
+    // Populate the bookmarks menu.
+    for (BookmarkStruct bookmarkStruct : *bookmarkListPointer)
+    {
+        // Get the bookmark URL.
+        QString bookmarkUrl = bookmarkStruct.bookmarkUrl;
+
+        // Add the bookmark to the menu.
+        QAction *menuBookmarkActionPointer = bookmarksMenuPointer->addAction(bookmarkStruct.favoriteIcon, bookmarkStruct.bookmarkName, [=]
+            {
+                // Remove the focus from the URL line edit.
+                urlLineEditPointer->clearFocus();
+
+                // Load the URL.
+                tabWidgetPointer->loadUrlFromLineEdit(bookmarkUrl);
+            }
+        );
+
+        // Add the bookmark to the toolbar.
+        QAction *toolBarBookmarkActionPointer = bookmarksToolBarPointer->addAction(bookmarkStruct.favoriteIcon, bookmarkStruct.bookmarkName, [=]
+            {
+                // Remove the focus from the URL line edit.
+                urlLineEditPointer->clearFocus();
+
+                // Load the URL.
+                tabWidgetPointer->loadUrlFromLineEdit(bookmarkUrl);
+            }
+        );
+
+        // Add the actions to the current bookmarks lists.
+        bookmarksMenuCurrentActionList.append(menuBookmarkActionPointer);
+        bookmarksToolBarCurrentActionList.append(toolBarBookmarkActionPointer);
+    }
+
+    // Get a handle for the bookmark toolbar layout.
+    QLayout *bookmarksToolBarLayoutPointer = bookmarksToolBarPointer->layout();
+
+    // Get the count of the bookmarks.
+    int bookmarkCount = bookmarksToolBarLayoutPointer->count();
+
+    // Set the layout of each bookmark to be left aligned.
+    for(int i = 0; i < bookmarkCount; ++i)
+        bookmarksToolBarLayoutPointer->itemAt(i)->setAlignment(Qt::AlignLeft);
+}
+
 void BrowserWindow::refresh() const
 {
     // Remove the focus from the URL line edit.
@@ -1023,48 +1166,7 @@ void BrowserWindow::toggleLocalStorage() const
 void BrowserWindow::toggleFullScreen()
 {
     // Toggle the full screen status.
-    if (fullScreenActionPointer->isChecked())  // Enable full screen browsing mode.
-    {
-        // Enable full screen mode.
-        fullScreenActionPointer->setFullScreen(window(), true);
-
-        // Hide the menu bar if specified.
-        if (Settings::fullScreenHideMenuBar())
-            menuBar()->setVisible(false);
-
-        // Hide the toolbars if specified.
-        if (Settings::fullScreenHideToolBars())
-        {
-            navigationToolBarPointer->setVisible(false);
-            urlToolBarPointer->setVisible(false);
-        }
-
-        // Hide the tab bar if specified.
-        if (Settings::fullScreenHideTabBar())
-            tabWidgetPointer->setTabBarVisible(false);
-
-        // Hide the status bar if specified.
-        if (Settings::fullScreenHideStatusBar())
-            statusBar()->setVisible(false);
-    }
-    else  // Disable full screen browsing mode.
-    {
-        // Disable full screen mode.
-        fullScreenActionPointer->setFullScreen(window(), false);
-
-        // Show the menu bar.
-        menuBar()->setVisible(true);
-
-        // Show the toolbars.
-        navigationToolBarPointer->setVisible(true);
-        urlToolBarPointer->setVisible(true);
-
-        // Show the tab bar.
-        tabWidgetPointer->setTabBarVisible(true);
-
-        // Show the status bar.
-        statusBar()->setVisible(true);
-    }
+    fullScreenRequested(fullScreenActionPointer->isChecked());
 }
 
 void BrowserWindow::toggleViewSource() const
@@ -1088,6 +1190,15 @@ void BrowserWindow::toggleViewSource() const
     loadUrlFromLineEdit(url);
 }
 
+void BrowserWindow::toggleViewBookmarksToolBar()
+{
+    // Store the current status of the bookmarks toolbar, which is used when exiting full screen browsing.
+    bookmarksToolBarIsVisible = viewBookmarksToolBarActionPointer->isChecked();
+
+    // Update the visibility of the bookmarks toolbar.
+    bookmarksToolBarPointer->setVisible(bookmarksToolBarIsVisible);
+}
+
 void BrowserWindow::toggleViewSourceInNewTab() const
 {
     // Get the current URL.
@@ -1488,6 +1599,22 @@ void BrowserWindow::updateUserAgentLabel(const QString &userAgentDatabaseName) c
     userAgentLabelPointer->setText(UserAgentHelper::getUserAgentFromDatabaseName(userAgentDatabaseName));
 }
 
+void BrowserWindow::updateViewBookmarksToolBarCheckbox(const bool visible)
+{
+    // Update the view bookmarks toolbar checkbox.
+    viewBookmarksToolBarActionPointer->setChecked(visible);
+
+    // Initialize the bookmarks toolbar visibility tracker if Privacy Browser has just launched.
+    if (bookmarksToolBarUninitialized)
+    {
+        // Set the initialization flag.
+        bookmarksToolBarUninitialized = false;
+
+        // Store the current status of the bookmarks toolbar, which is used when exiting full screen browsing.
+        bookmarksToolBarIsVisible = visible;
+    }
+}
+
 void BrowserWindow::updateWindowTitle(const QString &title)
 {
     // Update the window title.
index a7b78d6ec1ceb1a95473c55237b8bbab631a2868..49cb198307f40c7e6ddc2cc6b0005834a84b1e80 100644 (file)
@@ -26,6 +26,7 @@
 // KDE Frameworks headers.
 #include <KConfigDialog>
 #include <KToggleFullScreenAction>
+#include <KToolBar>
 #include <KXmlGuiWindow>
 
 // Qt toolkit headers.
@@ -50,10 +51,12 @@ public:
 
 private Q_SLOTS:
     // The private slots.
+    void addBookmark() const;
     void addOrEditDomainSettings() const;
     void back() const;
     void clearUrlLineEditFocus() const;
     void decrementZoom();
+    void editBookmarks() const;
     void escape() const;
     void findNext() const;
     void findPrevious() const;
@@ -65,6 +68,7 @@ private Q_SLOTS:
     void incrementZoom();
     void loadUrlFromLineEdit(const QString &url) const;
     void newWindow() const;
+    void populateBookmarks();
     void refresh() const;
     void reloadAndBypassCache() const;
     void showCookiesDialog();
@@ -78,6 +82,7 @@ private Q_SLOTS:
     void toggleJavaScript() const;
     void toggleLocalStorage() const;
     void toggleFullScreen();
+    void toggleViewBookmarksToolBar();
     void toggleViewSource() const;
     void toggleViewSourceInNewTab() const;
     void updateCookiesAction(const int numberOfCookies) const;
@@ -94,11 +99,18 @@ private Q_SLOTS:
     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();
 
 private:
     // The private variables.
+    QList<QAction*> bookmarksMenuCurrentActionList;
+    QMenu *bookmarksMenuPointer;
+    QList<QAction*> bookmarksToolBarCurrentActionList;
+    KToolBar *bookmarksToolBarPointer;
+    bool bookmarksToolBarIsVisible = false;
+    bool bookmarksToolBarUninitialized = true;
     KConfigDialog *configDialogPointer;
     QAction *cookiesActionPointer;
     QUrl currentUrl;
@@ -149,6 +161,7 @@ private:
     QAction *userAgentCustomActionPointer;
     KLineEdit *urlLineEditPointer;
     KToolBar *urlToolBarPointer;
+    QAction *viewBookmarksToolBarActionPointer;
     QAction *viewSourceActionPointer;
     QAction *viewSourceInNewTabActionPointer;
     QAction *zoomDefaultActionPointer;