diff options
author | saturneric <[email protected]> | 2024-01-11 03:05:45 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-11 03:05:45 +0000 |
commit | 0266ff1bbce2feccec34ab789f9e378948d1b24d (patch) | |
tree | 49dcdd97ea5fccb47ac5bdb7f2a7e1e51dfb8c05 /src/ui/main_window/MainWindowSlotFunction.cpp | |
parent | feat: update core apis, functions and models (diff) | |
download | GpgFrontend-0266ff1bbce2feccec34ab789f9e378948d1b24d.tar.gz GpgFrontend-0266ff1bbce2feccec34ab789f9e378948d1b24d.zip |
feat: improve api and ui of keys import and export
Diffstat (limited to 'src/ui/main_window/MainWindowSlotFunction.cpp')
-rw-r--r-- | src/ui/main_window/MainWindowSlotFunction.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index 3f29d281..6e87d6b6 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -65,20 +65,28 @@ void MainWindow::slot_find() { * Append the selected (not checked!) Key(s) To Textedit */ void MainWindow::slot_append_selected_keys() { - auto exported = GpgFrontend::SecureCreateSharedObject<ByteArray>(); auto key_ids = m_key_list_->GetSelected(); if (key_ids->empty()) { - GF_UI_LOG_ERROR("no key is selected"); + GF_UI_LOG_ERROR("no key is selected to export"); + return; + } + + auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front()); + if (!key.IsGood()) { + GF_UI_LOG_ERROR("selected key for exporting is invalid, key id: {}", + key_ids->front()); return; } - if (!GpgKeyImportExporter::GetInstance().ExportKeys(key_ids, exported)) { - QMessageBox::critical(this, _("Error"), _("Key Export Operation Failed.")); + auto [err, gf_buffer] = + GpgKeyImportExporter::GetInstance().ExportKey(key, false, true, false); + if (CheckGpgError(err) != GPG_ERR_NO_ERROR) { + CommonUtils::RaiseMessageBox(this, err); return; } - edit_->SlotAppendText2CurTextPage(QString::fromStdString(*exported)); + edit_->SlotAppendText2CurTextPage(gf_buffer.ConvertToQByteArray()); } void MainWindow::slot_append_keys_create_datetime() { @@ -300,7 +308,7 @@ void MainWindow::slot_version_upgrade_nofity() { QString(_("GpgFrontend Upgradeable (New Version: %1).")) .arg(latest_version.c_str()), 30000); - auto update_button = new QPushButton("Update GpgFrontend", this); + auto* update_button = new QPushButton("Update GpgFrontend", this); connect(update_button, &QPushButton::clicked, [=]() { auto* about_dialog = new AboutDialog(2, this); about_dialog->show(); |