From de4123e31d2f0590fc89a0ae2262f20bbc4eeba2 Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 17 Nov 2024 14:42:58 +0100 Subject: feat: can open key db by menu action triggered by right click --- src/ui/dialog/controller/GnuPGControllerDialog.cpp | 17 +++++++++++++++++ 1 file changed, 17 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 2d0bab6e..b53649c4 100644 --- a/src/ui/dialog/controller/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/controller/GnuPGControllerDialog.cpp @@ -70,6 +70,7 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) "Application restart.")); popup_menu_ = new QMenu(this); + popup_menu_->addAction(ui_->actionOpen_Key_Database); popup_menu_->addAction(ui_->actionRemove_Selected_Key_Database); // announce main window @@ -138,6 +139,9 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) connect(ui_->actionRemove_Selected_Key_Database, &QAction::triggered, this, &GnuPGControllerDialog::slot_remove_existing_key_database); + connect(ui_->actionOpen_Key_Database, &QAction::triggered, this, + &GnuPGControllerDialog::slot_open_key_database); + #if defined(__APPLE__) && defined(__MACH__) // macOS style settings ui_->buttonBox->setDisabled(true); @@ -398,4 +402,17 @@ void GnuPGControllerDialog::slot_remove_existing_key_database() { // announce the restart this->slot_set_restart_needed(kDeepRestartCode); } + +void GnuPGControllerDialog::slot_open_key_database() { + const auto row_size = ui_->keyDatabaseTable->rowCount(); + + auto& key_databases = buffered_key_db_so_; + for (int i = 0; i < row_size; i++) { + auto* const item = ui_->keyDatabaseTable->item(i, 1); + if (!item->isSelected()) continue; + LOG_D() << "try to open key db at path: " << key_databases[i].path; + QDesktopServices::openUrl(QUrl::fromLocalFile(key_databases[i].path)); + break; + } +} } // namespace GpgFrontend::UI -- cgit v1.2.3