aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/help
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog/help')
-rw-r--r--src/ui/dialog/help/AboutDialog.cpp228
-rw-r--r--src/ui/dialog/help/AboutDialog.h20
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp184
-rw-r--r--src/ui/dialog/help/GnupgTab.h16
4 files changed, 281 insertions, 167 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();
}
diff --git a/src/ui/dialog/help/AboutDialog.h b/src/ui/dialog/help/AboutDialog.h
index 6d7ce265..b7871a29 100644
--- a/src/ui/dialog/help/AboutDialog.h
+++ b/src/ui/dialog/help/AboutDialog.h
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2021 Saturneric
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
* This file is part of GpgFrontend.
*
@@ -20,19 +20,16 @@
* 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
*
*/
-#ifndef __ABOUTDIALOG_H__
-#define __ABOUTDIALOG_H__
+#pragma once
-#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
#include "ui/dialog/GeneralDialog.h"
-#include "ui/struct/SoftwareVersion.h"
namespace GpgFrontend::UI {
@@ -89,11 +86,8 @@ class UpdateTab : public QWidget {
*/
explicit UpdateTab(QWidget* parent = nullptr);
- /**
- * @brief Get the Latest Version object
- *
- */
- void getLatestVersion();
+ protected:
+ void showEvent(QShowEvent* event) override;
private slots:
/**
@@ -101,7 +95,7 @@ class UpdateTab : public QWidget {
*
* @param version
*/
- void slot_show_version_status(const SoftwareVersion& version);
+ void slot_show_version_status();
signals:
/**
@@ -141,5 +135,3 @@ class AboutDialog : public GeneralDialog {
};
} // namespace GpgFrontend::UI
-
-#endif // __ABOUTDIALOG_H__
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
index 996d4ad9..28f1acfe 100644
--- a/src/ui/dialog/help/GnupgTab.cpp
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -1,7 +1,7 @@
-/*
- * Copyright (c) 2022. Saturneric
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
- * This file is part of GpgFrontend.
+ * This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,9 +20,10 @@
* 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
+ *
*/
//
@@ -31,21 +32,20 @@
#include "GnupgTab.h"
-#include <shared_mutex>
-
-#include "ui/UserInterfaceUtils.h"
+#include "core/module/ModuleManager.h"
#include "ui_GnuPGInfo.h"
GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
- : QWidget(parent), ui_(std::make_shared<Ui_GnuPGInfo>()) {
+ : QWidget(parent),
+ ui_(GpgFrontend::SecureCreateSharedObject<Ui_GnuPGInfo>()) {
ui_->setupUi(this);
QStringList components_column_titles;
- components_column_titles << _("Name") << _("Description") << _("Version")
- << _("Checksum") << _("Binary Path");
+ components_column_titles << tr("Name") << tr("Description") << tr("Version")
+ << tr("Checksum") << tr("Binary Path");
- ui_->tabWidget->setTabText(0, _("Components"));
- ui_->tabWidget->setTabText(1, _("Configurations"));
+ ui_->tabWidget->setTabText(0, tr("Components"));
+ ui_->tabWidget->setTabText(1, tr("Configurations"));
ui_->componentDetailsTable->setColumnCount(components_column_titles.length());
ui_->componentDetailsTable->setHorizontalHeaderLabels(
@@ -55,7 +55,9 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
QAbstractItemView::SelectRows);
QStringList configurations_column_titles;
- configurations_column_titles << _("Key") << _("Value");
+ configurations_column_titles << tr("Component") << tr("Group") << tr("Key")
+ << tr("Description") << tr("Default Value")
+ << tr("Value");
ui_->configurationDetailsTable->setColumnCount(
configurations_column_titles.length());
@@ -79,34 +81,61 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
}
void GpgFrontend::UI::GnupgTab::process_software_info() {
- auto& ctx_info = GpgContext::GetInstance().GetInfo();
+ const auto gnupg_version = Module::RetrieveRTValueTypedOrDefault<>(
+ "core", "gpgme.ctx.gnupg_version", QString{"2.0.0"});
+ GF_UI_LOG_DEBUG("got gnupg version from rt: {}", gnupg_version);
- ui_->gnupgVersionLabel->setText(QString::fromStdString(
- fmt::format("Version: {}", ctx_info.GnupgVersion)));
+ ui_->gnupgVersionLabel->setText(
+ QString::fromStdString(fmt::format("Version: {}", gnupg_version)));
- ui_->componentDetailsTable->setRowCount(ctx_info.ComponentsInfo.size());
+ auto components = Module::ListRTChildKeys(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ "gnupg.components");
+ GF_UI_LOG_DEBUG("got gnupg components from rt, size: {}", components.size());
- int row = 0;
- for (const auto& info : ctx_info.ComponentsInfo) {
- if (info.second.size() != 4) continue;
+ ui_->componentDetailsTable->setRowCount(components.size());
- auto* tmp0 = new QTableWidgetItem(QString::fromStdString(info.first));
+ int row = 0;
+ for (auto& component : components) {
+ auto component_info_json_bytes = Module::RetrieveRTValueTypedOrDefault(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ QString("gnupg.components.%1").arg(component), QByteArray{});
+ GF_UI_LOG_DEBUG("got gnupg component {} info from rt", component);
+
+ auto component_info_json =
+ QJsonDocument::fromJson(component_info_json_bytes);
+ if (!component_info_json.isObject()) {
+ GF_UI_LOG_WARN("illegal gnupg component info, json: {}",
+ QString(component_info_json_bytes));
+ continue;
+ }
+
+ auto component_info = component_info_json.object();
+ if (!component_info.contains("name")) {
+ GF_UI_LOG_WARN(
+ "illegal gnupg component info. it doesn't have a name, json: {}",
+ QString(component_info_json_bytes));
+ continue;
+ }
+
+ auto* tmp0 = new QTableWidgetItem(component_info["name"].toString());
tmp0->setTextAlignment(Qt::AlignCenter);
ui_->componentDetailsTable->setItem(row, 0, tmp0);
- auto* tmp1 = new QTableWidgetItem(QString::fromStdString(info.second[0]));
+ auto* tmp1 = new QTableWidgetItem(component_info["desc"].toString());
tmp1->setTextAlignment(Qt::AlignCenter);
ui_->componentDetailsTable->setItem(row, 1, tmp1);
- auto* tmp2 = new QTableWidgetItem(QString::fromStdString(info.second[1]));
+ auto* tmp2 = new QTableWidgetItem(component_info["version"].toString());
tmp2->setTextAlignment(Qt::AlignCenter);
ui_->componentDetailsTable->setItem(row, 2, tmp2);
- auto* tmp3 = new QTableWidgetItem(QString::fromStdString(info.second[3]));
+ auto* tmp3 =
+ new QTableWidgetItem(component_info["binary_checksum"].toString());
tmp3->setTextAlignment(Qt::AlignCenter);
ui_->componentDetailsTable->setItem(row, 3, tmp3);
- auto* tmp4 = new QTableWidgetItem(QString::fromStdString(info.second[2]));
+ auto* tmp4 = new QTableWidgetItem(component_info["path"].toString());
tmp4->setTextAlignment(Qt::AlignLeft);
ui_->componentDetailsTable->setItem(row, 4, tmp4);
@@ -115,23 +144,96 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
ui_->componentDetailsTable->resizeColumnsToContents();
- ui_->configurationDetailsTable->setRowCount(
- ctx_info.ConfigurationsInfo.size());
-
+ // calcualte the total row number of configuration table
row = 0;
- for (const auto& info : ctx_info.ConfigurationsInfo) {
- if (info.second.size() != 1) continue;
-
- auto* tmp0 = new QTableWidgetItem(QString::fromStdString(info.first));
- tmp0->setTextAlignment(Qt::AlignCenter);
- ui_->configurationDetailsTable->setItem(row, 0, tmp0);
-
- auto* tmp1 = new QTableWidgetItem(QString::fromStdString(info.second[0]));
- tmp1->setTextAlignment(Qt::AlignCenter);
- ui_->configurationDetailsTable->setItem(row, 1, tmp1);
-
- row++;
+ for (auto& component : components) {
+ auto options = Module::ListRTChildKeys(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ QString("gnupg.components.%1.options").arg(component));
+ for (auto& option : options) {
+ const auto option_info_json =
+ QJsonDocument::fromJson(Module::RetrieveRTValueTypedOrDefault(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ QString("gnupg.components.%1.options.%2")
+ .arg(component)
+ .arg(option),
+ QByteArray{}));
+
+ if (!option_info_json.isObject()) continue;
+
+ auto option_info = option_info_json.object();
+ if (!option_info.contains("name") || option_info["flags"] == "1") {
+ continue;
+ }
+ row++;
+ }
}
+ ui_->configurationDetailsTable->setRowCount(row);
- ui_->configurationDetailsTable->resizeColumnsToContents();
+ row = 0;
+ QString configuration_group;
+ for (auto& component : components) {
+ auto options = Module::ListRTChildKeys(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ QString("gnupg.components.%1.options").arg(component));
+
+ for (auto& option : options) {
+ auto option_info_json_bytes = Module::RetrieveRTValueTypedOrDefault(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ QString("gnupg.components.%1.options.%2").arg(component).arg(option),
+ QByteArray{});
+ GF_UI_LOG_DEBUG("got gnupg component's option {} info from rt, info: {}",
+ component, option_info_json_bytes);
+
+ auto option_info_json = QJsonDocument::fromJson(option_info_json_bytes);
+
+ if (!option_info_json.isObject()) {
+ GF_UI_LOG_WARN("illegal gnupg option info, json: {}",
+ QString(option_info_json_bytes));
+ continue;
+ }
+
+ auto option_info = option_info_json.object();
+ if (!option_info.contains("name")) {
+ GF_UI_LOG_WARN(
+ "illegal gnupg configuation info. it doesn't have a name, json: {}",
+ QString(option_info_json_bytes));
+ continue;
+ }
+
+ if (option_info["flags"] == "1") {
+ configuration_group = option_info["name"].toString();
+ continue;
+ }
+
+ auto* tmp0 = new QTableWidgetItem(component);
+ tmp0->setTextAlignment(Qt::AlignCenter);
+ ui_->configurationDetailsTable->setItem(row, 0, tmp0);
+
+ auto* tmp1 = new QTableWidgetItem(configuration_group);
+ tmp1->setTextAlignment(Qt::AlignCenter);
+ ui_->configurationDetailsTable->setItem(row, 1, tmp1);
+
+ auto* tmp2 = new QTableWidgetItem(option_info["name"].toString());
+ tmp2->setTextAlignment(Qt::AlignCenter);
+ ui_->configurationDetailsTable->setItem(row, 2, tmp2);
+
+ auto* tmp3 = new QTableWidgetItem(option_info["description"].toString());
+
+ tmp3->setTextAlignment(Qt::AlignLeft);
+ ui_->configurationDetailsTable->setItem(row, 3, tmp3);
+
+ auto* tmp4 =
+ new QTableWidgetItem(option_info["default_value"].toString());
+ tmp4->setTextAlignment(Qt::AlignLeft);
+ ui_->configurationDetailsTable->setItem(row, 4, tmp4);
+
+ auto* tmp5 = new QTableWidgetItem(option_info["value"].toString());
+ tmp5->setTextAlignment(Qt::AlignLeft);
+ ui_->configurationDetailsTable->setItem(row, 5, tmp5);
+
+ row++;
+ }
+ }
+ // ui_->configurationDetailsTable->resizeColumnsToContents();
}
diff --git a/src/ui/dialog/help/GnupgTab.h b/src/ui/dialog/help/GnupgTab.h
index 9195dee0..9e6191db 100644
--- a/src/ui/dialog/help/GnupgTab.h
+++ b/src/ui/dialog/help/GnupgTab.h
@@ -1,7 +1,7 @@
-/*
- * Copyright (c) 2022. Saturneric
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
- * This file is part of GpgFrontend.
+ * This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,19 +20,19 @@
* 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
+ *
*/
//
// Created by eric on 2022/7/23.
//
-#ifndef GPGFRONTEND_GNUPGTAB_H
-#define GPGFRONTEND_GNUPGTAB_H
+#pragma once
-#include "core/GpgContext.h"
+#include "core/function/gpg/GpgContext.h"
#include "ui/GpgFrontendUI.h"
class Ui_GnuPGInfo;
@@ -53,5 +53,3 @@ class GnupgTab : public QWidget {
void process_software_info();
};
} // namespace GpgFrontend::UI
-
-#endif // GPGFRONTEND_GNUPGTAB_H