From 95997d27106daf91336847f50efaaa32279b7fc7 Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 16 Oct 2023 17:54:05 +0800 Subject: fix: check and update copyright at files --- src/ui/dialog/help/AboutDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 111a77af..098c7ad0 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Saturneric + * Copyright (C) 2021 Saturneric * * 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 starting on May 12, 2021. + * Saturneric starting on May 12, 2021. * * SPDX-License-Identifier: GPL-3.0-or-later * -- cgit v1.2.3 From 52f809414e485f81e58a0aa3fec99bd27e38c9cf Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 24 Oct 2023 15:55:29 +0800 Subject: feat: try to use GRT as a info exchange center of modules and ui --- src/ui/dialog/help/AboutDialog.cpp | 65 ++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 21 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 098c7ad0..acd76c97 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -30,9 +30,13 @@ #include +#include + #include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" +#include "core/module/ModuleManager.h" #include "core/thread/TaskRunnerGetter.h" +#include "spdlog/spdlog.h" #include "ui/dialog/help/GnupgTab.h" #include "ui/thread/VersionCheckTask.h" @@ -73,10 +77,7 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) this->show(); } -void AboutDialog::showEvent(QShowEvent* ev) { - QDialog::showEvent(ev); - update_tab_->getLatestVersion(); -} +void AboutDialog::showEvent(QShowEvent* ev) { QDialog::showEvent(ev); } InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); @@ -203,28 +204,50 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { setLayout(layout); } -void UpdateTab::getLatestVersion() { - this->pb_->setHidden(false); - - SPDLOG_DEBUG("try to get latest version"); +void UpdateTab::slot_show_version_status() { + this->pb_->setHidden(true); + SPDLOG_DEBUG("loading version info from rt"); - auto* version_task = new VersionCheckTask(); + auto is_loading_done = + std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( + "__module_com.bktus.gpgfrontend.module.integrated." + "versionchecking", + "version.loading_done")); - connect(version_task, &VersionCheckTask::SignalUpgradeVersion, this, - &UpdateTab::slot_show_version_status); + if (!is_loading_done) { + SPDLOG_DEBUG("version info loading havn't been done yet"); + this->pb_->setHidden(false); + } - Thread::TaskRunnerGetter::GetInstance() - .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network) - ->PostTask(version_task); -} + auto is_need_upgrade = + std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( + "__module_com.bktus.gpgfrontend.module.integrated." + "versionchecking", + "version.need_upgrade")); + + auto is_current_a_withdrawn_version = + std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( + "__module_com.bktus.gpgfrontend.module.integrated." + "versionchecking", + "version.current_a_withdrawn_version")); + + auto is_current_version_released = + std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( + "__module_com.bktus.gpgfrontend.module.integrated." + "versionchecking", + "version.current_version_released")); + + auto latest_version = std::any_cast( + Module::ModuleManager::GetInstance()->RetrieveRTValue( + "__module_com.bktus.gpgfrontend.module.integrated." + "versionchecking", + "version.latest_version")); -void UpdateTab::slot_show_version_status(const SoftwareVersion& version) { - this->pb_->setHidden(true); latest_version_label_->setText( "
" + QString(_("Latest Version From Github")) + ": " + - version.latest_version.c_str() + "
"); + latest_version.c_str() + ""); - if (version.NeedUpgrade()) { + if (is_need_upgrade) { upgrade_label_->setText( "
" + QString(_("The current version is less than the latest version on " @@ -235,7 +258,7 @@ void UpdateTab::slot_show_version_status(const SoftwareVersion& version) { _("Here") + " " + _("to download the latest stable version.") + "
"); upgrade_label_->show(); - } else if (version.VersionWithDrawn()) { + } else if (is_current_a_withdrawn_version) { upgrade_label_->setText( "
" + QString(_("This version has serious problems and has been withdrawn. " @@ -246,7 +269,7 @@ void UpdateTab::slot_show_version_status(const SoftwareVersion& version) { _("Here") + " " + _("to download the latest stable version.") + "
"); upgrade_label_->show(); - } else if (!version.CurrentVersionReleased()) { + } else if (!is_current_version_released) { upgrade_label_->setText( "
" + QString(_("This version has not been released yet, it may be a beta " -- cgit v1.2.3 From fa2e87a48acbc32650ca9db073b991729dfba622 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Tue, 24 Oct 2023 21:22:13 +0800 Subject: feat: use module instead of integrated code at version checking task --- src/ui/dialog/help/AboutDialog.cpp | 78 ++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 33 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index acd76c97..77363bef 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -30,15 +30,14 @@ #include +#include #include #include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" +#include "core/module/Module.h" #include "core/module/ModuleManager.h" -#include "core/thread/TaskRunnerGetter.h" -#include "spdlog/spdlog.h" #include "ui/dialog/help/GnupgTab.h" -#include "ui/thread/VersionCheckTask.h" namespace GpgFrontend::UI { @@ -204,44 +203,57 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { setLayout(layout); } +void UpdateTab::showEvent(QShowEvent* event) { + QWidget::showEvent(event); + SPDLOG_DEBUG("loading version loading info from rt"); + + auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.loading_done", false); + + if (!is_loading_done) { + Module::TriggerEvent("CHECK_APPLICATION_VERSION"); + } else { + slot_show_version_status(); + } +} + void UpdateTab::slot_show_version_status() { - this->pb_->setHidden(true); SPDLOG_DEBUG("loading version info from rt"); - auto is_loading_done = - std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( - "__module_com.bktus.gpgfrontend.module.integrated." - "versionchecking", - "version.loading_done")); + auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.loading_done", false); if (!is_loading_done) { - SPDLOG_DEBUG("version info loading havn't been done yet"); + SPDLOG_DEBUG("version info loading havn't been done yet."); this->pb_->setHidden(false); + return; + } else { + this->pb_->setHidden(true); } - auto is_need_upgrade = - std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( - "__module_com.bktus.gpgfrontend.module.integrated." - "versionchecking", - "version.need_upgrade")); - - auto is_current_a_withdrawn_version = - std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( - "__module_com.bktus.gpgfrontend.module.integrated." - "versionchecking", - "version.current_a_withdrawn_version")); - - auto is_current_version_released = - std::any_cast(Module::ModuleManager::GetInstance()->RetrieveRTValue( - "__module_com.bktus.gpgfrontend.module.integrated." - "versionchecking", - "version.current_version_released")); - - auto latest_version = std::any_cast( - Module::ModuleManager::GetInstance()->RetrieveRTValue( - "__module_com.bktus.gpgfrontend.module.integrated." - "versionchecking", - "version.latest_version")); + auto is_need_upgrade = Module::RetrieveRTValueTypedOrDefault<>( + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.need_upgrade", false); + + auto is_current_a_withdrawn_version = Module::RetrieveRTValueTypedOrDefault<>( + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.current_a_withdrawn_version", false); + + auto is_current_version_released = Module::RetrieveRTValueTypedOrDefault<>( + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.current_version_released", false); + + auto latest_version = Module::RetrieveRTValueTypedOrDefault<>( + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.latest_version", std::string{}); latest_version_label_->setText( "
" + QString(_("Latest Version From Github")) + ": " + -- cgit v1.2.3 From 124929609eabff19359caad276a10f1026793c0f Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 25 Oct 2023 18:26:26 +0800 Subject: fix: solve some code tidy issues --- src/ui/dialog/help/AboutDialog.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 77363bef..9948f1fc 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -37,6 +37,7 @@ #include "core/function/GlobalSettingStation.h" #include "core/module/Module.h" #include "core/module/ModuleManager.h" +#include "core/thread/TaskRunnerGetter.h" #include "ui/dialog/help/GnupgTab.h" namespace GpgFrontend::UI { -- cgit v1.2.3 From b7ceed0b87752077fe19fefe9b0df8ec27ce0531 Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 25 Oct 2023 22:28:25 +0800 Subject: feat: moving gnupg info gathering logic to a new module --- src/ui/dialog/help/AboutDialog.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 9948f1fc..ae708e46 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -80,6 +80,10 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) void AboutDialog::showEvent(QShowEvent* ev) { QDialog::showEvent(ev); } InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { + const auto gpgme_version = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.version", std::string{"2.0.0"}); + SPDLOG_DEBUG("got gpgme version from rt: {}", gpgme_version); + auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); auto* text = new QString( "

" + qApp->applicationName() + "

" + @@ -98,11 +102,8 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { _("or send a mail to my mailing list at") + " eric@bktus.com." + "

" + _("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + - " " + _("and") + " " + "GPGME" + " " + - GpgFrontend::GpgContext::GetInstance() - .GetInfo(false) - .GpgMEVersion.c_str() + - "
" + _("Built at") + " " + BUILD_TIMESTAMP + "
"); + " " + _("and") + " " + "GPGME" + " " + gpgme_version.c_str() + "
" + + _("Built at") + " " + BUILD_TIMESTAMP + "
"); auto* layout = new QGridLayout(); auto* pixmapLabel = new QLabel(); @@ -214,6 +215,17 @@ void UpdateTab::showEvent(QShowEvent* event) { "version.loading_done", false); if (!is_loading_done) { + Module::ListenRTPublishEvent( + this, + Module::GetRealModuleIdentifier( + "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "version.loading_done", + [=](Module::Namespace, Module::Key, int, std::any) { + SPDLOG_DEBUG( + "versionchecking version.loading_done changed, calling slot " + "version upgrade"); + this->slot_show_version_status(); + }); Module::TriggerEvent("CHECK_APPLICATION_VERSION"); } else { slot_show_version_status(); @@ -222,6 +234,7 @@ void UpdateTab::showEvent(QShowEvent* event) { void UpdateTab::slot_show_version_status() { SPDLOG_DEBUG("loading version info from rt"); + this->pb_->setHidden(true); auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( Module::GetRealModuleIdentifier( @@ -230,10 +243,7 @@ void UpdateTab::slot_show_version_status() { if (!is_loading_done) { SPDLOG_DEBUG("version info loading havn't been done yet."); - this->pb_->setHidden(false); return; - } else { - this->pb_->setHidden(true); } auto is_need_upgrade = Module::RetrieveRTValueTypedOrDefault<>( -- cgit v1.2.3 From fd46d4667611c0db9cea3f06205727399b6fb5fd Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 29 Oct 2023 02:46:15 +0800 Subject: refactor: start to tidy up code using clang-tidy --- src/ui/dialog/help/AboutDialog.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index ae708e46..f308b75c 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -160,9 +160,8 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { pixmap_label->setPixmap(*pixmap); layout->addWidget(pixmap_label, 0, 0, 1, -1, Qt::AlignCenter); - current_version_ = "v" + QString::number(VERSION_MAJOR) + "." + - QString::number(VERSION_MINOR) + "." + - QString::number(VERSION_PATCH); + current_version_ = + QString("v") + VERSION_MAJOR + "." + VERSION_MINOR + "." + VERSION_PATCH; auto tips_label = new QLabel(); tips_label->setText( -- cgit v1.2.3 From 9d16c9d5dfcd1171d713c3ba87a69d0f0fac4f33 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Wed, 29 Nov 2023 17:49:54 +0800 Subject: fix: repair gnupg info listing funtion --- src/ui/dialog/help/AboutDialog.cpp | 55 ++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 32 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index f308b75c..8d5ad896 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -37,7 +37,6 @@ #include "core/function/GlobalSettingStation.h" #include "core/module/Module.h" #include "core/module/ModuleManager.h" -#include "core/thread/TaskRunnerGetter.h" #include "ui/dialog/help/GnupgTab.h" namespace GpgFrontend::UI { @@ -64,13 +63,13 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) tab_widget->setCurrentIndex(defaultIndex); } - auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); - connect(buttonBox, &QDialogButtonBox::accepted, this, &AboutDialog::close); + auto* button_box = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(button_box, &QDialogButtonBox::accepted, this, &AboutDialog::close); - auto* mainLayout = new QVBoxLayout; - mainLayout->addWidget(tab_widget); - mainLayout->addWidget(buttonBox); - setLayout(mainLayout); + auto* main_layout = new QVBoxLayout; + main_layout->addWidget(tab_widget); + main_layout->addWidget(button_box); + setLayout(main_layout); this->resize(550, 650); this->setMinimumWidth(450); @@ -106,14 +105,14 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { _("Built at") + " " + BUILD_TIMESTAMP + ""); auto* layout = new QGridLayout(); - auto* pixmapLabel = new QLabel(); - pixmapLabel->setPixmap(*pixmap); - layout->addWidget(pixmapLabel, 0, 0, 1, -1, Qt::AlignCenter); - auto* aboutLabel = new QLabel(); - aboutLabel->setText(*text); - aboutLabel->setWordWrap(true); - aboutLabel->setOpenExternalLinks(true); - layout->addWidget(aboutLabel, 1, 0, 1, -1); + auto* pixmap_label = new QLabel(); + pixmap_label->setPixmap(*pixmap); + layout->addWidget(pixmap_label, 0, 0, 1, -1, Qt::AlignCenter); + auto* about_label = new QLabel(); + about_label->setText(*text); + about_label->setWordWrap(true); + about_label->setOpenExternalLinks(true); + layout->addWidget(about_label, 1, 0, 1, -1); layout->addItem( new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1, 1, 1); @@ -141,7 +140,7 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { main_layout->addWidget(label); main_layout->addStretch(); - auto notice_label = new QLabel( + auto* notice_label = new QLabel( _("If you think there are any problems with the translation, why not " "participate in the translation work? If you want to participate, " "please " @@ -163,7 +162,7 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { current_version_ = QString("v") + VERSION_MAJOR + "." + VERSION_MINOR + "." + VERSION_PATCH; - auto tips_label = new QLabel(); + auto* tips_label = new QLabel(); tips_label->setText( "
" + QString(_("It is recommended that you always check the version " @@ -209,15 +208,12 @@ void UpdateTab::showEvent(QShowEvent* event) { SPDLOG_DEBUG("loading version loading info from rt"); auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "com.bktus.gpgfrontend.module.integrated.version-checking", "version.loading_done", false); if (!is_loading_done) { Module::ListenRTPublishEvent( - this, - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + this, "com.bktus.gpgfrontend.module.integrated.version-checking", "version.loading_done", [=](Module::Namespace, Module::Key, int, std::any) { SPDLOG_DEBUG( @@ -236,8 +232,7 @@ void UpdateTab::slot_show_version_status() { this->pb_->setHidden(true); auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "com.bktus.gpgfrontend.module.integrated.version-checking", "version.loading_done", false); if (!is_loading_done) { @@ -246,23 +241,19 @@ void UpdateTab::slot_show_version_status() { } auto is_need_upgrade = Module::RetrieveRTValueTypedOrDefault<>( - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "com.bktus.gpgfrontend.module.integrated.version-checking", "version.need_upgrade", false); auto is_current_a_withdrawn_version = Module::RetrieveRTValueTypedOrDefault<>( - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "com.bktus.gpgfrontend.module.integrated.version-checking", "version.current_a_withdrawn_version", false); auto is_current_version_released = Module::RetrieveRTValueTypedOrDefault<>( - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "com.bktus.gpgfrontend.module.integrated.version-checking", "version.current_version_released", false); auto latest_version = Module::RetrieveRTValueTypedOrDefault<>( - Module::GetRealModuleIdentifier( - "com.bktus.gpgfrontend.module.integrated.versionchecking"), + "com.bktus.gpgfrontend.module.integrated.version-checking", "version.latest_version", std::string{}); latest_version_label_->setText( -- cgit v1.2.3 From 644aa4397b03dbef73f8bfedc13925b51cad836b Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 5 Jan 2024 20:55:15 +0800 Subject: feat: integrate logging api to core --- src/ui/dialog/help/AboutDialog.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 8d5ad896..7c534cbf 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -57,7 +57,7 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) tab_widget->addTab(update_tab_, _("Update")); connect(tab_widget, &QTabWidget::currentChanged, this, - [&](int index) { SPDLOG_DEBUG("current index: {}", index); }); + [&](int index) { GF_UI_LOG_DEBUG("current index: {}", index); }); if (defaultIndex < tab_widget->count() && defaultIndex >= 0) { tab_widget->setCurrentIndex(defaultIndex); @@ -81,7 +81,7 @@ void AboutDialog::showEvent(QShowEvent* ev) { QDialog::showEvent(ev); } InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { const auto gpgme_version = Module::RetrieveRTValueTypedOrDefault<>( "core", "gpgme.version", std::string{"2.0.0"}); - SPDLOG_DEBUG("got gpgme version from rt: {}", gpgme_version); + GF_UI_LOG_DEBUG("got gpgme version from rt: {}", gpgme_version); auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); auto* text = new QString( @@ -205,7 +205,7 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { void UpdateTab::showEvent(QShowEvent* event) { QWidget::showEvent(event); - SPDLOG_DEBUG("loading version loading info from rt"); + GF_UI_LOG_DEBUG("loading version loading info from rt"); auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( "com.bktus.gpgfrontend.module.integrated.version-checking", @@ -216,7 +216,7 @@ void UpdateTab::showEvent(QShowEvent* event) { this, "com.bktus.gpgfrontend.module.integrated.version-checking", "version.loading_done", [=](Module::Namespace, Module::Key, int, std::any) { - SPDLOG_DEBUG( + GF_UI_LOG_DEBUG( "versionchecking version.loading_done changed, calling slot " "version upgrade"); this->slot_show_version_status(); @@ -228,7 +228,7 @@ void UpdateTab::showEvent(QShowEvent* event) { } void UpdateTab::slot_show_version_status() { - SPDLOG_DEBUG("loading version info from rt"); + GF_UI_LOG_DEBUG("loading version info from rt"); this->pb_->setHidden(true); auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( @@ -236,7 +236,7 @@ void UpdateTab::slot_show_version_status() { "version.loading_done", false); if (!is_loading_done) { - SPDLOG_DEBUG("version info loading havn't been done yet."); + GF_UI_LOG_DEBUG("version info loading havn't been done yet."); return; } -- cgit v1.2.3 From bf538056b24a68b8fd235b1c50991ee8eb46a776 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 12 Jan 2024 14:02:37 +0800 Subject: refactor: use QString instead of std::string and improve threading system --- src/ui/dialog/help/AboutDialog.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 7c534cbf..e38777f3 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -80,7 +80,7 @@ void AboutDialog::showEvent(QShowEvent* ev) { QDialog::showEvent(ev); } InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { const auto gpgme_version = Module::RetrieveRTValueTypedOrDefault<>( - "core", "gpgme.version", std::string{"2.0.0"}); + "core", "gpgme.version", QString{"2.0.0"}); GF_UI_LOG_DEBUG("got gpgme version from rt: {}", gpgme_version); auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); @@ -101,7 +101,7 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { _("or send a mail to my mailing list at") + " eric@bktus.com." + "

" + _("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + - " " + _("and") + " " + "GPGME" + " " + gpgme_version.c_str() + "
" + + " " + _("and") + " " + "GPGME" + " " + gpgme_version + "
" + _("Built at") + " " + BUILD_TIMESTAMP + "
"); auto* layout = new QGridLayout(); @@ -124,7 +124,7 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { QFile translators_qfile; auto translators_file = GlobalSettingStation::GetInstance().GetResourceDir() / "TRANSLATORS"; - translators_qfile.setFileName(translators_file.u8string().c_str()); + translators_qfile.setFileName(translators_file); #ifdef LINUX if (!translators_qfile.exists()) { translators_qfile.setFileName("/usr/local/share/GpgFrontend/TRANSLATORS"); @@ -254,11 +254,11 @@ void UpdateTab::slot_show_version_status() { auto latest_version = Module::RetrieveRTValueTypedOrDefault<>( "com.bktus.gpgfrontend.module.integrated.version-checking", - "version.latest_version", std::string{}); + "version.latest_version", QString{}); - latest_version_label_->setText( - "
" + QString(_("Latest Version From Github")) + ": " + - latest_version.c_str() + "
"); + latest_version_label_->setText("
" + + QString(_("Latest Version From Github")) + + ": " + latest_version + "
"); if (is_need_upgrade) { upgrade_label_->setText( -- cgit v1.2.3 From 6983b5c1dd82d159236ebd06cf17f071cc9c1ee9 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 12 Jan 2024 23:08:38 +0800 Subject: refactor: remove boost and use QString instead of std::filesystem::path --- src/ui/dialog/help/AboutDialog.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index e38777f3..6f8dedc2 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -121,10 +121,8 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { } TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { - QFile translators_qfile; - auto translators_file = - GlobalSettingStation::GetInstance().GetResourceDir() / "TRANSLATORS"; - translators_qfile.setFileName(translators_file); + QFile translators_qfile(GlobalSettingStation::GetInstance().GetResourceDir() + + "/TRANSLATORS"); #ifdef LINUX if (!translators_qfile.exists()) { translators_qfile.setFileName("/usr/local/share/GpgFrontend/TRANSLATORS"); @@ -143,8 +141,7 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { auto* notice_label = new QLabel( _("If you think there are any problems with the translation, why not " "participate in the translation work? If you want to participate, " - "please " - "read the document or contact me via email."), + "please read the document or contact me via email."), this); notice_label->setWordWrap(true); main_layout->addWidget(notice_label); -- cgit v1.2.3 From 620ae9e7c1a8b2db2515c080416cb592066e5fec Mon Sep 17 00:00:00 2001 From: saturneric Date: Tue, 16 Jan 2024 21:35:59 +0800 Subject: refactor: remove libgettext from project --- src/ui/dialog/help/AboutDialog.cpp | 84 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 43 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 6f8dedc2..54deed22 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -31,11 +31,9 @@ #include #include -#include #include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" -#include "core/module/Module.h" #include "core/module/ModuleManager.h" #include "ui/dialog/help/GnupgTab.h" @@ -43,7 +41,7 @@ namespace GpgFrontend::UI { AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : GeneralDialog(typeid(AboutDialog).name(), parent) { - this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName()); + this->setWindowTitle(tr("About") + " " + qApp->applicationName()); auto* tab_widget = new QTabWidget; auto* info_tab = new InfoTab(); @@ -51,10 +49,10 @@ AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) auto* translators_tab = new TranslatorsTab(); update_tab_ = new UpdateTab(); - tab_widget->addTab(info_tab, _("About GpgFrontend")); - tab_widget->addTab(gnupg_tab, _("GnuPG")); - tab_widget->addTab(translators_tab, _("Translators")); - tab_widget->addTab(update_tab_, _("Update")); + tab_widget->addTab(info_tab, tr("About GpgFrontend")); + tab_widget->addTab(gnupg_tab, tr("GnuPG")); + tab_widget->addTab(translators_tab, tr("Translators")); + tab_widget->addTab(update_tab_, tr("Update")); connect(tab_widget, &QTabWidget::currentChanged, this, [&](int index) { GF_UI_LOG_DEBUG("current index: {}", index); }); @@ -83,26 +81,26 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { "core", "gpgme.version", QString{"2.0.0"}); GF_UI_LOG_DEBUG("got gpgme version from rt: {}", gpgme_version); - auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); + auto* pixmap = new QPixmap(":/icons/gpgfrontend-logo.png"); auto* text = new QString( "

" + qApp->applicationName() + "

" + "
" + qApp->applicationVersion() + "
" + "
" + GIT_VERSION + "
" + "
" + - _("GpgFrontend is an easy-to-use, compact, cross-platform, " - "and installation-free GnuPG Frontend." - "It visualizes most of the common operations of GnuPG." - "GpgFrontend is licensed under the GPLv3") + + tr("GpgFrontend is an easy-to-use, compact, cross-platform, " + "and installation-free GnuPG Frontend." + "It visualizes most of the common operations of GnuPG." + "GpgFrontend is licensed under the GPLv3") + "

" "" + - _("Developer:") + "
" + "Saturneric" + "

" + - _("If you have any questions or suggestions, raise an issue at") + + tr("Developer:") + "

" + "Saturneric" + "

" + + tr("If you have any questions or suggestions, raise an issue at") + "
" " GitHub " + - _("or send a mail to my mailing list at") + " eric@bktus.com." + "

" + - _("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + - " " + _("and") + " " + "GPGME" + " " + gpgme_version + "
" + - _("Built at") + " " + BUILD_TIMESTAMP + "
"); + tr("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + + " " + tr("and") + " " + "GPGME" + " " + gpgme_version + "
" + + tr("Built at") + " " + BUILD_TIMESTAMP + ""); auto* layout = new QGridLayout(); auto* pixmap_label = new QLabel(); @@ -139,9 +137,9 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { main_layout->addStretch(); auto* notice_label = new QLabel( - _("If you think there are any problems with the translation, why not " - "participate in the translation work? If you want to participate, " - "please read the document or contact me via email."), + tr("If you think there are any problems with the translation, why not " + "participate in the translation work? If you want to participate, " + "please read the document or contact me via email."), this); notice_label->setWordWrap(true); main_layout->addWidget(notice_label); @@ -150,7 +148,7 @@ TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { } UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { - auto* pixmap = new QPixmap(":gpgfrontend-logo.png"); + auto* pixmap = new QPixmap(":/icons/gpgfrontend-logo.png"); auto* layout = new QGridLayout(); auto* pixmap_label = new QLabel(); pixmap_label->setPixmap(*pixmap); @@ -162,17 +160,17 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { auto* tips_label = new QLabel(); tips_label->setText( "
" + - QString(_("It is recommended that you always check the version " - "of GpgFrontend and upgrade to the latest version.")) + + tr("It is recommended that you always check the version " + "of GpgFrontend and upgrade to the latest version.") + "
" + - _("New versions not only represent new features, but " - "also often represent functional and security fixes.") + + tr("New versions not only represent new features, but " + "also often represent functional and security fixes.") + "
"); tips_label->setWordWrap(true); current_version_label_ = new QLabel(); - current_version_label_->setText("
" + QString(_("Current Version")) + - _(": ") + "" + current_version_ + + current_version_label_->setText("
" + tr("Current Version") + + tr(": ") + "" + current_version_ + "
"); current_version_label_->setWordWrap(true); @@ -254,41 +252,41 @@ void UpdateTab::slot_show_version_status() { "version.latest_version", QString{}); latest_version_label_->setText("
" + - QString(_("Latest Version From Github")) + - ": " + latest_version + "
"); + tr("Latest Version From Github") + ": " + + latest_version + "
"); if (is_need_upgrade) { upgrade_label_->setText( "
" + - QString(_("The current version is less than the latest version on " - "github.")) + - "
" + _("Please click") + + tr("The current version is less than the latest version on " + "github.") + + "
" + tr("Please click") + " " + - _("Here") + " " + _("to download the latest stable version.") + + tr("Here") + " " + tr("to download the latest stable version.") + "
"); upgrade_label_->show(); } else if (is_current_a_withdrawn_version) { upgrade_label_->setText( "
" + - QString(_("This version has serious problems and has been withdrawn. " - "Please stop using it immediately.")) + - "
" + _("Please click") + + tr("This version has serious problems and has been withdrawn. " + "Please stop using it immediately.") + + "
" + tr("Please click") + " " + - _("Here") + " " + _("to download the latest stable version.") + + tr("Here") + " " + tr("to download the latest stable version.") + "
"); upgrade_label_->show(); } else if (!is_current_version_released) { upgrade_label_->setText( "
" + - QString(_("This version has not been released yet, it may be a beta " - "version. If you are not a tester and care about version " - "stability, please do not use this version.")) + - "
" + _("Please click") + + tr("This version has not been released yet, it may be a beta " + "version. If you are not a tester and care about version " + "stability, please do not use this version.") + + "
" + tr("Please click") + " " + - _("Here") + " " + _("to download the latest stable version.") + + tr("Here") + " " + tr("to download the latest stable version.") + "
"); upgrade_label_->show(); } -- cgit v1.2.3 From 394e28ec525077f07ae578161220b3cfafb65591 Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 17 Jan 2024 00:54:18 +0800 Subject: fix: slove some issues and update translations --- src/ui/dialog/help/AboutDialog.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/ui/dialog/help/AboutDialog.cpp') diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 54deed22..e4a189a3 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -119,19 +119,10 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { } TranslatorsTab::TranslatorsTab(QWidget* parent) : QWidget(parent) { - QFile translators_qfile(GlobalSettingStation::GetInstance().GetResourceDir() + - "/TRANSLATORS"); -#ifdef LINUX - if (!translators_qfile.exists()) { - translators_qfile.setFileName("/usr/local/share/GpgFrontend/TRANSLATORS"); - } -#endif - - translators_qfile.open(QIODevice::ReadOnly); - QByteArray in_buffer = translators_qfile.readAll(); - - auto* label = new QLabel(in_buffer); + QFile translators_file(":/TRANSLATORS"); + translators_file.open(QIODevice::ReadOnly); + auto* label = new QLabel(translators_file.readAll()); auto* main_layout = new QVBoxLayout(this); main_layout->addWidget(label); main_layout->addStretch(); -- cgit v1.2.3