aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/main_window/MainWindowSlotFunction.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-02 07:23:01 +0000
committersaturneric <[email protected]>2023-12-02 07:23:01 +0000
commit8a63c3954d6745c5e323dcf3e518219ce6545cc0 (patch)
treea41caf8801d0dceea3a2882626bbfb5b06c279b5 /src/ui/main_window/MainWindowSlotFunction.cpp
parentfix: discover and fix some bugs (diff)
downloadGpgFrontend-8a63c3954d6745c5e323dcf3e518219ce6545cc0.tar.gz
GpgFrontend-8a63c3954d6745c5e323dcf3e518219ce6545cc0.zip
fix: add set owner struct action in keymanager menu
Diffstat (limited to 'src/ui/main_window/MainWindowSlotFunction.cpp')
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp48
1 files changed, 4 insertions, 44 deletions
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 2c1d92ac..8998024f 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -49,6 +49,7 @@
#include "ui/dialog/help/AboutDialog.h"
#include "ui/dialog/import_export/KeyUploadDialog.h"
#include "ui/dialog/keypair_details/KeyDetailsDialog.h"
+#include "ui/function/SetOwnerTrustLevel.h"
#include "ui/widgets/FindWidget.h"
namespace GpgFrontend::UI {
@@ -751,50 +752,9 @@ void MainWindow::slot_set_owner_trust_level_of_key() {
auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) return;
- auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front());
-
- QStringList items;
-
- items << _("Unknown") << _("Undefined") << _("Never") << _("Marginal")
- << _("Full") << _("Ultimate");
- bool ok;
- QString item = QInputDialog::getItem(this, _("Modify Owner Trust Level"),
- _("Trust for the Key Pair:"), items,
- key.GetOwnerTrustLevel(), false, &ok);
-
- if (ok && !item.isEmpty()) {
- SPDLOG_DEBUG("selected policy: {}", item.toStdString());
- int trust_level = 0; // Unknown Level
- if (item == _("Ultimate")) {
- trust_level = 5;
- } else if (item == _("Full")) {
- trust_level = 4;
- } else if (item == _("Marginal")) {
- trust_level = 3;
- } else if (item == _("Never")) {
- trust_level = 2;
- } else if (item == _("Undefined")) {
- trust_level = 1;
- }
-
- if (trust_level == 0) {
- QMessageBox::warning(
- this, _("Warning"),
- QString(_("Owner Trust Level cannot set to Unknown level, automately "
- "changing it into Undefined level.")));
- trust_level = 1;
- }
-
- bool status =
- GpgKeyManager::GetInstance().SetOwnerTrustLevel(key, trust_level);
- if (!status) {
- QMessageBox::critical(this, _("Failed"),
- QString(_("Modify Owner Trust Level failed.")));
- } else {
- // update key database and refresh ui
- emit SignalKeyDatabaseRefresh();
- }
- }
+ auto* function = new SetOwnerTrustLevel(this);
+ function->Exec(key_ids->front());
+ function->deleteLater();
}
void MainWindow::upload_key_to_server() {