diff options
author | Saturneric <[email protected]> | 2023-07-13 09:32:04 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-07-13 09:32:04 +0000 |
commit | a20527f4ba85b462f936f4ee54d93752f9c70ebe (patch) | |
tree | 95ac504aca96ce4da4e84a700fc0c48869ecaccd /src/ui/main_window/MainWindowSlotFunction.cpp | |
parent | fix: update ui file of KeyList (diff) | |
download | GpgFrontend-a20527f4ba85b462f936f4ee54d93752f9c70ebe.tar.gz GpgFrontend-a20527f4ba85b462f936f4ee54d93752f9c70ebe.zip |
feat: support resotring unsaved pages after a crash
Diffstat (limited to 'src/ui/main_window/MainWindowSlotFunction.cpp')
-rw-r--r-- | src/ui/main_window/MainWindowSlotFunction.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index fc0218b9..1adf2d4e 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -39,6 +39,7 @@ #include "core/function/gpg/GpgBasicOperator.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/function/gpg/GpgKeyImportExporter.h" +#include "core/function/gpg/GpgKeyManager.h" #include "dialog/SignersPicker.h" #include "spdlog/spdlog.h" #include "ui/UserInterfaceUtils.h" @@ -776,6 +777,56 @@ void MainWindow::refresh_keys_from_key_server() { dialog->SlotImport(key_ids); } +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(); + } + } +} + void MainWindow::upload_key_to_server() { auto key_ids = m_key_list_->GetSelected(); auto* dialog = new KeyUploadDialog(key_ids, this); |