diff options
author | Saturn&Eric <[email protected]> | 2024-01-23 07:21:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-23 07:21:28 +0000 |
commit | 56acf161d439ce73eceaa145c40fe703bb2c3f02 (patch) | |
tree | a5d4790a6b2efc8786a3c0f74a07f5a8032d4e94 /src/ui/dialog/help/AboutDialog.cpp | |
parent | fix: use more secure cdn links (diff) | |
parent | fix: solve issues on detected gnupg path function and fix linking errors on w... (diff) | |
download | GpgFrontend-56acf161d439ce73eceaa145c40fe703bb2c3f02.tar.gz GpgFrontend-56acf161d439ce73eceaa145c40fe703bb2c3f02.zip |
Merge pull request #126 from saturneric/dev/2.1.1/main
Develop 2.1.2.1
Diffstat (limited to 'src/ui/dialog/help/AboutDialog.cpp')
-rw-r--r-- | src/ui/dialog/help/AboutDialog.cpp | 228 |
1 files changed, 125 insertions, 103 deletions
diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index 111a77af..e4a189a3 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 <[email protected]> * * This file is part of GpgFrontend. * @@ -20,7 +20,7 @@ * the gpg4usb project, which is under GPL-3.0-or-later. * * All the source code of GpgFrontend was modified and released by - * Saturneric<[email protected]> starting on May 12, 2021. + * Saturneric <[email protected]> starting on May 12, 2021. * * SPDX-License-Identifier: GPL-3.0-or-later * @@ -30,17 +30,18 @@ #include <openssl/opensslv.h> +#include <any> + #include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" -#include "core/thread/TaskRunnerGetter.h" +#include "core/module/ModuleManager.h" #include "ui/dialog/help/GnupgTab.h" -#include "ui/thread/VersionCheckTask.h" 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(); @@ -48,70 +49,68 @@ 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) { 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); } - 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); 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"); + const auto gpgme_version = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.version", QString{"2.0.0"}); + GF_UI_LOG_DEBUG("got gpgme version from rt: {}", gpgme_version); + + auto* pixmap = new QPixmap(":/icons/gpgfrontend-logo.png"); auto* text = new QString( "<center><h2>" + qApp->applicationName() + "</h2></center>" + "<center><b>" + qApp->applicationVersion() + "</b></center>" + "<center>" + GIT_VERSION + "</center>" + "<br><center>" + - _("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") + "<br><br>" "<b>" + - _("Developer:") + "</b><br>" + "Saturneric" + "<br><br>" + - _("If you have any questions or suggestions, raise an issue at") + + tr("Developer:") + "</b><br>" + "Saturneric" + "<br><br>" + + tr("If you have any questions or suggestions, raise an issue at") + "<br/>" " <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " + - _("or send a mail to my mailing list at") + " <a " + + tr("or send a mail to my mailing list at") + " <a " + "href=\"mailto:[email protected]\">[email protected]</a>." + "<br><br> " + - _("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + - " " + _("and") + " " + "GPGME" + " " + - GpgFrontend::GpgContext::GetInstance() - .GetInfo(false) - .GpgMEVersion.c_str() + - "<br>" + _("Built at") + " " + BUILD_TIMESTAMP + "</center>"); + tr("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT + + " " + tr("and") + " " + "GPGME" + " " + gpgme_version + "<br>" + + tr("Built at") + " " + BUILD_TIMESTAMP + "</center>"); 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); @@ -120,30 +119,18 @@ 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.u8string().c_str()); -#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(); - 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."), + auto* notice_label = new QLabel( + 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); @@ -152,30 +139,29 @@ 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); 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(); + auto* tips_label = new QLabel(); tips_label->setText( "<center>" + - 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.") + "</center><center>" + - _("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.") + "</center>"); tips_label->setWordWrap(true); current_version_label_ = new QLabel(); - current_version_label_->setText("<center>" + QString(_("Current Version")) + - _(": ") + "<b>" + current_version_ + + current_version_label_->setText("<center>" + tr("Current Version") + + tr(": ") + "<b>" + current_version_ + "</b></center>"); current_version_label_->setWordWrap(true); @@ -203,59 +189,95 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) { setLayout(layout); } -void UpdateTab::getLatestVersion() { - this->pb_->setHidden(false); +void UpdateTab::showEvent(QShowEvent* event) { + QWidget::showEvent(event); + GF_UI_LOG_DEBUG("loading version loading info from rt"); + + auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( + "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.loading_done", false); + + if (!is_loading_done) { + Module::ListenRTPublishEvent( + this, "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.loading_done", + [=](Module::Namespace, Module::Key, int, std::any) { + GF_UI_LOG_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(); + } +} - SPDLOG_DEBUG("try to get latest version"); +void UpdateTab::slot_show_version_status() { + GF_UI_LOG_DEBUG("loading version info from rt"); + this->pb_->setHidden(true); - auto* version_task = new VersionCheckTask(); + auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>( + "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.loading_done", false); - connect(version_task, &VersionCheckTask::SignalUpgradeVersion, this, - &UpdateTab::slot_show_version_status); + if (!is_loading_done) { + GF_UI_LOG_DEBUG("version info loading havn't been done yet."); + return; + } - Thread::TaskRunnerGetter::GetInstance() - .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network) - ->PostTask(version_task); -} + auto is_need_upgrade = Module::RetrieveRTValueTypedOrDefault<>( + "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.need_upgrade", false); -void UpdateTab::slot_show_version_status(const SoftwareVersion& version) { - this->pb_->setHidden(true); - latest_version_label_->setText( - "<center><b>" + QString(_("Latest Version From Github")) + ": " + - version.latest_version.c_str() + "</b></center>"); + auto is_current_a_withdrawn_version = Module::RetrieveRTValueTypedOrDefault<>( + "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.current_a_withdrawn_version", false); + + auto is_current_version_released = Module::RetrieveRTValueTypedOrDefault<>( + "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.current_version_released", false); + + auto latest_version = Module::RetrieveRTValueTypedOrDefault<>( + "com.bktus.gpgfrontend.module.integrated.version-checking", + "version.latest_version", QString{}); + + latest_version_label_->setText("<center><b>" + + tr("Latest Version From Github") + ": " + + latest_version + "</b></center>"); - if (version.NeedUpgrade()) { + if (is_need_upgrade) { upgrade_label_->setText( "<center>" + - QString(_("The current version is less than the latest version on " - "github.")) + - "</center><center>" + _("Please click") + + tr("The current version is less than the latest version on " + "github.") + + "</center><center>" + tr("Please click") + " <a " "href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" + - _("Here") + "</a> " + _("to download the latest stable version.") + + tr("Here") + "</a> " + tr("to download the latest stable version.") + "</center>"); upgrade_label_->show(); - } else if (version.VersionWithDrawn()) { + } else if (is_current_a_withdrawn_version) { upgrade_label_->setText( "<center>" + - QString(_("This version has serious problems and has been withdrawn. " - "Please stop using it immediately.")) + - "</center><center>" + _("Please click") + + tr("This version has serious problems and has been withdrawn. " + "Please stop using it immediately.") + + "</center><center>" + tr("Please click") + " <a " "href=\"https://github.com/saturneric/GpgFrontend/releases\">" + - _("Here") + "</a> " + _("to download the latest stable version.") + + tr("Here") + "</a> " + tr("to download the latest stable version.") + "</center>"); upgrade_label_->show(); - } else if (!version.CurrentVersionReleased()) { + } else if (!is_current_version_released) { upgrade_label_->setText( "<center>" + - 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.")) + - "</center><center>" + _("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.") + + "</center><center>" + tr("Please click") + " <a " "href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" + - _("Here") + "</a> " + _("to download the latest stable version.") + + tr("Here") + "</a> " + tr("to download the latest stable version.") + "</center>"); upgrade_label_->show(); } |