/*
- * 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>.
*
#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"));
addBookmarkDialogUi.setupUi(this);
// Get handles for the widgets.
- defaultFavoriteIconRadioButtonPointer = addBookmarkDialogUi.defaultFavoriteIconRadioButton;
+ websiteFavoriteIconRadioButtonPointer = addBookmarkDialogUi.websiteFavoriteIconRadioButton;
customFavoriteIconRadioButtonPointer = addBookmarkDialogUi.customFavoriteIconRadioButton;
parentFolderTreeWidgetPointer = addBookmarkDialogUi.parentFolderTreeWidget;
bookmarkNameLineEditPointer = addBookmarkDialogUi.bookmarkNameLineEdit;
QPushButton *browseButtonPointer = addBookmarkDialogUi.browseButton;
QDialogButtonBox *dialogButtonBoxPointer = addBookmarkDialogUi.dialogButtonBox;
- // Set the default favorite icon.
- defaultFavoriteIconRadioButtonPointer->setIcon(favoriteIcon);
+ // Set the icons.
+ websiteFavoriteIconRadioButtonPointer->setIcon(favoriteIcon);
+ customFavoriteIconRadioButtonPointer->setIcon(QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet"))));
// Instantiate a folder helper.
folderHelperPointer = new FolderHelper();
// Populate the bookmarks tree widget item.
bookmarksTreeWidgetItemPointer->setText(folderHelperPointer->FOLDER_NAME_COLUMN, i18nc("The bookmarks root tree widget name", "Bookmarks"));
- bookmarksTreeWidgetItemPointer->setIcon(folderHelperPointer->FOLDER_NAME_COLUMN, QIcon::fromTheme("bookmarks"));
+ bookmarksTreeWidgetItemPointer->setIcon(folderHelperPointer->FOLDER_NAME_COLUMN, QIcon::fromTheme(QLatin1String("bookmarks"), QIcon::fromTheme(QLatin1String("bookmark-new"))));
bookmarksTreeWidgetItemPointer->setText(folderHelperPointer->FOLDER_ID_COLUMN, QLatin1String("0"));
// Add the bookmarks tree widget item to the root of the tree.
bookmarkNameLineEditPointer->setText(bookmarkName);
bookmarkUrlLineEditPointer->setText(bookmarkUrl);
- // Scroll to the beginning of the line edits.
- bookmarkNameLineEditPointer->setCursorPosition(0);
+ // Scroll to the beginning of the bookmark URL line edit.
bookmarkUrlLineEditPointer->setCursorPosition(0);
+ // Focus the bookmark name line edit.
+ bookmarkNameLineEditPointer->setFocus();
+
// Add buttons to the dialog button box.
addButtonPointer = dialogButtonBoxPointer->addButton(i18nc("The add bookmark button", "Add"), QDialogButtonBox::AcceptRole);
QTreeWidgetItem *selectedFolderPointer = selectedFoldersList.first();
// Get the favorite icon.
- QIcon favoriteIcon = defaultFavoriteIconRadioButtonPointer->isChecked() ? defaultFavoriteIconRadioButtonPointer->icon() : customFavoriteIconRadioButtonPointer->icon();
+ QIcon favoriteIcon = websiteFavoriteIconRadioButtonPointer->isChecked() ? websiteFavoriteIconRadioButtonPointer->icon() : customFavoriteIconRadioButtonPointer->icon();
// Create a bookmark struct.
BookmarkStruct *bookmarkStructPointer = new BookmarkStruct;