From 3ec6373fc40ca5120e0417ffb41a6341272fd952 Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 23 Jan 2024 18:14:21 +0800 Subject: fix: solve issues at i18n support --- src/ui/UserInterfaceUtils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui/UserInterfaceUtils.cpp') diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 9e1d906f..b4e1b6c7 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -57,17 +57,17 @@ void show_verify_details(QWidget *parent, InfoBoardWidget *info_board, GpgError error, const GpgVerifyResult &verify_result) { // take out result info_board->ResetOptionActionsMenu(); - info_board->AddOptionalAction(QObject::tr("Show Verify Details"), [=]() { - VerifyDetailsDialog(parent, error, verify_result); - }); + info_board->AddOptionalAction( + QCoreApplication::tr("Show Verify Details"), + [=]() { VerifyDetailsDialog(parent, error, verify_result); }); } void import_unknown_key_from_keyserver( QWidget *parent, const GpgVerifyResultAnalyse &verify_res) { QMessageBox::StandardButton reply; reply = QMessageBox::question( - parent, QObject::tr("Public key not found locally"), - QObject::tr( + parent, QCoreApplication::tr("Public key not found locally"), + QCoreApplication::tr( "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?"), -- cgit v1.2.3 From 079b613d373c9ea317d49941728da146dad32356 Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 23 Jan 2024 20:27:30 +0800 Subject: feat: add a setting to enable gpgme debug log --- src/ui/UserInterfaceUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/UserInterfaceUtils.cpp') diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index b4e1b6c7..b915b5ab 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -408,7 +408,7 @@ void CommonUtils::SlotImportKeyFromKeyServer( target_keyserver_url.host() + "/pks/lookup?op=get&search=0x" + key_id + "&options=mr"); - GF_UI_LOG_DEBUG("request url: {}", req_url.toString().toStdString()); + GF_UI_LOG_DEBUG("request url: {}", req_url.toString()); // Waiting for reply QNetworkReply *reply = network_manager->get(QNetworkRequest(req_url)); -- cgit v1.2.3 From dfd95b751d44a749d6f2cb7edf941f978cb93ccb Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 29 Jan 2024 17:57:41 +0800 Subject: fix: solve reported issues --- src/ui/UserInterfaceUtils.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/ui/UserInterfaceUtils.cpp') diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index b915b5ab..c66b9845 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -28,6 +28,8 @@ #include "UserInterfaceUtils.h" +#include + #include "core/GpgConstants.h" #include "core/function/CoreSignalStation.h" #include "core/function/gpg/GpgKeyGetter.h" @@ -273,19 +275,25 @@ void CommonUtils::SlotImportKeys(QWidget *parent, const QString &in_buffer) { } void CommonUtils::SlotImportKeyFromFile(QWidget *parent) { - auto file_name = QFileDialog::getOpenFileName(this, tr("Open Key"), QString(), - tr("Key Files")) + - " (*.asc *.txt);;" + tr("Keyring files") + - " (*.gpg);;All Files (*)"; - if (!file_name.isNull()) { - QByteArray key_buffer; - if (!ReadFile(file_name, key_buffer)) { - QMessageBox::critical(nullptr, tr("File Open Failed"), - tr("Failed to open file: ") + file_name); - return; - } - SlotImportKeys(parent, key_buffer); + auto file_name = + QFileDialog::getOpenFileName(parent, tr("Open Key"), QString(), + tr("Keyring files") + " (*.asc *.gpg)"); + if (file_name.isEmpty()) return; + + QFileInfo file_info(file_name); + if (file_info.size() > static_cast(1024 * 1024)) { + QMessageBox::critical(parent, tr("Error"), + tr("The target file is too large for a keyring.")); + return; + } + + QByteArray key_buffer; + if (!ReadFile(file_name, key_buffer)) { + QMessageBox::critical(nullptr, tr("File Open Failed"), + tr("Failed to open file: ") + file_name); + return; } + SlotImportKeys(parent, key_buffer); } void CommonUtils::SlotImportKeyFromKeyServer(QWidget *parent) { -- cgit v1.2.3 From 635cfadda55fe79917c0ba96b589e2235571bab3 Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 30 Jan 2024 11:26:41 +0800 Subject: fix: add function to import key rev cert --- src/ui/UserInterfaceUtils.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/ui/UserInterfaceUtils.cpp') diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index c66b9845..ab8aeac9 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -281,6 +281,15 @@ void CommonUtils::SlotImportKeyFromFile(QWidget *parent) { if (file_name.isEmpty()) return; QFileInfo file_info(file_name); + + if (!file_info.isFile() || !file_info.isReadable()) { + QMessageBox::critical( + parent, tr("Error"), + tr("Cannot open this file. Please make sure that this " + "is a regular file and it's readable.")); + return; + } + if (file_info.size() > static_cast(1024 * 1024)) { QMessageBox::critical(parent, tr("Error"), tr("The target file is too large for a keyring.")); @@ -342,7 +351,7 @@ void CommonUtils::SlotExecuteGpgCommand( const QStringList &arguments, const std::function &interact_func) { QEventLoop looper; - auto dialog = new WaitingDialog(tr("Processing"), nullptr); + auto *dialog = new WaitingDialog(tr("Processing"), nullptr); dialog->show(); auto *gpg_process = new QProcess(&looper); gpg_process->setProcessChannelMode(QProcess::MergedChannels); @@ -506,7 +515,7 @@ void CommonUtils::SlotRestartApplication(int code) { } } -bool CommonUtils::isApplicationNeedRestart() { +auto CommonUtils::isApplicationNeedRestart() -> bool { return application_need_to_restart_at_once_; } -- cgit v1.2.3