diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpg/GpgContext.cpp | 2 | ||||
-rw-r--r-- | src/gpg/result_analyse/SignResultAnalyse.cpp | 5 | ||||
-rw-r--r-- | src/gpg/result_analyse/VerifyResultAnalyse.cpp | 12 | ||||
-rw-r--r-- | src/gpg/result_analyse/VerifyResultAnalyse.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 54 | ||||
-rw-r--r-- | src/ui/KeyServerImportDialog.cpp | 5 | ||||
-rw-r--r-- | src/ui/KeyUploadDialog.cpp | 10 | ||||
-rw-r--r-- | src/ui/MainWindow.cpp | 3 | ||||
-rw-r--r-- | src/ui/UserInterfaceUtils.cpp | 37 | ||||
-rw-r--r-- | src/ui/UserInterfaceUtils.h | 7 | ||||
-rw-r--r-- | src/ui/Wizard.cpp | 4 | ||||
-rw-r--r-- | src/ui/keygen/KeygenDialog.cpp | 2 | ||||
-rw-r--r-- | src/ui/keygen/SubkeyGenerateDialog.cpp | 6 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyPairDetailTab.cpp | 60 | ||||
-rw-r--r-- | src/ui/keypair_details/KeyPairDetailTab.h | 3 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowFileSlotFunction.cpp | 54 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowSlotFunction.cpp | 30 | ||||
-rw-r--r-- | src/ui/widgets/InfoBoardWidget.cpp | 20 | ||||
-rw-r--r-- | src/ui/widgets/KeyList.cpp | 2 |
19 files changed, 170 insertions, 148 deletions
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index b35615a6..a8b86619 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -51,7 +51,7 @@ GpgContext::GpgContext(bool independent_database, std::string db_path, if (_first) { /* Initialize the locale environment. */ - setlocale(LC_ALL, ""); + LOG(INFO) << "locale" << setlocale(LC_CTYPE, nullptr); gpgme_check_version(nullptr); gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr)); #ifdef LC_MESSAGES diff --git a/src/gpg/result_analyse/SignResultAnalyse.cpp b/src/gpg/result_analyse/SignResultAnalyse.cpp index 770594ca..a65c4a9d 100644 --- a/src/gpg/result_analyse/SignResultAnalyse.cpp +++ b/src/gpg/result_analyse/SignResultAnalyse.cpp @@ -76,8 +76,9 @@ void GpgFrontend::SignResultAnalyse::do_analyse() { << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << std::endl; stream << " " << _("Hash Algo") << ": " << gpgme_hash_algo_name(new_sign->hash_algo) << std::endl; - stream << " " << _("Date & Time") << ": " - << boost::posix_time::to_iso_string( + stream << " " << _("Date") << "(" << _("UTC") << ")" + << ": " + << boost::posix_time::to_iso_extended_string( boost::posix_time::from_time_t(new_sign->timestamp)) << std::endl; diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp index 3901b6c8..8f565b8e 100644 --- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp +++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp @@ -56,8 +56,9 @@ void GpgFrontend::VerifyResultAnalyse::do_analyse() { return; } - stream << "[>] " << _("Signed On") << " " - << boost::posix_time::to_iso_string( + stream << "[>] " << _("Signed On") << "(" << _("UTC") << ")" + << " " + << boost::posix_time::to_iso_extended_string( boost::posix_time::from_time_t(sign->timestamp)) << std::endl; @@ -186,15 +187,16 @@ bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream, stream << " " << _("Hash Algo") << ": " << gpgme_hash_algo_name(sign->hash_algo) << std::endl; if (sign->timestamp) - stream << " " << _("Date & Time") << ": " - << boost::posix_time::to_iso_string( + stream << " " << _("Date") << "(" << _("UTC") << ")" + << ": " + << boost::posix_time::to_iso_extended_string( boost::posix_time::from_time_t(sign->timestamp)) << std::endl; stream << std::endl; return keyFound; } -gpgme_signature_t GpgFrontend::VerifyResultAnalyse::GetSignatures() { +gpgme_signature_t GpgFrontend::VerifyResultAnalyse::GetSignatures() const { if (result) return result->signatures; else diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.h b/src/gpg/result_analyse/VerifyResultAnalyse.h index abd8f72e..8bf75f85 100644 --- a/src/gpg/result_analyse/VerifyResultAnalyse.h +++ b/src/gpg/result_analyse/VerifyResultAnalyse.h @@ -34,7 +34,7 @@ class VerifyResultAnalyse : public ResultAnalyse { public: explicit VerifyResultAnalyse(GpgError error, GpgVerifyResult result); - gpgme_signature_t GetSignatures(); + gpgme_signature_t GetSignatures() const; GpgVerifyResult TakeChargeOfResult(); diff --git a/src/main.cpp b/src/main.cpp index 066231fb..ed78231d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,11 @@ * */ +#include <stdlib.h> + #include <boost/locale.hpp> +#include <clocale> +#include <locale> #include "GpgFrontendBuildInfo.h" #include "ui/MainWindow.h" @@ -45,9 +49,6 @@ int main(int argc, char* argv[]) { // logging system init_logging(); - // i18n - init_locale(); - // App config QApplication::setApplicationVersion(BUILD_VERSION); QApplication::setApplicationName(PROJECT_NAME); @@ -74,19 +75,10 @@ int main(int argc, char* argv[]) { int return_from_event_loop_code; do { - QApplication::setQuitOnLastWindowClosed(true); + // i18n + init_locale(); - /** - * The function `gpgme_check_version' must be called before any other - * function in the library, because it initializes the thread support - * subsystem in GPGME. (from the info page) */ - gpgme_check_version(nullptr); - - /** set locale, because tests do also */ - gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr)); -#ifndef _WIN32 - gpgme_set_locale(nullptr, LC_MESSAGES, setlocale(LC_MESSAGES, nullptr)); -#endif + QApplication::setQuitOnLastWindowClosed(true); auto main_window = std::make_unique<GpgFrontend::UI::MainWindow>(); main_window->init(); @@ -139,11 +131,7 @@ void init_locale() { GpgFrontend::UI::GlobalSettingStation::GetInstance().Sync(); - auto* locale_name = setlocale(LC_ALL, nullptr); - boost::locale::generator gen; - // Create locale generator - std::locale::global(gen(locale_name)); - LOG(INFO) << "current system locale" << locale_name; + LOG(INFO) << "current system locale" << setlocale(LC_ALL, nullptr); // read from settings file std::string lang; @@ -151,21 +139,29 @@ void init_locale() { LOG(ERROR) << _("Could not read properly from configure file"); }; - LOG(INFO) << "lang" << lang; + LOG(INFO) << "lang from settings" << lang; LOG(INFO) << "PROJECT_NAME" << PROJECT_NAME; LOG(INFO) << "locales path" << GpgFrontend::UI::GlobalSettingStation::GetInstance() .GetLocaleDir() .c_str(); - if (!lang.empty()) lang += ".UTF8"; - // GNU gettext settings - locale_name = setlocale(LC_ALL, lang.c_str()); - if (locale_name == nullptr) { - LOG(WARNING) << "set locale name failed"; - } else { - LOG(INFO) << "locale name now" << locale_name; - } + if (lang.empty()) return; + std::string lc = lang.empty() ? "" : lang + ".UTF-8"; + + // set LC_ALL + auto* locale_name = setlocale(LC_ALL, lc.c_str()); + if (locale_name == nullptr) LOG(WARNING) << "set LC_ALL failed" << lc; + boost::locale::generator gen; + // Create locale generator + std::locale::global(gen(locale_name != nullptr ? lc : "")); + // set LANGUAGE + std::string language_env = getenv("LANGUAGE"); + language_env.insert(0, lang + ":"); + LOG(INFO) << "language env" << language_env; + if (setenv("LANGUAGE", language_env.c_str(), 1)) { + LOG(WARNING) << "set LANGUAGE failed" << language_env; + }; bindtextdomain(PROJECT_NAME, GpgFrontend::UI::GlobalSettingStation::GetInstance() diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp index 2b814693..844f2ae5 100644 --- a/src/ui/KeyServerImportDialog.cpp +++ b/src/ui/KeyServerImportDialog.cpp @@ -505,12 +505,13 @@ void KeyServerImportDialog::importKeys(ByteArrayPtr in_data) { GpgImportInformation result = GpgKeyImportExportor::GetInstance().ImportKey(std::move(in_data)); emit signalKeyImported(); + QWidget* _parent = qobject_cast<QWidget*>(parent()); if (mAutomatic) { - auto dialog = new KeyImportDetailDialog(result, true, nullptr); + auto dialog = new KeyImportDetailDialog(result, true, _parent); dialog->show(); this->accept(); } else { - auto dialog = new KeyImportDetailDialog(result, false, this); + auto dialog = new KeyImportDetailDialog(result, false, _parent); dialog->exec(); } } diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp index b2bfff6d..d9c97252 100644 --- a/src/ui/KeyUploadDialog.cpp +++ b/src/ui/KeyUploadDialog.cpp @@ -108,11 +108,11 @@ void KeyUploadDialog::slotUploadFinished() { auto* reply = qobject_cast<QNetworkReply*>(sender()); QByteArray response = reply->readAll(); - qDebug() << "Response: " << response.data(); + LOG(INFO) << "Response: " << response.toStdString(); auto error = reply->error(); if (error != QNetworkReply::NoError) { - qDebug() << "Error From Reply" << reply->errorString(); + LOG(INFO) << "Error From Reply" << reply->errorString().toStdString(); QString message; switch (error) { case QNetworkReply::ContentNotFoundError: @@ -130,9 +130,9 @@ void KeyUploadDialog::slotUploadFinished() { QMessageBox::critical(this, "Upload Failed", message); return; } else { - QMessageBox::information(this, "Upload Success", - "Upload Public Key Successfully"); - qDebug() << "Success while contacting keyserver!"; + QMessageBox::information(this, _("Upload Success"), + _("Upload Public Key Successfully")); + LOG(INFO) << "Success while contacting keyserver!"; } reply->deleteLater(); } diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index d13a0bd5..9aceed96 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -38,6 +38,7 @@ MainWindow::MainWindow() { } void MainWindow::init() noexcept { + LOG(INFO) << _("Called"); try { // Check Context Status if (!GpgContext::GetInstance().good()) { @@ -149,6 +150,8 @@ void MainWindow::init() noexcept { } void MainWindow::restoreSettings() { + LOG(INFO) << _("Called"); + try { auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 52fc8457..3c10009a 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -35,6 +35,41 @@ namespace GpgFrontend::UI { std::unique_ptr<GpgFrontend::UI::CommonUtils> GpgFrontend::UI::CommonUtils::_instance = nullptr; +void show_verify_details(QWidget* parent, InfoBoardWidget* info_board, + GpgError error, VerifyResultAnalyse& verify_res) { + // take out result + auto _result = verify_res.TakeChargeOfResult(); + info_board->resetOptionActionsMenu(); + info_board->addOptionalAction( + "Show Verify Details", [parent, error, _result_ptr = _result.get()]() { + VerifyDetailsDialog(parent, error, GpgVerifyResult(_result_ptr)); + }); + _result.reset(nullptr); +} + +void import_unknown_key_from_keyserver(QWidget* parent, + const VerifyResultAnalyse& verify_res) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question( + parent, _("Public key not found locally"), + _("There is no target public key content in local for GpgFrontend to " + "gather enough information about this Signature. Do you want to " + "import the public key from Keyserver now?"), + QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::Yes) { + auto dialog = KeyServerImportDialog(true, parent); + auto key_ids = std::make_unique<KeyIdArgsList>(); + auto* signature = verify_res.GetSignatures(); + while (signature != nullptr) { + LOG(INFO) << "signature fpr" << signature->fpr; + key_ids->push_back(signature->fpr); + signature = signature->next; + } + dialog.show(); + dialog.slotImport(key_ids); + } +} + void refresh_info_board(InfoBoardWidget* info_board, int status, const std::string& report_text) { if (status < 0) @@ -60,7 +95,7 @@ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board, LOG(INFO) << "process_result_analyse Started"; info_board->associateTabWidget(edit->tabWidget); - + refresh_info_board( info_board, std::min(result_analyse_a.getStatus(), result_analyse_b.getStatus()), diff --git a/src/ui/UserInterfaceUtils.h b/src/ui/UserInterfaceUtils.h index df974257..7b05658f 100644 --- a/src/ui/UserInterfaceUtils.h +++ b/src/ui/UserInterfaceUtils.h @@ -25,6 +25,7 @@ #ifndef GPGFRONTEND_USER_INTERFACE_UTILS_H #define GPGFRONTEND_USER_INTERFACE_UTILS_H +#include "gpg/result_analyse/VerifyResultAnalyse.h" #include "ui/GpgFrontendUI.h" namespace GpgFrontend { @@ -36,6 +37,12 @@ namespace GpgFrontend::UI { class InfoBoardWidget; class TextEdit; +void show_verify_details(QWidget* parent, InfoBoardWidget* info_board, + GpgError error, VerifyResultAnalyse& verify_res); + +void import_unknown_key_from_keyserver(QWidget* parent, + const VerifyResultAnalyse& verify_res); + void refresh_info_board(InfoBoardWidget* info_board, int status, const std::string& report_text); diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp index 9f0626ff..a8576627 100644 --- a/src/ui/Wizard.cpp +++ b/src/ui/Wizard.cpp @@ -248,10 +248,10 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { bottomLabel->setWordWrap(true); openHelpCheckBox = new QCheckBox(_("Open offline help.")); - openHelpCheckBox->setChecked(Qt::Checked); + openHelpCheckBox->setChecked(true); dontShowWizardCheckBox = new QCheckBox(_("Dont show the wizard again.")); - dontShowWizardCheckBox->setChecked(Qt::Checked); + dontShowWizardCheckBox->setChecked(true); registerField("showWizard", dontShowWizardCheckBox); // registerField("openHelp", openHelpCheckBox); diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp index bcbdbffa..98ea1d5c 100644 --- a/src/ui/keygen/KeygenDialog.cpp +++ b/src/ui/keygen/KeygenDialog.cpp @@ -114,7 +114,7 @@ void KeyGenDialog::slotKeyGenAccept() { [&]() { error = GpgKeyOpera::GetInstance().GenerateKey(genKeyInfo); }); thread->start(); - auto* dialog = new WaitingDialog("Generating", this); + auto* dialog = new WaitingDialog(_("Generating"), this); dialog->show(); while (thread->isRunning()) { diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp index 53ecd8e3..9bac076e 100644 --- a/src/ui/keygen/SubkeyGenerateDialog.cpp +++ b/src/ui/keygen/SubkeyGenerateDialog.cpp @@ -65,7 +65,7 @@ QGroupBox* SubkeyGenerateDialog::create_key_usage_group_box() { auto* groupBox = new QGroupBox(this); auto* grid = new QGridLayout(this); - groupBox->setTitle("Key Usage"); + groupBox->setTitle(_("Key Usage")); auto* encrypt = new QCheckBox(_("Encryption"), groupBox); encrypt->setTristate(false); @@ -239,12 +239,12 @@ void SubkeyGenerateDialog::slotKeyGenAccept() { GpgError error; auto thread = QThread::create([&]() { - LOG(INFO) << "SubkeyGenerateDialog::slotKeyGenAccept() Thread Started"; + LOG(INFO) << "Thread Started"; error = GpgKeyOpera::GetInstance().GenerateSubkey(mKey, genKeyInfo); }); thread->start(); - auto* dialog = new WaitingDialog("Generating", this); + auto* dialog = new WaitingDialog(_("Generating"), this); dialog->show(); while (thread->isRunning()) { diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp index 916aa6a1..e01e21cb 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.cpp +++ b/src/ui/keypair_details/KeyPairDetailTab.cpp @@ -83,14 +83,14 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) vboxKD->addWidget(new QLabel(QString(_("Master Key Existence")) + ": "), 8, 0); - vboxKD->addWidget(keySizeVarLabel, 2, 1); - vboxKD->addWidget(expireVarLabel, 6, 1); - vboxKD->addWidget(algorithmVarLabel, 1, 1); - vboxKD->addWidget(createdVarLabel, 5, 1); - vboxKD->addWidget(lastUpdateVarLabel, 7, 1); vboxKD->addWidget(keyidVarLabel, 0, 1); + vboxKD->addWidget(algorithmVarLabel, 1, 1); + vboxKD->addWidget(keySizeVarLabel, 2, 1); vboxKD->addWidget(usageVarLabel, 3, 1); vboxKD->addWidget(actualUsageVarLabel, 4, 1); + vboxKD->addWidget(createdVarLabel, 5, 1); + vboxKD->addWidget(expireVarLabel, 6, 1); + vboxKD->addWidget(lastUpdateVarLabel, 7, 1); vboxKD->addWidget(masterKeyExistVarLabel, 8, 1); ownerBox->setLayout(vboxOD); @@ -102,8 +102,10 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) fingerPrintVarLabel->setWordWrap(false); fingerPrintVarLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); fingerPrintVarLabel->setStyleSheet("margin-left: 0; margin-right: 5;"); + fingerPrintVarLabel->setAlignment(Qt::AlignCenter); auto* hboxFP = new QHBoxLayout(); + hboxFP->addStretch(); hboxFP->addWidget(fingerPrintVarLabel); auto* copyFingerprintButton = new QPushButton(_("Copy")); @@ -113,10 +115,11 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) SLOT(slotCopyFingerprint())); hboxFP->addWidget(copyFingerprintButton); + hboxFP->addStretch(); fingerprintBox->setLayout(hboxFP); - mvbox->addWidget(fingerprintBox); mvbox->addStretch(); + mvbox->addWidget(fingerprintBox); auto* opera_key_box = new QGroupBox(_("Operations")); auto* vbox_p_k = new QVBoxLayout(); @@ -180,28 +183,19 @@ KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent) mvbox->addWidget(opera_key_box); vbox_p_k->addWidget(modify_tofu_button); - if ((mKey.expired()) || (mKey.revoked())) { - auto* expBox = new QHBoxLayout(); - QPixmap pixmap(":warning.png"); + auto* expBox = new QHBoxLayout(); + QPixmap pixmap(":warning.png"); - auto* expLabel = new QLabel(); - auto* iconLabel = new QLabel(); - if (mKey.expired()) { - expLabel->setText(_("Warning: The Master Key has expired.")); - } - if (mKey.revoked()) { - expLabel->setText(_("Warning: The Master Key has been revoked")); - } + expLabel = new QLabel(); + iconLabel = new QLabel(); - iconLabel->setPixmap(pixmap.scaled(24, 24, Qt::KeepAspectRatio)); - QFont font = expLabel->font(); - font.setBold(true); - expLabel->setFont(font); - expLabel->setAlignment(Qt::AlignCenter); - expBox->addWidget(iconLabel); - expBox->addWidget(expLabel); - mvbox->addLayout(expBox); - } + iconLabel->setPixmap(pixmap.scaled(24, 24, Qt::KeepAspectRatio)); + expLabel->setAlignment(Qt::AlignCenter); + expBox->addStretch(); + expBox->addWidget(iconLabel); + expBox->addWidget(expLabel); + expBox->addStretch(); + mvbox->addLayout(expBox); // when key database updated connect(SignalStation::GetInstance(), SIGNAL(KeyDatabaseRefresh()), this, @@ -362,6 +356,20 @@ void KeyPairDetailTab::slotRefreshKeyInfo() { keySizeVarLabel->setText(key_size_val.c_str()); algorithmVarLabel->setText(key_algo_val.c_str()); fingerPrintVarLabel->setText(beautify_fingerprint(mKey.fpr()).c_str()); + + iconLabel->hide(); + expLabel->hide(); + + if (mKey.expired()) { + iconLabel->show(); + expLabel->show(); + expLabel->setText(_("Warning: The Master Key has expired.")); + } + if (mKey.revoked()) { + iconLabel->show(); + expLabel->show(); + expLabel->setText(_("Warning: The Master Key has been revoked.")); + } } void KeyPairDetailTab::createKeyServerOperaMenu() { diff --git a/src/ui/keypair_details/KeyPairDetailTab.h b/src/ui/keypair_details/KeyPairDetailTab.h index 0791344c..68ca1ebd 100644 --- a/src/ui/keypair_details/KeyPairDetailTab.h +++ b/src/ui/keypair_details/KeyPairDetailTab.h @@ -91,6 +91,9 @@ class KeyPairDetailTab : public QWidget { QLabel* actualUsageVarLabel; QLabel* masterKeyExistVarLabel; + QLabel* iconLabel; + QLabel* expLabel; + QMenu* keyServerOperaMenu{}; public: diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index c258e8b0..19be9769 100644 --- a/src/ui/main_window/MainWindowFileSlotFunction.cpp +++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp @@ -287,43 +287,15 @@ void MainWindow::slotFileVerify() { }); if (!if_error) { - auto resultAnalyse = VerifyResultAnalyse(error, std::move(result)); - resultAnalyse.analyse(); - process_result_analyse(edit, infoBoard, resultAnalyse); + auto result_analyse = VerifyResultAnalyse(error, std::move(result)); + result_analyse.analyse(); + process_result_analyse(edit, infoBoard, result_analyse); - if (resultAnalyse.getStatus() == -2) { - QMessageBox::StandardButton reply; - reply = QMessageBox::question( - this, _("Public key not found locally"), - _("There is no target public key content in local for GpgFrontend to " - "gather enough information about this Signature. Do you want to " - "import the public key from Keyserver now?"), - QMessageBox::Yes | QMessageBox::No); - if (reply == QMessageBox::Yes) { - qDebug() << "Yes was clicked"; - auto dialog = KeyServerImportDialog(true, this); - auto key_ids = std::make_unique<KeyIdArgsList>(); - auto* signature = resultAnalyse.GetSignatures(); - while (signature != nullptr) { - LOG(INFO) << "signature fpr" << signature->fpr; - key_ids->push_back(signature->fpr); - signature = signature->next; - } - dialog.slotImport(key_ids); - dialog.show(); - - } else { - qDebug() << "Yes was *not* clicked"; - } - } + if (result_analyse.getStatus() == -2) + import_unknown_key_from_keyserver(this, result_analyse); - // if (resultAnalyse.getStatus() >= 0) { - // infoBoard->resetOptionActionsMenu(); - // infoBoard->addOptionalAction( - // "Show Verify Details", [this, error, &result]() { - // VerifyDetailsDialog(this, mKeyList, error, result); - // }); - // } + if (result_analyse.getStatus() >= 0) + show_verify_details(this, infoBoard, error, result_analyse); fileTreeView->update(); } else { @@ -452,13 +424,11 @@ void MainWindow::slotFileDecryptVerify() { verify_res.analyse(); process_result_analyse(edit, infoBoard, decrypt_res, verify_res); - // if (verify_res.getStatus() >= 0) { - // infoBoard->resetOptionActionsMenu(); - // infoBoard->addOptionalAction( - // "Show Verify Details", [this, error, v_result]() { - // VerifyDetailsDialog(this, mCtx, mKeyList, error, v_result); - // }); - // } + if (verify_res.getStatus() == -2) + import_unknown_key_from_keyserver(this, verify_res); + + if (verify_res.getStatus() >= 0) + show_verify_details(this, infoBoard, error, verify_res); fileTreeView->update(); } else { diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp index f2b98be1..4ad33ac3 100644 --- a/src/ui/main_window/MainWindowSlotFunction.cpp +++ b/src/ui/main_window/MainWindowSlotFunction.cpp @@ -249,17 +249,11 @@ void MainWindow::slotVerify() { result_analyse.analyse(); process_result_analyse(edit, infoBoard, result_analyse); - if (result_analyse.getStatus() >= 0) { - // take out result - auto _result = result_analyse.TakeChargeOfResult(); - auto _result_ptr = _result.get(); - _result.reset(nullptr); - infoBoard->resetOptionActionsMenu(); - infoBoard->addOptionalAction( - "Show Verify Details", [this, error, _result_ptr]() { - VerifyDetailsDialog(this, error, GpgVerifyResult(_result_ptr)); - }); - } + if (result_analyse.getStatus() == -2) + import_unknown_key_from_keyserver(this, result_analyse); + + if (result_analyse.getStatus() >= 0) + show_verify_details(this, infoBoard, error, result_analyse); } } @@ -431,14 +425,12 @@ void MainWindow::slotDecryptVerify() { if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR) edit->slotFillTextEditWithText(QString::fromStdString(*decrypted)); - // if (verify_res.getStatus() >= 0) { - // infoBoard->resetOptionActionsMenu(); - // infoBoard->addOptionalAction( - // "Show Verify Details", [this, error, v_result]() { - // VerifyDetailsDialog(this, mCtx, mKeyList, error, - // v_result); - // }); - // } + if (verify_res.getStatus() == -2) + import_unknown_key_from_keyserver(this, verify_res); + + if (verify_res.getStatus() >= 0) + show_verify_details(this, infoBoard, error, verify_res); + } else { QMessageBox::critical(this, _("Error"), _("An error occurred during operation.")); diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp index 7b7ea38e..e0de75f9 100644 --- a/src/ui/widgets/InfoBoardWidget.cpp +++ b/src/ui/widgets/InfoBoardWidget.cpp @@ -46,10 +46,11 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) detailMenu->addAction(importFromKeyserverAct); importFromKeyserverAct->setVisible(false); - auto* actionButtonMenu = new QWidget(); - actionButtonMenu->setContentsMargins(0, 0, 0, 0); - actionButtonMenu->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - actionButtonMenu->setFixedHeight(40); + auto* action_button_menu = new QWidget(); + action_button_menu->setContentsMargins(0, 0, 0, 0); + action_button_menu->setSizePolicy(QSizePolicy::Preferred, + QSizePolicy::Minimum); + action_button_menu->setFixedHeight(40); actionButtonLayout = new QHBoxLayout(); actionButtonLayout->setContentsMargins(0, 0, 0, 0); @@ -64,7 +65,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) bottom_layout->addWidget(label); actionButtonLayout->addStretch(); bottom_layout->addLayout(actionButtonLayout); - actionButtonMenu->setLayout(bottom_layout); + action_button_menu->setLayout(bottom_layout); QFrame* line; line = new QFrame(this); @@ -78,8 +79,8 @@ InfoBoardWidget::InfoBoardWidget(QWidget* parent, KeyList* keyList) notificationWidgetLayout->addWidget(infoBoard); notificationWidgetLayout->setStretchFactor(infoBoard, 10); - notificationWidgetLayout->addWidget(actionButtonMenu); - notificationWidgetLayout->setStretchFactor(actionButtonMenu, 1); + notificationWidgetLayout->addWidget(action_button_menu); + notificationWidgetLayout->setStretchFactor(action_button_menu, 1); notificationWidgetLayout->addWidget(line); notificationWidgetLayout->setStretchFactor(line, 1); notificationWidgetLayout->addStretch(0); @@ -186,7 +187,8 @@ void InfoBoardWidget::addOptionalAction(const QString& name, * Delete All item in actionButtonLayout */ void InfoBoardWidget::resetOptionActionsMenu() { - deleteWidgetsInLayout(actionButtonLayout, 2); + // skip stretch + deleteWidgetsInLayout(actionButtonLayout, 1); } void InfoBoardWidget::slotReset() { @@ -199,6 +201,8 @@ void InfoBoardWidget::slotReset() { * @param layout target layout */ void InfoBoardWidget::deleteWidgetsInLayout(QLayout* layout, int start_index) { + LOG(INFO) << "Called"; + QLayoutItem* item; while ((item = layout->layout()->takeAt(start_index)) != nullptr) { layout->removeItem(item); diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 83ffcbb5..5931e337 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -39,7 +39,7 @@ KeyList::KeyList(KeyListRow::KeyType selectType, QWidget* parent) : QWidget(parent) { init(); - addListGroupTab("Default", selectType, infoType, filter); + addListGroupTab(_("Default"), selectType, infoType, filter); } void KeyList::init() { |