]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/AddBookmarkDialog.cpp
Block all CSP requests. https://redmine.stoutner.com/issues/1193
[PrivacyBrowserPC.git] / src / dialogs / AddBookmarkDialog.cpp
index 9f977afabdcfed2f8ece0e02b89499d5e4b01b40..991962cb3d08e24d03cf1ce44c6bc69bbb9c0d57 100644 (file)
@@ -1,20 +1,20 @@
-/*
- * 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.
@@ -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"));
@@ -94,15 +95,17 @@ AddBookmarkDialog::AddBookmarkDialog(const QString &bookmarkName, const QString
     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()));
@@ -141,7 +144,7 @@ void AddBookmarkDialog::addBookmark()
     BookmarksDatabase::addBookmark(bookmarkStructPointer);
 
     // Update the list of bookmarks in the menu and toolbar.
-    emit bookmarkAdded();
+    Q_EMIT bookmarkAdded();
 
     // Close the dialog.
     close();
@@ -166,7 +169,7 @@ void AddBookmarkDialog::browse()
 
 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.