aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/ui/dialog/controller/GnuPGControllerDialog.cpp17
-rw-r--r--src/ui/dialog/controller/GnuPGControllerDialog.h6
-rw-r--r--ui/GnuPGControllerDialog.ui31
3 files changed, 44 insertions, 10 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}; ///<
diff --git a/ui/GnuPGControllerDialog.ui b/ui/GnuPGControllerDialog.ui
index 2876e2e4..86a4ac3d 100644
--- a/ui/GnuPGControllerDialog.ui
+++ b/ui/GnuPGControllerDialog.ui
@@ -72,7 +72,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
- <enum>Qt::Vertical</enum>
+ <enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -92,7 +92,7 @@
<item>
<widget class="QTableWidget" name="keyDatabaseTable">
<property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
+ <set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>false</bool>
@@ -101,16 +101,16 @@
<bool>false</bool>
</property>
<property name="dragDropMode">
- <enum>QAbstractItemView::NoDragDrop</enum>
+ <enum>QAbstractItemView::DragDropMode::NoDragDrop</enum>
</property>
<property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
+ <enum>Qt::DropAction::IgnoreAction</enum>
</property>
<property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
+ <enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
</property>
<property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
+ <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<property name="columnCount">
<number>2</number>
@@ -179,7 +179,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
- <enum>Qt::Vertical</enum>
+ <enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -203,10 +203,10 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ <set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
@@ -218,7 +218,18 @@
<string>Remove</string>
</property>
<property name="menuRole">
- <enum>QAction::NoRole</enum>
+ <enum>QAction::MenuRole::NoRole</enum>
+ </property>
+ </action>
+ <action name="actionOpen_Key_Database">
+ <property name="text">
+ <string>Open</string>
+ </property>
+ <property name="toolTip">
+ <string>Open Key database by System File Expolrer</string>
+ </property>
+ <property name="menuRole">
+ <enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
</widget>