diff options
Diffstat (limited to 'src/ui/widgets/KeyList.cpp')
-rw-r--r-- | src/ui/widgets/KeyList.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 1d954f86..4e581d81 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -633,4 +633,19 @@ void KeyList::UpdateKeyTableColumnType(GpgKeyTableColumn column_type) { auto KeyList::GetCurrentGpgContextChannel() const -> int { return current_gpg_context_channel_; } + +auto KeyList::GetSelectedGpgKey() -> std::tuple<bool, GpgKey> { + auto key_ids = GetSelected(); + if (key_ids.empty()) return {false, GpgKey()}; + + auto key = GpgKeyGetter::GetInstance(GetCurrentGpgContextChannel()) + .GetKey(key_ids.front()); + + if (!key.IsGood()) { + QMessageBox::critical(this, tr("Error"), tr("Key Not Found.")); + return {false, GpgKey()}; + } + + return {true, key}; +} } // namespace GpgFrontend::UI |