-/*
- * Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2023-2024 Soren Stoutner <soren@stoutner.com>
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
- * Privacy Browser PC is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
*
- * Privacy Browser PC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
*
- * You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Application headers.
#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"));
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);
// Set the button icons.
- addButtonPointer->setIcon(QIcon::fromTheme("list-add"));
+ addButtonPointer->setIcon(QIcon::fromTheme(QLatin1String("list-add")));
// Connect the buttons.
connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(browse()));
BookmarksDatabase::addBookmark(bookmarkStructPointer);
// Update the list of bookmarks in the menu and toolbar.
- emit bookmarkAdded();
+ Q_EMIT bookmarkAdded();
// Close the dialog.
close();
void AddBookmarkDialog::updateUi()
{
- // Determine if both line edits are populated.
+ // Update the add button status
if (bookmarkNameLineEditPointer->text().isEmpty() || bookmarkUrlLineEditPointer->text().isEmpty()) // At least one of the line edits is empty.
{
// Disable the add button.