aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/VerifyKeyDetailBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widgets/VerifyKeyDetailBox.cpp')
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.cpp176
1 files changed, 87 insertions, 89 deletions
diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp
index 192b09f3..35b3c100 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.cpp
+++ b/src/ui/widgets/VerifyKeyDetailBox.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2021 Saturneric
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
* This file is part of GpgFrontend.
*
@@ -20,7 +20,7 @@
* the gpg4usb project, which is under GPL-3.0-or-later.
*
* All the source code of GpgFrontend was modified and released by
- * Saturneric<[email protected]> starting on May 12, 2021.
+ * Saturneric <[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
@@ -28,8 +28,11 @@
#include "ui/widgets/VerifyKeyDetailBox.h"
+#include "core/GpgModel.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyGetter.h"
+#include "core/utils/CommonUtils.h"
+#include "ui/UserInterfaceUtils.h"
namespace GpgFrontend::UI {
@@ -43,21 +46,23 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
this->setTitle("A Error Signature");
bool forbid_all_gnupg_connection =
- GlobalSettingStation::GetInstance().LookupSettings(
- "network.forbid_all_gnupg_connection", false);
+ GlobalSettingStation::GetInstance()
+ .GetSettings()
+ .value("network/forbid_all_gnupg_connection", false)
+ .toBool();
- auto* import_button = new QPushButton(_("Import from keyserver"));
+ auto* import_button = new QPushButton(tr("Import from keyserver"));
import_button->setDisabled(forbid_all_gnupg_connection);
connect(import_button, &QPushButton::clicked, this,
&VerifyKeyDetailBox::slot_import_form_key_server);
- this->setTitle(QString(_("Key not present with id 0x")) + fpr_.c_str());
+ this->setTitle(tr("Key not present with id 0x") + fpr_);
- auto grid = new QGridLayout();
+ auto* grid = new QGridLayout();
- grid->addWidget(new QLabel(QString(_("Status")) + _(":")), 0, 0);
- // grid->addWidget(new QLabel(_("Fingerprint:")), 1, 0);
- grid->addWidget(new QLabel(_("Key not present in key list")), 0, 1);
+ grid->addWidget(new QLabel(tr("Status") + tr(":")), 0, 0);
+ // grid->addWidget(new QLabel(tr("Fingerprint:")), 1, 0);
+ grid->addWidget(new QLabel(tr("Key not present in key list")), 0, 1);
// grid->addWidget(new QLabel(signature->fpr), 1, 1);
grid->addWidget(import_button, 2, 0, 2, 1);
@@ -65,96 +70,91 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
break;
}
case GPG_ERR_NO_ERROR: {
- this->setTitle(QString(_("A Signature")) + ":");
- auto gird = create_key_info_grid(signature);
+ this->setTitle(tr("A Signature") + ":");
+ auto* gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
- vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.GetFingerprint().empty()) {
- vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.GetFingerprint().c_str()));
+ vbox->addWidget(new QLabel(tr("Key Information is NOT Available")));
+ if (!signature.GetFingerprint().isEmpty()) {
+ vbox->addWidget(new QLabel(tr("Fingerprint") + ": " +
+ signature.GetFingerprint()));
}
}
break;
}
case GPG_ERR_CERT_REVOKED: {
this->setTitle("An Error Signature");
- vbox->addWidget(
- new QLabel(QString(_("Status")) + ":" + _("Cert Revoked")));
- auto gird = create_key_info_grid(signature);
+ vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Cert Revoked")));
+ auto* gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
- vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.GetFingerprint().empty()) {
- vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.GetFingerprint().c_str()));
+ vbox->addWidget(new QLabel(tr("Key Information is NOT Available")));
+ if (!signature.GetFingerprint().isEmpty()) {
+ vbox->addWidget(new QLabel(tr("Fingerprint") + ": " +
+ signature.GetFingerprint()));
}
}
break;
}
case GPG_ERR_SIG_EXPIRED: {
this->setTitle("An Error Signature");
- vbox->addWidget(
- new QLabel(QString(_("Status")) + ":" + _("Signature Expired")));
- auto gird = create_key_info_grid(signature);
+ vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Signature Expired")));
+ auto* gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
- vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.GetFingerprint().empty()) {
- vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.GetFingerprint().c_str()));
+ vbox->addWidget(new QLabel(tr("Key Information is NOT Available")));
+ if (!signature.GetFingerprint().isEmpty()) {
+ vbox->addWidget(new QLabel(tr("Fingerprint") + ": " +
+ signature.GetFingerprint()));
}
}
break;
}
case GPG_ERR_KEY_EXPIRED: {
this->setTitle("An Error Signature");
- vbox->addWidget(
- new QLabel(QString(_("Status")) + ":" + _("Key Expired")));
- vbox->addWidget(
- new QLabel(QString(_("Status")) + ":" + _("Key Expired")));
- auto gird = create_key_info_grid(signature);
+ vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Key Expired")));
+ vbox->addWidget(new QLabel(tr("Status") + ":" + tr("Key Expired")));
+ auto* gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
- vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.GetFingerprint().empty()) {
- vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.GetFingerprint().c_str()));
+ vbox->addWidget(new QLabel(tr("Key Information is NOT Available")));
+ if (!signature.GetFingerprint().isEmpty()) {
+ vbox->addWidget(new QLabel(tr("Fingerprint") + ": " +
+ signature.GetFingerprint()));
}
}
break;
}
case GPG_ERR_GENERAL: {
this->setTitle("An Error Signature");
- vbox->addWidget(
- new QLabel(QString(_("Status")) + ":" + _("General Error")));
- auto gird = create_key_info_grid(signature);
+ vbox->addWidget(new QLabel(tr("Status") + ":" + tr("General Error")));
+ auto* gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
- vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.GetFingerprint().empty()) {
- vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.GetFingerprint().c_str()));
+ vbox->addWidget(new QLabel(tr("Key Information is NOT Available")));
+ if (!signature.GetFingerprint().isEmpty()) {
+ vbox->addWidget(new QLabel(tr("Fingerprint") + ": " +
+ signature.GetFingerprint()));
}
}
break;
}
default: {
this->setTitle("An Error Signature");
- this->setTitle(QString(_("Status")) + ":" + _("Unknown Error "));
- auto gird = create_key_info_grid(signature);
+ this->setTitle(tr("Status") + ":" + tr("Unknown Error "));
+ auto* gird = create_key_info_grid(signature);
if (gird != nullptr) {
vbox->addLayout(gird);
} else {
- vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.GetFingerprint().empty()) {
- vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.GetFingerprint().c_str()));
+ vbox->addWidget(new QLabel(tr("Key Information is NOT Available")));
+ if (!signature.GetFingerprint().isEmpty()) {
+ vbox->addWidget(new QLabel(tr("Fingerprint") + ": " +
+ signature.GetFingerprint()));
}
}
break;
@@ -164,59 +164,57 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
}
void VerifyKeyDetailBox::slot_import_form_key_server() {
- auto* importDialog = new KeyServerImportDialog(false, this);
- auto key_ids = std::make_unique<KeyIdArgsList>();
- key_ids->push_back(fpr_);
- importDialog->SlotImport(key_ids);
+ CommonUtils::GetInstance()->ImportKeyFromKeyServer({fpr_});
}
-QGridLayout* VerifyKeyDetailBox::create_key_info_grid(
- const GpgSignature& signature) {
- auto grid = new QGridLayout();
- GpgKey key = GpgKeyGetter::GetInstance().GetKey(fpr_);
+auto VerifyKeyDetailBox::create_key_info_grid(const GpgSignature& signature)
+ -> QGridLayout* {
+ auto* grid = new QGridLayout();
+ auto key = GpgKeyGetter::GetInstance().GetKey(fpr_);
if (!key.IsGood()) return nullptr;
- grid->addWidget(new QLabel(QString(_("Signer Name")) + ":"), 0, 0);
- grid->addWidget(new QLabel(QString(_("Signer Email")) + ":"), 1, 0);
- grid->addWidget(new QLabel(QString(_("Key's Fingerprint")) + ":"), 2, 0);
- grid->addWidget(new QLabel(QString(_("Valid")) + ":"), 3, 0);
- grid->addWidget(new QLabel(QString(_("Flags")) + ":"), 4, 0);
-
- grid->addWidget(new QLabel(QString::fromStdString(key.GetName())), 0, 1);
- grid->addWidget(new QLabel(QString::fromStdString(key.GetEmail())), 1, 1);
- grid->addWidget(new QLabel(beautify_fingerprint(fpr_).c_str()), 2, 1);
-
- if (signature.GetSummary() & GPGME_SIGSUM_VALID) {
- grid->addWidget(new QLabel(_("Fully Valid")), 3, 1);
+ grid->addWidget(new QLabel(tr("Signer Name") + ":"), 0, 0);
+ grid->addWidget(new QLabel(tr("Signer Email") + ":"), 1, 0);
+ grid->addWidget(new QLabel(tr("Key's Fingerprint") + ":"), 2, 0);
+ grid->addWidget(new QLabel(tr("Valid") + ":"), 3, 0);
+ grid->addWidget(new QLabel(tr("Flags") + ":"), 4, 0);
+
+ grid->addWidget(new QLabel(key.GetName()), 0, 1);
+ grid->addWidget(new QLabel(key.GetEmail()), 1, 1);
+ grid->addWidget(new QLabel(BeautifyFingerprint(fpr_)), 2, 1);
+
+ if ((signature.GetSummary() & GPGME_SIGSUM_VALID) != 0U) {
+ grid->addWidget(new QLabel(tr("Fully Valid")), 3, 1);
} else {
- grid->addWidget(new QLabel(_("NOT Fully Valid")), 3, 1);
+ grid->addWidget(new QLabel(tr("NOT Fully Valid")), 3, 1);
}
- std::stringstream text_stream;
+ QString buffer;
+ QTextStream text_stream(&buffer);
- if (signature.GetSummary() & GPGME_SIGSUM_GREEN) {
- text_stream << _("Good") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_GREEN) != 0U) {
+ text_stream << tr("Good") << " ";
}
- if (signature.GetSummary() & GPGME_SIGSUM_RED) {
- text_stream << _("Bad") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_RED) != 0U) {
+ text_stream << tr("Bad") << " ";
}
- if (signature.GetSummary() & GPGME_SIGSUM_SIG_EXPIRED) {
- text_stream << _("Expired") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_SIG_EXPIRED) != 0U) {
+ text_stream << tr("Expired") << " ";
}
- if (signature.GetSummary() & GPGME_SIGSUM_KEY_MISSING) {
- text_stream << _("Missing Key") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_KEY_MISSING) != 0U) {
+ text_stream << tr("Missing Key") << " ";
}
- if (signature.GetSummary() & GPGME_SIGSUM_KEY_REVOKED) {
- text_stream << _("Revoked Key") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_KEY_REVOKED) != 0U) {
+ text_stream << tr("Revoked Key") << " ";
}
- if (signature.GetSummary() & GPGME_SIGSUM_KEY_EXPIRED) {
- text_stream << _("Expired Key") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_KEY_EXPIRED) != 0U) {
+ text_stream << tr("Expired Key") << " ";
}
- if (signature.GetSummary() & GPGME_SIGSUM_CRL_MISSING) {
- text_stream << _("Missing CRL") << " ";
+ if ((signature.GetSummary() & GPGME_SIGSUM_CRL_MISSING) != 0U) {
+ text_stream << tr("Missing CRL") << " ";
}
- grid->addWidget(new QLabel(text_stream.str().c_str()), 4, 1);
+ grid->addWidget(new QLabel(text_stream.readAll()), 4, 1);
return grid;
}