aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/controller
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-11-17 13:42:58 +0000
committersaturneric <[email protected]>2024-11-17 13:42:58 +0000
commitde4123e31d2f0590fc89a0ae2262f20bbc4eeba2 (patch)
treee7e468d39107d9604c6bb329f58f75a3abfd8ee4 /src/ui/dialog/controller
parentfix: should restart app after editing key db infos (diff)
downloadGpgFrontend-de4123e31d2f0590fc89a0ae2262f20bbc4eeba2.tar.gz
GpgFrontend-de4123e31d2f0590fc89a0ae2262f20bbc4eeba2.zip
feat: can open key db by menu action triggered by right click
Diffstat (limited to 'src/ui/dialog/controller')
-rw-r--r--src/ui/dialog/controller/GnuPGControllerDialog.cpp17
-rw-r--r--src/ui/dialog/controller/GnuPGControllerDialog.h6
2 files changed, 23 insertions, 0 deletions
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
diff --git a/src/ui/dialog/controller/GnuPGControllerDialog.h b/src/ui/dialog/controller/GnuPGControllerDialog.h
index 37ec2f62..4a81e917 100644
--- a/src/ui/dialog/controller/GnuPGControllerDialog.h
+++ b/src/ui/dialog/controller/GnuPGControllerDialog.h
@@ -94,6 +94,12 @@ class GnuPGControllerDialog : public GeneralDialog {
*/
void slot_refresh_key_database_table();
+ /**
+ * @brief
+ *
+ */
+ void slot_open_key_database();
+
private:
std::shared_ptr<Ui_GnuPGControllerDialog> ui_; ///<
int restart_mode_{0}; ///<