From f1b8873d3d98a95d02af38453585bd95edf8a8be Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 29 Nov 2024 17:30:42 +0100 Subject: feat: user should confirm the removal of key dbs --- src/ui/dialog/controller/GnuPGControllerDialog.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ui/dialog/controller/GnuPGControllerDialog.cpp') diff --git a/src/ui/dialog/controller/GnuPGControllerDialog.cpp b/src/ui/dialog/controller/GnuPGControllerDialog.cpp index fe334e45..d911d52e 100644 --- a/src/ui/dialog/controller/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/controller/GnuPGControllerDialog.cpp @@ -70,6 +70,8 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) tr("Tips: notice that modify any of these settings will cause an " "Application restart.")); + + popup_menu_ = new QMenu(this); popup_menu_->addAction(ui_->actionMove_Key_Database_Up); popup_menu_->addAction(ui_->actionMove_Key_Database_Down); @@ -429,6 +431,16 @@ void GnuPGControllerDialog::slot_remove_existing_key_database() { for (int i = 0; i < row_size; i++) { auto* const item = ui_->keyDatabaseTable->item(i, 1); if (!item->isSelected()) continue; + + QMessageBox::StandardButton reply = QMessageBox::question( + this, tr("Confirm Deletion"), + tr("Are you sure you want to delete the selected key database?"), + QMessageBox::Yes | QMessageBox::No); + + if (reply != QMessageBox::Yes) { + return; + } + key_databases.remove(i); break; } -- cgit v1.2.3 From 25f38e3b946ef847334c2a6c0d708127f4200a40 Mon Sep 17 00:00:00 2001 From: saturneric Date: Sat, 30 Nov 2024 22:21:12 +0100 Subject: fix: solve discovered issues --- src/ui/dialog/controller/GnuPGControllerDialog.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ui/dialog/controller/GnuPGControllerDialog.cpp') diff --git a/src/ui/dialog/controller/GnuPGControllerDialog.cpp b/src/ui/dialog/controller/GnuPGControllerDialog.cpp index d911d52e..72e9c276 100644 --- a/src/ui/dialog/controller/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/controller/GnuPGControllerDialog.cpp @@ -70,8 +70,6 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) tr("Tips: notice that modify any of these settings will cause an " "Application restart.")); - - popup_menu_ = new QMenu(this); popup_menu_->addAction(ui_->actionMove_Key_Database_Up); popup_menu_->addAction(ui_->actionMove_Key_Database_Down); @@ -274,7 +272,9 @@ void GnuPGControllerDialog::set_settings() { buffered_key_db_so_ = GetGpgKeyDatabaseInfos(); editable_key_db_so_ = buffered_key_db_so_; - editable_key_db_so_.pop_front(); + if (!editable_key_db_so_.isEmpty()) { + editable_key_db_so_.pop_front(); + } this->slot_refresh_key_database_table(); } @@ -382,7 +382,9 @@ void GnuPGControllerDialog::slot_add_new_key_database() { key_databases.append(key_database); editable_key_db_so_ = buffered_key_db_so_; - editable_key_db_so_.pop_front(); + if (!editable_key_db_so_.isEmpty()) { + editable_key_db_so_.pop_front(); + } // refresh ui slot_refresh_key_database_table(); -- cgit v1.2.3