feat: show release note of latest version and improve ui structure
This commit is contained in:
parent
e76d2abcf9
commit
49642fc03d
@ -30,15 +30,47 @@
|
|||||||
|
|
||||||
#include "GFModuleCommonUtils.hpp"
|
#include "GFModuleCommonUtils.hpp"
|
||||||
#include "GFSDKBasic.h"
|
#include "GFSDKBasic.h"
|
||||||
#include "GFSDKLog.h"
|
|
||||||
#include "GFSDKModule.h"
|
#include "GFSDKModule.h"
|
||||||
#include "VersionCheckTask.h"
|
#include "VersionCheckTask.h"
|
||||||
#include "VersionCheckingModule.h"
|
#include "VersionCheckingModule.h"
|
||||||
|
|
||||||
UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) {
|
UpdateTab::UpdateTab(QWidget* parent)
|
||||||
auto* layout = new QGridLayout();
|
: QWidget(parent), current_version_(GFProjectVersion()) {
|
||||||
|
auto* layout = new QVBoxLayout();
|
||||||
|
|
||||||
current_version_ = GFProjectVersion();
|
auto* current_version_box = new QGroupBox(tr("Current Version Information"));
|
||||||
|
auto* current_version_layout = new QVBoxLayout();
|
||||||
|
current_version_label_ = new QLabel();
|
||||||
|
current_version_label_->setText("<center>" + tr("Current Version") +
|
||||||
|
tr(": ") + "<b>" + current_version_ +
|
||||||
|
"</b></center>");
|
||||||
|
current_version_label_->setWordWrap(true);
|
||||||
|
latest_version_label_ = new QLabel();
|
||||||
|
current_version_layout->addWidget(current_version_label_);
|
||||||
|
current_version_layout->addWidget(latest_version_label_);
|
||||||
|
current_version_box->setLayout(current_version_layout);
|
||||||
|
|
||||||
|
auto* upgrade_info_box = new QGroupBox(tr("Upgrade Information"));
|
||||||
|
auto* upgrade_info_layout = new QVBoxLayout();
|
||||||
|
upgrade_label_ = new QLabel();
|
||||||
|
upgrade_label_->setWordWrap(true);
|
||||||
|
upgrade_label_->setOpenExternalLinks(true);
|
||||||
|
upgrade_label_->setHidden(true);
|
||||||
|
pb_ = new QProgressBar();
|
||||||
|
pb_->setRange(0, 0);
|
||||||
|
pb_->setTextVisible(false);
|
||||||
|
upgrade_info_layout->addWidget(upgrade_label_);
|
||||||
|
upgrade_info_layout->addWidget(pb_);
|
||||||
|
upgrade_info_box->setLayout(upgrade_info_layout);
|
||||||
|
|
||||||
|
auto* release_note_box = new QGroupBox(tr("Release Notes"));
|
||||||
|
auto* release_note_layout = new QVBoxLayout();
|
||||||
|
release_note_viewer_ = new QTextEdit();
|
||||||
|
release_note_viewer_->setReadOnly(true);
|
||||||
|
release_note_viewer_->setAcceptRichText(true);
|
||||||
|
release_note_viewer_->hide();
|
||||||
|
release_note_layout->addWidget(release_note_viewer_);
|
||||||
|
release_note_box->setLayout(release_note_layout);
|
||||||
|
|
||||||
auto* tips_label = new QLabel();
|
auto* tips_label = new QLabel();
|
||||||
tips_label->setText(
|
tips_label->setText(
|
||||||
@ -51,39 +83,16 @@ UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) {
|
|||||||
"</center>");
|
"</center>");
|
||||||
tips_label->setWordWrap(true);
|
tips_label->setWordWrap(true);
|
||||||
|
|
||||||
current_version_label_ = new QLabel();
|
layout->addWidget(current_version_box);
|
||||||
current_version_label_->setText("<center>" + tr("Current Version") +
|
layout->addWidget(upgrade_info_box);
|
||||||
tr(": ") + "<b>" + current_version_ +
|
layout->addWidget(release_note_box);
|
||||||
"</b></center>");
|
layout->addWidget(tips_label);
|
||||||
current_version_label_->setWordWrap(true);
|
|
||||||
|
|
||||||
latest_version_label_ = new QLabel();
|
|
||||||
latest_version_label_->setWordWrap(true);
|
|
||||||
|
|
||||||
upgrade_label_ = new QLabel();
|
|
||||||
upgrade_label_->setWordWrap(true);
|
|
||||||
upgrade_label_->setOpenExternalLinks(true);
|
|
||||||
upgrade_label_->setHidden(true);
|
|
||||||
|
|
||||||
pb_ = new QProgressBar();
|
|
||||||
pb_->setRange(0, 0);
|
|
||||||
pb_->setTextVisible(false);
|
|
||||||
|
|
||||||
layout->addWidget(tips_label, 1, 0, 1, -1);
|
|
||||||
layout->addWidget(current_version_label_, 2, 0, 1, -1);
|
|
||||||
layout->addWidget(latest_version_label_, 3, 0, 1, -1);
|
|
||||||
layout->addWidget(upgrade_label_, 4, 0, 1, -1);
|
|
||||||
layout->addWidget(pb_, 5, 0, 1, -1);
|
|
||||||
layout->addItem(
|
|
||||||
new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1,
|
|
||||||
1, 1);
|
|
||||||
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTab::showEvent(QShowEvent* event) {
|
void UpdateTab::showEvent(QShowEvent* event) {
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
MLogDebug("loading version loading info from rt");
|
|
||||||
|
|
||||||
auto is_loading_done = GFModuleRetrieveRTValueOrDefaultBool(
|
auto is_loading_done = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
GFGetModuleID(), GFModuleStrDup("version.loading_done"), 0);
|
GFGetModuleID(), GFModuleStrDup("version.loading_done"), 0);
|
||||||
@ -103,7 +112,6 @@ void UpdateTab::showEvent(QShowEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTab::slot_show_version_status() {
|
void UpdateTab::slot_show_version_status() {
|
||||||
MLogDebug("loading version info from rt");
|
|
||||||
this->pb_->setHidden(true);
|
this->pb_->setHidden(true);
|
||||||
|
|
||||||
auto is_loading_done = GFModuleRetrieveRTValueOrDefaultBool(
|
auto is_loading_done = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
@ -128,44 +136,54 @@ void UpdateTab::slot_show_version_status() {
|
|||||||
GFGetModuleID(), GFModuleStrDup("version.latest_version"),
|
GFGetModuleID(), GFModuleStrDup("version.latest_version"),
|
||||||
GFModuleStrDup("")));
|
GFModuleStrDup("")));
|
||||||
|
|
||||||
|
QString const release_note = UDUP(GFModuleRetrieveRTValueOrDefault(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.release_note"),
|
||||||
|
GFModuleStrDup("")));
|
||||||
|
|
||||||
latest_version_label_->setText("<center><b>" +
|
latest_version_label_->setText("<center><b>" +
|
||||||
tr("Latest Version From Github") + ": " +
|
tr("Latest Version From Github") + ": " +
|
||||||
latest_version + "</b></center>");
|
latest_version + "</b></center>");
|
||||||
|
|
||||||
if (is_need_upgrade != 0) {
|
if (is_need_upgrade != 0) {
|
||||||
upgrade_label_->setText(
|
upgrade_label_->setText(
|
||||||
"<center>" +
|
"<center>" + tr("Your current version is outdated.") +
|
||||||
tr("The current version is less than the latest version on "
|
"</center><center>" + tr("Click") +
|
||||||
"github.") +
|
" <a href=\"https://www.gpgfrontend.bktus.com/overview/downloads/\">" +
|
||||||
"</center><center>" + tr("Please click") +
|
tr("here") + "</a> " + tr("to download the latest stable version.") +
|
||||||
" <a "
|
|
||||||
"href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" +
|
|
||||||
tr("Here") + "</a> " + tr("to download the latest stable version.") +
|
|
||||||
"</center>");
|
"</center>");
|
||||||
upgrade_label_->show();
|
upgrade_label_->show();
|
||||||
} else if (is_current_a_withdrawn_version != 0) {
|
} else if (is_current_a_withdrawn_version != 0) {
|
||||||
upgrade_label_->setText(
|
upgrade_label_->setText(
|
||||||
"<center>" +
|
"<center>" +
|
||||||
tr("This version has serious problems and has been withdrawn. "
|
tr("This version has critical issues and has been withdrawn. Please "
|
||||||
"Please stop using it immediately.") +
|
"stop using it immediately.") +
|
||||||
"</center><center>" + tr("Please click") +
|
"</center><center>" + tr("Click") +
|
||||||
" <a "
|
" <a href=\"https://www.gpgfrontend.bktus.com/overview/downloads/\">" +
|
||||||
"href=\"https://github.com/saturneric/GpgFrontend/releases\">" +
|
tr("here") + "</a> " + tr("to download the latest stable version.") +
|
||||||
tr("Here") + "</a> " + tr("to download the latest stable version.") +
|
|
||||||
"</center>");
|
"</center>");
|
||||||
upgrade_label_->show();
|
upgrade_label_->show();
|
||||||
} else if (is_current_version_released == 0) {
|
} else if (is_current_version_released == 0) {
|
||||||
upgrade_label_->setText(
|
upgrade_label_->setText(
|
||||||
"<center>" +
|
"<center>" +
|
||||||
tr("This version has not been released yet, it may be a beta "
|
tr("This is an unreleased version, possibly a beta. If stability is "
|
||||||
"version. If you are not a tester and care about version "
|
"important to you, please avoid using this version.") +
|
||||||
"stability, please do not use this version.") +
|
"</center><center>" + tr("Click") +
|
||||||
"</center><center>" + tr("Please click") +
|
" <a href=\"https://www.gpgfrontend.bktus.com/overview/downloads/\">" +
|
||||||
" <a "
|
tr("here") + "</a> " + tr("to download the latest stable version.") +
|
||||||
"href=\"https://www.gpgfrontend.bktus.com/overview/downloads/\">" +
|
|
||||||
tr("Here") + "</a> " + tr("to download the latest stable version.") +
|
|
||||||
"</center>");
|
"</center>");
|
||||||
upgrade_label_->show();
|
upgrade_label_->show();
|
||||||
|
} else {
|
||||||
|
upgrade_label_->setText(
|
||||||
|
"<center>" +
|
||||||
|
tr("You are using the latest stable version. No action is required.") +
|
||||||
|
"</center>");
|
||||||
|
upgrade_label_->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!release_note.trimmed().isEmpty()) {
|
||||||
|
release_note_viewer_->clear();
|
||||||
|
release_note_viewer_->setMarkdown(release_note);
|
||||||
|
release_note_viewer_->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class UpdateTab : public QWidget {
|
|||||||
QLabel* latest_version_label_; ///<
|
QLabel* latest_version_label_; ///<
|
||||||
QLabel* upgrade_label_; ///<
|
QLabel* upgrade_label_; ///<
|
||||||
QProgressBar* pb_; ///<
|
QProgressBar* pb_; ///<
|
||||||
|
QTextEdit* release_note_viewer_; ///<
|
||||||
QString current_version_; ///<
|
QString current_version_; ///<
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -193,6 +193,9 @@ void VersionCheckTask::slot_fill_grt_with_version_info(
|
|||||||
GFModuleUpsertRTValueBool(
|
GFModuleUpsertRTValueBool(
|
||||||
GFGetModuleID(), GFModuleStrDup("version.current_a_withdrawn_version"),
|
GFGetModuleID(), GFModuleStrDup("version.current_a_withdrawn_version"),
|
||||||
version.VersionWithdrawn() ? 1 : 0);
|
version.VersionWithdrawn() ? 1 : 0);
|
||||||
|
|
||||||
|
GFModuleUpsertRTValue(GFGetModuleID(), GFModuleStrDup("version.release_note"),
|
||||||
|
GFModuleStrDup(version.release_note.toUtf8()));
|
||||||
GFModuleUpsertRTValueBool(GFGetModuleID(),
|
GFModuleUpsertRTValueBool(GFGetModuleID(),
|
||||||
GFModuleStrDup("version.loading_done"),
|
GFModuleStrDup("version.loading_done"),
|
||||||
version.loading_done ? 1 : 0);
|
version.loading_done ? 1 : 0);
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#include "VersionCheckTask.h"
|
#include "VersionCheckTask.h"
|
||||||
|
|
||||||
GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.version_checking",
|
GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.version_checking",
|
||||||
"VersionChecking", "1.0.0",
|
"VersionChecking", "1.1.0",
|
||||||
"Try checking GpgFrontend version.", "Saturneric");
|
"Try checking GpgFrontend version.", "Saturneric");
|
||||||
|
|
||||||
DEFINE_TRANSLATIONS_STRUCTURE(ModuleVersionChecking);
|
DEFINE_TRANSLATIONS_STRUCTURE(ModuleVersionChecking);
|
||||||
|
Loading…
Reference in New Issue
Block a user