diff options
author | saturneric <[email protected]> | 2024-01-23 12:27:30 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-23 12:27:30 +0000 |
commit | 079b613d373c9ea317d49941728da146dad32356 (patch) | |
tree | a37a567cf27368f445b0365008e96c7a9ae958f1 | |
parent | fix: solve issues at i18n support (diff) | |
download | GpgFrontend-079b613d373c9ea317d49941728da146dad32356.tar.gz GpgFrontend-079b613d373c9ea317d49941728da146dad32356.zip |
feat: add a setting to enable gpgme debug log
24 files changed, 140 insertions, 133 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 24a0ae7b..04531faf 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -38,7 +38,6 @@ #include "core/function/gpg/GpgKeyGetter.h" #include "core/module/ModuleManager.h" #include "core/thread/Task.h" -#include "core/thread/TaskRunner.h" #include "core/thread/TaskRunnerGetter.h" #include "core/utils/CommonUtils.h" #include "core/utils/GpgUtils.h" diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp index 118f4784..1ca47480 100644 --- a/src/core/function/gpg/GpgKeyOpera.cpp +++ b/src/core/function/gpg/GpgKeyOpera.cpp @@ -130,7 +130,7 @@ void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key, // Code From Gpg4Win while (proc->canReadLine()) { const QString line = QString::fromUtf8(proc->readLine()).trimmed(); - GF_CORE_LOG_DEBUG("line: {}", line.toStdString()); + GF_CORE_LOG_DEBUG("line: {}", line); if (line == QLatin1String("[GNUPG:] GET_BOOL gen_revoke.okay")) { proc->write("y\n"); } else if (line == QLatin1String("[GNUPG:] GET_LINE " diff --git a/src/init.cpp b/src/init.cpp index 8e61f4a7..2d7760fe 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -30,6 +30,7 @@ #include "core/GpgCoreInit.h" #include "core/function/GlobalSettingStation.h" +#include "core/function/gpg/GpgAdvancedOperator.h" #include "core/thread/TaskRunnerGetter.h" #include "core/utils/LogUtils.h" #include "module/GpgFrontendModuleInit.h" @@ -54,11 +55,19 @@ int setenv(const char *name, const char *value, int overwrite) { #endif void InitLoggingSystem(const GFCxtSPtr &ctx) { +#ifdef DEBUG RegisterSyncLogger("core", ctx->log_level); RegisterSyncLogger("main", ctx->log_level); RegisterSyncLogger("module", ctx->log_level); RegisterSyncLogger("ui", ctx->log_level); RegisterSyncLogger("test", ctx->log_level); +#else + RegisterAsyncLogger("core", ctx->log_level); + RegisterAsyncLogger("main", ctx->log_level); + RegisterAsyncLogger("module", ctx->log_level); + RegisterAsyncLogger("ui", ctx->log_level); + RegisterAsyncLogger("test", ctx->log_level); +#endif } void InitGlobalPathEnv() { @@ -86,6 +95,15 @@ void InitGlobalPathEnv() { QString modified_path_value = getenv("PATH"); GF_MAIN_LOG_DEBUG("Modified System PATH: {}", modified_path_value); } + + if (GlobalSettingStation::GetInstance() + .GetSettings() + .value("gnupg/enable_gpgme_debug_log", false) + .toBool()) { + qputenv("GPGME_DEBUG", + QString("9:%1").arg(QDir::currentPath() + "/gpgme.log").toUtf8()); + GF_CORE_LOG_DEBUG("GPGME_DEBUG ENV: {}", qgetenv("GPGME_DEBUG")); + } } void InitGlobalBasicalEnv(const GFCxtWPtr &p_ctx, bool gui_mode) { @@ -149,6 +167,14 @@ void ShutdownGlobalBasicalEnv(const GFCxtWPtr &p_ctx) { return; } + // clear password cache + if (GlobalSettingStation::GetInstance() + .GetSettings() + .value("basic/clear_gpg_password_cache", false) + .toBool()) { + GpgAdvancedOperator::ClearGpgPasswordCache([](int, DataObjectPtr) {}); + } + Thread::TaskRunnerGetter::GetInstance().StopAllTeakRunner(); DestroyGpgFrontendCore(); diff --git a/src/module/integrated/version_checking_module/VersionCheckTask.cpp b/src/module/integrated/version_checking_module/VersionCheckTask.cpp index 8699b7b6..83844af8 100644 --- a/src/module/integrated/version_checking_module/VersionCheckTask.cpp +++ b/src/module/integrated/version_checking_module/VersionCheckTask.cpp @@ -59,38 +59,44 @@ auto VersionCheckTask::Run() -> int { } void VersionCheckTask::slot_parse_latest_version_info() { - version_.current_version = current_version_; - - if (latest_reply_ == nullptr || - latest_reply_->error() != QNetworkReply::NoError) { - MODULE_LOG_ERROR("latest version request error"); + if (latest_reply_ == nullptr) { + version_.latest_version = current_version_; + version_.loading_done = false; + } else if (latest_reply_->error() != QNetworkReply::NoError) { + MODULE_LOG_ERROR("latest version request error: ", + latest_reply_->errorString()); version_.latest_version = current_version_; } else { latest_reply_bytes_ = latest_reply_->readAll(); auto latest_reply_json = QJsonDocument::fromJson(latest_reply_bytes_); - QString latest_version = latest_reply_json["tag_name"].toString(); - MODULE_LOG_INFO("latest version from Github: {}", latest_version); - - QRegularExpression re(R"(^[vV](\d+\.)?(\d+\.)?(\*|\d+))"); - auto version_match = re.match(latest_version); - if (version_match.hasMatch()) { - latest_version = version_match.captured(0); - MODULE_LOG_DEBUG("latest version matched: {}", latest_version); + if (latest_reply_json.isObject()) { + QString latest_version = latest_reply_json["tag_name"].toString(); + + QRegularExpression re(R"(^[vV](\d+\.)?(\d+\.)?(\*|\d+))"); + auto version_match = re.match(latest_version); + if (version_match.hasMatch()) { + latest_version = version_match.captured(0); + MODULE_LOG_INFO("latest version from github: {}", latest_version); + } else { + latest_version = current_version_; + MODULE_LOG_WARN("latest version unknown, set to current version: {}", + current_version_); + } + + bool prerelease = latest_reply_json["prerelease"].toBool(); + bool draft = latest_reply_json["draft"].toBool(); + auto publish_date = latest_reply_json["published_at"].toString(); + auto release_note = latest_reply_json["body"].toString(); + version_.latest_version = latest_version; + version_.latest_prerelease_version_from_remote = prerelease; + version_.latest_draft_from_remote = draft; + version_.publish_date = publish_date; + version_.release_note = release_note; } else { - latest_version = current_version_; - MODULE_LOG_WARN("latest version unknown"); + MODULE_LOG_WARN("cannot parse data got from github: {}", + latest_reply_bytes_); } - - bool prerelease = latest_reply_json["prerelease"].toBool(); - bool draft = latest_reply_json["draft"].toBool(); - auto publish_date = latest_reply_json["published_at"].toString(); - auto release_note = latest_reply_json["body"].toString(); - version_.latest_version = latest_version; - version_.latest_prerelease_version_from_remote = prerelease; - version_.latest_draft_from_remote = draft; - version_.publish_date = publish_date; - version_.release_note = release_note; } if (latest_reply_ != nullptr) { @@ -119,22 +125,14 @@ void VersionCheckTask::slot_parse_current_version_info() { if (current_reply_ == nullptr) { // loading done version_.loading_done = false; - return; - } - - if (current_reply_->error() != QNetworkReply::NoError) { - if (current_reply_ != nullptr) { - MODULE_LOG_ERROR("current version request network error: {}", - current_reply_->errorString()); - } else { - MODULE_LOG_ERROR( - "current version request network error, null reply object"); - } - version_.current_version_publish_in_remote = false; + } else if (current_reply_->error() != QNetworkReply::NoError) { + MODULE_LOG_ERROR("current version request network error: {}", + current_reply_->errorString()); // loading done version_.loading_done = true; + version_.current_version_publish_in_remote = false; } else { version_.current_version_publish_in_remote = true; current_reply_bytes_ = current_reply_->readAll(); @@ -148,7 +146,8 @@ void VersionCheckTask::slot_parse_current_version_info() { // loading done version_.loading_done = true; } else { - MODULE_LOG_WARN("cannot parse data got from github"); + MODULE_LOG_WARN("cannot parse data got from github: {}", + current_reply_bytes_); } } 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)); diff --git a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp b/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp index 9e3573f5..9c108674 100644 --- a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp @@ -49,6 +49,7 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) ui_->asciiModeCheckBox->setText(tr("No ASCII Mode")); ui_->usePinentryAsPasswordInputDialogCheckBox->setText( tr("Use Pinentry as Password Input Dialog")); + ui_->gpgmeDebugLogCheckBox->setText(tr("Enable GpgME Debug Log")); ui_->useCustomGnuPGInstallPathCheckBox->setText(tr("Use Custom GnuPG")); ui_->useCustomGnuPGInstallPathButton->setText(tr("Select GnuPG Path")); ui_->keyDatabseUseCustomCheckBox->setText( @@ -103,14 +104,6 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) return; } - auto settings = GlobalSettingStation::GetInstance().GetSettings(); - - // update settings - if (!settings.contains("basic/custom_key_database_path")) { - settings.setValue("basic/custom_key_database_path", - selected_custom_key_database_path); - } - // announce the restart this->slot_set_restart_needed(kDeepRestartCode); @@ -134,12 +127,6 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) return; } - auto settings = GlobalSettingStation::GetInstance().GetSettings(); - if (!settings.contains("basic/custom_gnupg_install_path")) { - settings.setValue("basic/custom_gnupg_install_path", - selected_custom_gnupg_install_path); - } - // announce the restart this->slot_set_restart_needed(kDeepRestartCode); @@ -149,11 +136,21 @@ GnuPGControllerDialog::GnuPGControllerDialog(QWidget* parent) }); connect(ui_->usePinentryAsPasswordInputDialogCheckBox, - &QCheckBox::stateChanged, this, [=](int state) { + &QCheckBox::stateChanged, this, [=](int) { // announce the restart this->slot_set_restart_needed(kDeepRestartCode); }); + connect(ui_->gpgmeDebugLogCheckBox, &QCheckBox::stateChanged, this, [=](int) { + // announce the restart + this->slot_set_restart_needed(kDeepRestartCode); + }); + + connect(ui_->asciiModeCheckBox, &QCheckBox::stateChanged, this, [=](int) { + // announce the restart + this->slot_set_restart_needed(kDeepRestartCode); + }); + #ifndef MACOS connect(ui_->buttonBox, &QDialogButtonBox::accepted, this, &GnuPGControllerDialog::SlotAccept); @@ -263,36 +260,35 @@ void GnuPGControllerDialog::slot_update_custom_gnupg_install_path_label( } void GnuPGControllerDialog::set_settings() { - auto& settings_station = GlobalSettingStation::GetInstance(); + auto settings = GlobalSettingStation::GetInstance().GetSettings(); - bool non_ascii_when_export = settings_station.GetSettings() - .value("basic/non_ascii_when_export", true) - .toBool(); - GF_UI_LOG_DEBUG("non_ascii_when_export: {}", non_ascii_when_export); + bool non_ascii_when_export = + settings.value("basic/non_ascii_when_export", true).toBool(); if (non_ascii_when_export) ui_->asciiModeCheckBox->setCheckState(Qt::Checked); bool const use_custom_key_database_path = - settings_station.GetSettings() - .value("basic/use_custom_key_database_path", false) - .toBool(); + settings.value("basic/use_custom_key_database_path", false).toBool(); if (use_custom_key_database_path) { ui_->keyDatabseUseCustomCheckBox->setCheckState(Qt::Checked); } + bool const enable_gpgme_debug_log = + settings.value("gnupg/enable_gpgme_debug_log", false).toBool(); + if (enable_gpgme_debug_log) { + ui_->gpgmeDebugLogCheckBox->setCheckState(Qt::Checked); + } + this->slot_update_custom_key_database_path_label( ui_->keyDatabseUseCustomCheckBox->checkState()); bool const use_custom_gnupg_install_path = - settings_station.GetSettings() - .value("basic/use_custom_gnupg_install_path", false) - .toBool(); + settings.value("basic/use_custom_gnupg_install_path", false).toBool(); if (use_custom_gnupg_install_path) { ui_->useCustomGnuPGInstallPathCheckBox->setCheckState(Qt::Checked); } bool const use_pinentry_as_password_input_dialog = - settings_station.GetSettings() - .value("basic/use_pinentry_as_password_input_dialog", false) + settings.value("basic/use_pinentry_as_password_input_dialog", false) .toBool(); if (use_pinentry_as_password_input_dialog) { ui_->usePinentryAsPasswordInputDialogCheckBox->setCheckState(Qt::Checked); @@ -316,6 +312,12 @@ void GnuPGControllerDialog::apply_settings() { ui_->useCustomGnuPGInstallPathCheckBox->isChecked()); settings.setValue("basic/use_pinentry_as_password_input_dialog", ui_->usePinentryAsPasswordInputDialogCheckBox->isChecked()); + settings.setValue("gnupg/enable_gpgme_debug_log", + ui_->gpgmeDebugLogCheckBox->isChecked()); + settings.setValue("basic/custom_key_database_path", + ui_->currentKeyDatabasePathLabel->text()); + settings.setValue("basic/custom_gnupg_install_path", + ui_->currentCustomGnuPGInstallPathLabel->text()); } int GnuPGControllerDialog::get_restart_needed() const { diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp index 599d512d..296df539 100644 --- a/src/ui/dialog/import_export/KeyServerImportDialog.cpp +++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp @@ -411,7 +411,7 @@ void KeyServerImportDialog::slot_import_finished( set_loading(false); if (!success) { - GF_UI_LOG_ERROR("Error From Reply", buffer.toStdString()); + GF_UI_LOG_ERROR("error from reply: {}", buffer); set_message(err_msg, true); return; } diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp index 903b2e14..f59f9daa 100644 --- a/src/ui/dialog/import_export/KeyUploadDialog.cpp +++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp @@ -136,11 +136,11 @@ void KeyUploadDialog::slot_upload_finished() { this->close(); QByteArray response = reply->readAll(); - GF_UI_LOG_DEBUG("response: {}", response.toStdString()); + GF_UI_LOG_DEBUG("upload response: {}", response); auto error = reply->error(); if (error != QNetworkReply::NoError) { - GF_UI_LOG_DEBUG("error from reply: {}", reply->errorString().toStdString()); + GF_UI_LOG_DEBUG("error from reply: {}", reply->errorString()); QString message; switch (error) { case QNetworkReply::ContentNotFoundError: diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp index 7756ac37..be9cd9d2 100644 --- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp @@ -352,7 +352,7 @@ void KeyPairOperaTab::slot_modify_tofu_policy() { this, tr("Modify TOFU Policy(Default is Auto)"), tr("Policy for the Key Pair:"), items, 0, false, &ok); if (ok && !item.isEmpty()) { - GF_UI_LOG_DEBUG("selected policy: {}", item.toStdString()); + GF_UI_LOG_DEBUG("selected policy: {}", item); gpgme_tofu_policy_t tofu_policy = GPGME_TOFU_POLICY_AUTO; if (item == tr("Policy Auto")) { tofu_policy = GPGME_TOFU_POLICY_AUTO; diff --git a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp index 22d1db2a..51956379 100644 --- a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp +++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp @@ -58,9 +58,9 @@ KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id, } void KeySetExpireDateDialog::slot_confirm() { - GF_UI_LOG_DEBUG("called: {} {}", - ui_->dateEdit->date().toString().toStdString(), - ui_->timeEdit->time().toString().toStdString()); + GF_UI_LOG_DEBUG("confirm called, date: {}, time: {}", + ui_->dateEdit->date().toString(), + ui_->timeEdit->time().toString()); auto datetime = QDateTime(ui_->dateEdit->date(), ui_->timeEdit->time()); std::unique_ptr<QDateTime> expires = nullptr; if (ui_->noExpirationCheckBox->checkState() == Qt::Unchecked) { diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp index 2af56906..a26ddf0b 100644 --- a/src/ui/dialog/settings/SettingsDialog.cpp +++ b/src/ui/dialog/settings/SettingsDialog.cpp @@ -129,7 +129,7 @@ auto SettingsDialog::ListLanguages() -> QHash<QString, QString> { QStringList filenames = QDir(QLatin1String(":/i18n")).entryList(); for (const auto& file : filenames) { - GF_UI_LOG_DEBUG("get locale from locale directory: {}", file.toStdString()); + GF_UI_LOG_DEBUG("get locale from locale directory: {}", file); auto start = file.indexOf('.') + 1; auto end = file.lastIndexOf('.'); diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp index 44c66e10..2f3e171e 100644 --- a/src/ui/dialog/settings/SettingsGeneral.cpp +++ b/src/ui/dialog/settings/SettingsGeneral.cpp @@ -124,7 +124,7 @@ void GeneralTab::SetSettings() { QString lang_key = settings.value("basic/lang").toString(); QString lang_value = lang_.value(lang_key); - GF_UI_LOG_DEBUG("lang settings current: {}", lang_value.toStdString()); + GF_UI_LOG_DEBUG("lang settings current: {}", lang_value); if (!lang_.empty()) { ui_->langSelectBox->setCurrentIndex( ui_->langSelectBox->findText(lang_value)); diff --git a/src/ui/function/GenerateRevokeCertification.cpp b/src/ui/function/GenerateRevokeCertification.cpp index b4a6c934..9f8afcff 100644 --- a/src/ui/function/GenerateRevokeCertification.cpp +++ b/src/ui/function/GenerateRevokeCertification.cpp @@ -63,7 +63,7 @@ auto GenerateRevokeCertification::Exec(const GpgKey& key, // Code From Gpg4Win while (proc->canReadLine()) { const QString line = QString::fromUtf8(proc->readLine()).trimmed(); - GF_UI_LOG_DEBUG("line: {}", line.toStdString()); + GF_UI_LOG_DEBUG("line: {}", line); if (line == QLatin1String("[GNUPG:] GET_BOOL gen_revoke.okay")) { proc->write("y\n"); } else if (line == QLatin1String("[GNUPG:] GET_LINE " diff --git a/src/ui/function/RaisePinentry.cpp b/src/ui/function/RaisePinentry.cpp index 64e10c48..447f15a1 100644 --- a/src/ui/function/RaisePinentry.cpp +++ b/src/ui/function/RaisePinentry.cpp @@ -55,8 +55,8 @@ auto RaisePinentry::Exec() -> int { GF_UI_LOG_DEBUG( "setting pinetry's arguments, context uids: {}, passphrase info: {}, " "prev_was_bad: {}", - context_->GetUidsInfo().toStdString(), - context_->GetPassphraseInfo().toStdString(), context_->IsPreWasBad()); + context_->GetUidsInfo(), context_->GetPassphraseInfo(), + context_->IsPreWasBad()); bool ask_for_new = context_->IsAskForNew() && context_->GetPassphraseInfo().isEmpty() && diff --git a/src/ui/function/SetOwnerTrustLevel.cpp b/src/ui/function/SetOwnerTrustLevel.cpp index 360abfce..87f4cb61 100644 --- a/src/ui/function/SetOwnerTrustLevel.cpp +++ b/src/ui/function/SetOwnerTrustLevel.cpp @@ -54,7 +54,7 @@ auto SetOwnerTrustLevel::Exec(const QString& key_id) -> bool { key.GetOwnerTrustLevel(), false, &ok); if (ok && !item.isEmpty()) { - GF_UI_LOG_DEBUG("selected owner trust policy: {}", item.toStdString()); + GF_UI_LOG_DEBUG("selected owner trust policy: {}", item); int trust_level = 0; // Unknown Level if (item == tr("Ultimate")) { trust_level = 5; diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index ef7910ab..3090bdb7 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -123,21 +123,6 @@ void MainWindow::Init() noexcept { edit_->CurTextPage()->setFocus(); - // before application exit - connect(qApp, &QCoreApplication::aboutToQuit, this, []() { - GF_UI_LOG_DEBUG("about to quit process started"); - - if (GlobalSettingStation::GetInstance() - .GetSettings() - .value("basic/clear_gpg_password_cache", false) - .toBool()) { - GpgFrontend::GpgAdvancedOperator::ClearGpgPasswordCache( - [](int, DataObjectPtr) { - - }); - } - }); - Module::ListenRTPublishEvent( this, "com.bktus.gpgfrontend.module.integrated.version-checking", "version.loading_done", diff --git a/src/ui/thread/ListedKeyServerTestTask.cpp b/src/ui/thread/ListedKeyServerTestTask.cpp index 4ab7ba5f..f50a66ab 100644 --- a/src/ui/thread/ListedKeyServerTestTask.cpp +++ b/src/ui/thread/ListedKeyServerTestTask.cpp @@ -47,20 +47,19 @@ auto GpgFrontend::UI::ListedKeyServerTestTask::Run() -> int { size_t index = 0; for (const auto& url : urls_) { auto key_url = QUrl{url}; - GF_UI_LOG_DEBUG("key server request: {}", key_url.host().toStdString()); + GF_UI_LOG_DEBUG("key server request: {}", key_url.host()); auto* network_reply = network_manager_->get(QNetworkRequest{key_url}); auto* timer = new QTimer(this); connect(network_reply, &QNetworkReply::finished, this, [this, index, network_reply]() { - GF_UI_LOG_DEBUG("key server domain reply: {}", - urls_[index].toStdString()); + GF_UI_LOG_DEBUG("key server domain reply: {}", urls_[index]); this->slot_process_network_reply(index, network_reply); }); connect(timer, &QTimer::timeout, this, [this, index, network_reply]() { - GF_UI_LOG_DEBUG("timeout for key server: {}", urls_[index].toStdString()); + GF_UI_LOG_DEBUG("timeout for key server: {}", urls_[index]); if (network_reply->isRunning()) { network_reply->abort(); this->slot_process_network_reply(index, network_reply); diff --git a/src/ui/thread/ProxyConnectionTestTask.cpp b/src/ui/thread/ProxyConnectionTestTask.cpp index 6b0993fe..b681ca6d 100644 --- a/src/ui/thread/ProxyConnectionTestTask.cpp +++ b/src/ui/thread/ProxyConnectionTestTask.cpp @@ -45,13 +45,12 @@ auto GpgFrontend::UI::ProxyConnectionTestTask::Run() -> int { connect(network_reply, &QNetworkReply::finished, this, [this, network_reply]() { - GF_UI_LOG_DEBUG("key server domain reply: {} received", - url_.toStdString()); + GF_UI_LOG_DEBUG("key server domain reply: {} received", url_); this->slot_process_network_reply(network_reply); }); connect(timer, &QTimer::timeout, this, [this, network_reply]() { - GF_UI_LOG_DEBUG("timeout for key server: {}", url_.toStdString()); + GF_UI_LOG_DEBUG("timeout for key server: {}", url_); if (network_reply->isRunning()) { network_reply->abort(); this->slot_process_network_reply(network_reply); @@ -65,8 +64,8 @@ auto GpgFrontend::UI::ProxyConnectionTestTask::Run() -> int { void GpgFrontend::UI::ProxyConnectionTestTask::slot_process_network_reply( QNetworkReply* reply) { auto buffer = reply->readAll(); - GF_UI_LOG_DEBUG("key server domain reply: {}, buffer size: {}", - url_.toStdString(), buffer.size()); + GF_UI_LOG_DEBUG("key server domain reply: {}, buffer size: {}", url_, + buffer.size()); if (reply->error() == QNetworkReply::NoError && !buffer.isEmpty()) { result_ = "Reachable"; diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp index 0c299a97..450acbad 100644 --- a/src/ui/widgets/FileTreeView.cpp +++ b/src/ui/widgets/FileTreeView.cpp @@ -159,7 +159,7 @@ auto FileTreeView::SlotDeleteSelectedItem() -> void { if (ret == QMessageBox::Cancel) return; - GF_UI_LOG_DEBUG("delete item: {}", data.toString().toStdString()); + GF_UI_LOG_DEBUG("delete item: {}", data.toString()); if (!dir_model_->remove(index)) { QMessageBox::critical(this, tr("Error"), @@ -194,25 +194,17 @@ void FileTreeView::SlotMkdirBelowAtSelectedItem() { } void FileTreeView::SlotTouch() { -#ifdef WINDOWS - auto root_path_str = dir_model_->rootPath().toStdU16String(); -#else - auto root_path_str = dir_model_->rootPath().toStdString(); -#endif - std::filesystem::path root_path(root_path_str); + auto root_path = dir_model_->rootPath(); QString new_file_name; bool ok; + new_file_name = QInputDialog::getText( this, tr("Create Empty File"), tr("Filename (you can given extension)"), QLineEdit::Normal, new_file_name, &ok); if (ok && !new_file_name.isEmpty()) { -#ifdef WINDOWS - auto file_path = root_path / new_file_name.toStdU16String(); -#else - auto file_path = root_path / new_file_name.toStdString(); -#endif - QFile new_file(file_path.u8string().c_str()); + auto file_path = root_path + "/" + new_file_name; + QFile new_file(file_path); if (!new_file.open(QIODevice::WriteOnly | QIODevice::NewOnly)) { QMessageBox::critical(this, tr("Error"), tr("Unable to create the file.")); @@ -257,7 +249,7 @@ void FileTreeView::keyPressEvent(QKeyEvent* event) { void FileTreeView::SlotOpenSelectedItemBySystemApplication() { QFileInfo const info(selected_path_); if (info.isDir()) { - const auto file_path = info.filePath().toUtf8().toStdString(); + const auto file_path = info.filePath().toUtf8(); QDesktopServices::openUrl(QUrl::fromLocalFile(selected_path_)); } else { @@ -377,11 +369,11 @@ void FileTreeView::slot_calculate_hash() { CommonUtils::WaitForOpera( this->parentWidget(), tr("Calculating"), [=](const OperaWaitingHd& hd) { RunOperaAsync( - [=](DataObjectPtr data_object) { + [=](const DataObjectPtr& data_object) { data_object->Swap({CalculateHash(this->GetSelectedPath())}); return 0; }, - [hd](int rtn, DataObjectPtr data_object) { + [hd](int rtn, const DataObjectPtr& data_object) { hd(); if (rtn < 0 || !data_object->Check<QString>()) { return; diff --git a/src/ui/widgets/FileTreeView.h b/src/ui/widgets/FileTreeView.h index 9e9b03dd..d2272f90 100644 --- a/src/ui/widgets/FileTreeView.h +++ b/src/ui/widgets/FileTreeView.h @@ -38,14 +38,14 @@ class FileTreeView : public QTreeView { /** * @brief Get the Current Path object * - * @return std::filesystem::path + * @return QString */ auto GetCurrentPath() -> QString; /** * @brief Get the Selected Path object * - * @return std::filesystem::path + * @return QString */ auto GetSelectedPath() -> QString; @@ -53,7 +53,7 @@ class FileTreeView : public QTreeView { * @brief Get the Path By Click Point object * * @param point - * @return std::filesystem::path + * @return QString */ auto GetPathByClickPoint(const QPoint& point) -> QString; diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp index fdec1e50..d1a006c5 100644 --- a/src/ui/widgets/InfoBoardWidget.cpp +++ b/src/ui/widgets/InfoBoardWidget.cpp @@ -115,7 +115,7 @@ void InfoBoardWidget::AssociateTabWidget(QTabWidget* tab) { void InfoBoardWidget::AddOptionalAction(const QString& name, const std::function<void()>& action) { - GF_UI_LOG_DEBUG("add option: {}", name.toStdString()); + GF_UI_LOG_DEBUG("add option action: {}", name); auto* action_button = new QPushButton(name); auto* layout = new QHBoxLayout(); layout->setContentsMargins(5, 0, 5, 0); @@ -165,7 +165,7 @@ void InfoBoardWidget::slot_copy() { void InfoBoardWidget::slot_save() { auto file_path = QFileDialog::getSaveFileName( this, tr("Save Information Board's Content"), {}, tr("Text (*.txt)")); - GF_UI_LOG_DEBUG("file path: {}", file_path.toStdString()); + GF_UI_LOG_DEBUG("file path: {}", file_path); if (file_path.isEmpty()) return; QFile file(file_path); diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 58e53ae0..4fb883db 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -115,7 +115,7 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id, KeyListRow::KeyType selectType, KeyListColumn::InfoType infoType, const KeyTable::KeyTableFilter filter) { - GF_UI_LOG_DEBUG("add tab: {}", name.toStdString()); + GF_UI_LOG_DEBUG("add list group tab: {}", name); auto* key_list = new QTableWidget(this); if (m_key_list_ == nullptr) { @@ -315,7 +315,7 @@ void KeyList::contextMenuEvent(QContextMenuEvent* event) { QString current_tab_widget_obj_name = ui_->keyGroupTab->widget(ui_->keyGroupTab->currentIndex())->objectName(); GF_UI_LOG_DEBUG("current tab widget object name: {}", - current_tab_widget_obj_name.toStdString()); + current_tab_widget_obj_name); if (current_tab_widget_obj_name == "favourite") { QList<QAction*> actions = popup_menu_->actions(); for (QAction* action : actions) { @@ -388,7 +388,7 @@ void KeyList::dropEvent(QDropEvent* event) { QFile file; file.setFileName(tmp.toLocalFile()); if (!file.open(QIODevice::ReadOnly)) { - GF_UI_LOG_ERROR("couldn't open file: {}", tmp.toString().toStdString()); + GF_UI_LOG_ERROR("couldn't open file: {}", tmp.toString()); } QByteArray in_buffer = file.readAll(); this->import_keys(in_buffer); diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index 59890465..3a56b90d 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -120,8 +120,7 @@ void TextEdit::SlotNewFileTab() { void TextEdit::SlotOpenFile(const QString& path) { QFile file(path); - GF_UI_LOG_DEBUG("main window editor is opening file at path: {}", - path.toStdString()); + GF_UI_LOG_DEBUG("main window editor is opening file at path: {}", path); auto result = file.open(QIODevice::ReadOnly | QIODevice::Text); if (result) { auto* page = new PlainTextEditorPage(path); @@ -511,7 +510,7 @@ QHash<int, QString> TextEdit::UnsavedDocuments() const { if (ep != nullptr && ep->ReadDone() && ep->GetTextPage()->document()->isModified()) { QString doc_name = tab_widget_->tabText(i); - GF_UI_LOG_DEBUG("unsaved: {}", doc_name.toStdString()); + GF_UI_LOG_DEBUG("unsaved: {}", doc_name); // remove * before name of modified doc doc_name.remove(0, 2); diff --git a/ui/GnuPGControllerDialog.ui b/ui/GnuPGControllerDialog.ui index 968aba70..6141062d 100644 --- a/ui/GnuPGControllerDialog.ui +++ b/ui/GnuPGControllerDialog.ui @@ -38,6 +38,13 @@ </property> </widget> </item> + <item> + <widget class="QCheckBox" name="gpgmeDebugLogCheckBox"> + <property name="text"> + <string>Enable GpgME Debug Log</string> + </property> + </widget> + </item> </layout> </item> </layout> |