aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/help
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ui/dialog/help/AboutDialog.cpp55
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp203
2 files changed, 170 insertions, 88 deletions
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 + "</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);
@@ -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(
"<center>" +
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(
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
index 4780dbf1..260ca29d 100644
--- a/src/ui/dialog/help/GnupgTab.cpp
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -32,6 +32,8 @@
#include "GnupgTab.h"
+#include <boost/format.hpp>
+#include <nlohmann/json.hpp>
#include <shared_mutex>
#include "core/module/ModuleManager.h"
@@ -57,7 +59,9 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
QAbstractItemView::SelectRows);
QStringList configurations_column_titles;
- configurations_column_titles << _("Key") << _("Value");
+ configurations_column_titles << _("Component") << _("Group") << _("Key")
+ << _("Description") << _("Default Value")
+ << _("Value");
ui_->configurationDetailsTable->setColumnCount(
configurations_column_titles.length());
@@ -88,59 +92,146 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
ui_->gnupgVersionLabel->setText(
QString::fromStdString(fmt::format("Version: {}", gnupg_version)));
- // ui_->componentDetailsTable->setRowCount(ctx_info.ComponentsInfo.size());
-
- // int row = 0;
- // for (const auto& info : ctx_info.ComponentsInfo) {
- // if (info.second.size() != 4) continue;
-
- // auto* tmp0 = new QTableWidgetItem(QString::fromStdString(info.first));
- // tmp0->setTextAlignment(Qt::AlignCenter);
- // ui_->componentDetailsTable->setItem(row, 0, tmp0);
-
- // auto* tmp1 = new
- // QTableWidgetItem(QString::fromStdString(info.second[0]));
- // tmp1->setTextAlignment(Qt::AlignCenter);
- // ui_->componentDetailsTable->setItem(row, 1, tmp1);
-
- // auto* tmp2 = new
- // QTableWidgetItem(QString::fromStdString(info.second[1]));
- // tmp2->setTextAlignment(Qt::AlignCenter);
- // ui_->componentDetailsTable->setItem(row, 2, tmp2);
-
- // auto* tmp3 = new
- // QTableWidgetItem(QString::fromStdString(info.second[3]));
- // tmp3->setTextAlignment(Qt::AlignCenter);
- // ui_->componentDetailsTable->setItem(row, 3, tmp3);
-
- // auto* tmp4 = new
- // QTableWidgetItem(QString::fromStdString(info.second[2]));
- // tmp4->setTextAlignment(Qt::AlignLeft);
- // ui_->componentDetailsTable->setItem(row, 4, tmp4);
-
- // row++;
- // }
-
- // ui_->componentDetailsTable->resizeColumnsToContents();
-
- // ui_->configurationDetailsTable->setRowCount(
- // ctx_info.ConfigurationsInfo.size());
-
- // 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++;
- // }
-
- // ui_->configurationDetailsTable->resizeColumnsToContents();
+ auto components = Module::ListRTChildKeys(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ "gnupg.components");
+ SPDLOG_DEBUG("got gnupg components from rt, size: {}", components.size());
+
+ ui_->componentDetailsTable->setRowCount(components.size());
+
+ int row = 0;
+ for (auto& component : components) {
+ auto component_info_json = Module::RetrieveRTValueTypedOrDefault(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ (boost::format("gnupg.components.%1%") % component).str(),
+ std::string{});
+ SPDLOG_DEBUG("got gnupg component {} info from rt, info: {}", component,
+ component_info_json);
+
+ auto component_info = nlohmann::json::parse(component_info_json);
+
+ if (!component_info.contains("name")) {
+ SPDLOG_WARN("illegal gnupg component info, json: {}",
+ component_info_json);
+ continue;
+ }
+
+ auto* tmp0 = new QTableWidgetItem(
+ QString::fromStdString(component_info.value("name", "")));
+ tmp0->setTextAlignment(Qt::AlignCenter);
+ ui_->componentDetailsTable->setItem(row, 0, tmp0);
+
+ auto* tmp1 = new QTableWidgetItem(
+ QString::fromStdString(component_info.value("desc", "")));
+ tmp1->setTextAlignment(Qt::AlignCenter);
+ ui_->componentDetailsTable->setItem(row, 1, tmp1);
+
+ auto* tmp2 = new QTableWidgetItem(
+ QString::fromStdString(component_info.value("version", "")));
+ tmp2->setTextAlignment(Qt::AlignCenter);
+ ui_->componentDetailsTable->setItem(row, 2, tmp2);
+
+ auto* tmp3 = new QTableWidgetItem(
+ QString::fromStdString(component_info.value("binary_checksum", "")));
+ tmp3->setTextAlignment(Qt::AlignCenter);
+ ui_->componentDetailsTable->setItem(row, 3, tmp3);
+
+ auto* tmp4 = new QTableWidgetItem(
+ QString::fromStdString(component_info.value("path", "")));
+ tmp4->setTextAlignment(Qt::AlignLeft);
+ ui_->componentDetailsTable->setItem(row, 4, tmp4);
+
+ row++;
+ }
+
+ ui_->componentDetailsTable->resizeColumnsToContents();
+
+ // calcualte the total row number of configuration table
+ row = 0;
+ for (auto& component : components) {
+ auto options = Module::ListRTChildKeys(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ (boost::format("gnupg.components.%1%.options") % component).str());
+ for (auto& option : options) {
+ const auto option_info =
+ nlohmann::json::parse(Module::RetrieveRTValueTypedOrDefault(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ (boost::format("gnupg.components.%1%.options.%2%") % component %
+ option)
+ .str(),
+ std::string{}));
+ if (!option_info.contains("name") ||
+ option_info.value("flags", "1") == "1") {
+ continue;
+ }
+ row++;
+ }
+ }
+ ui_->configurationDetailsTable->setRowCount(row);
+
+ row = 0;
+ std::string configuration_group;
+ for (auto& component : components) {
+ auto options = Module::ListRTChildKeys(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ (boost::format("gnupg.components.%1%.options") % component).str());
+
+ for (auto& option : options) {
+ auto option_info_json = Module::RetrieveRTValueTypedOrDefault(
+ "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ (boost::format("gnupg.components.%1%.options.%2%") % component %
+ option)
+ .str(),
+ std::string{});
+ SPDLOG_DEBUG("got gnupg component's option {} info from rt, info: {}",
+ component, option_info_json);
+
+ auto option_info = nlohmann::json::parse(option_info_json);
+
+ if (!option_info.contains("name")) {
+ SPDLOG_WARN("illegal gnupg configuation info, json: {}",
+ option_info_json);
+ continue;
+ }
+
+ if (option_info.value("flags", "1") == "1") {
+ configuration_group = option_info.value("name", "");
+ continue;
+ }
+
+ auto* tmp0 = new QTableWidgetItem(QString::fromStdString(component));
+ tmp0->setTextAlignment(Qt::AlignCenter);
+ ui_->configurationDetailsTable->setItem(row, 0, tmp0);
+
+ auto* tmp1 =
+ new QTableWidgetItem(QString::fromStdString(configuration_group));
+ tmp1->setTextAlignment(Qt::AlignCenter);
+ ui_->configurationDetailsTable->setItem(row, 1, tmp1);
+
+ auto* tmp2 = new QTableWidgetItem(
+ QString::fromStdString(option_info.value("name", "")));
+ tmp2->setTextAlignment(Qt::AlignCenter);
+ ui_->configurationDetailsTable->setItem(row, 2, tmp2);
+
+ auto* tmp3 = new QTableWidgetItem(
+ QString::fromStdString(option_info.value("description", "")));
+
+ tmp3->setTextAlignment(Qt::AlignLeft);
+ ui_->configurationDetailsTable->setItem(row, 3, tmp3);
+
+ auto* tmp4 = new QTableWidgetItem(
+ QString::fromStdString(option_info.value("default_value", "")));
+ tmp4->setTextAlignment(Qt::AlignLeft);
+ ui_->configurationDetailsTable->setItem(row, 4, tmp4);
+
+ auto* tmp5 = new QTableWidgetItem(
+ QString::fromStdString(option_info.value("value", "")));
+ tmp5->setTextAlignment(Qt::AlignLeft);
+ ui_->configurationDetailsTable->setItem(row, 5, tmp5);
+
+ row++;
+ }
+ }
+ // ui_->configurationDetailsTable->resizeColumnsToContents();
+
}