diff --git a/src/m_ver_check/UpdateTab.cpp b/src/m_ver_check/UpdateTab.cpp
index 64c2a86..acd1cdf 100644
--- a/src/m_ver_check/UpdateTab.cpp
+++ b/src/m_ver_check/UpdateTab.cpp
@@ -38,7 +38,7 @@ UpdateTab::UpdateTab(QWidget* parent)
: QWidget(parent), current_version_(GFProjectVersion()) {
auto* layout = new QVBoxLayout();
- auto* current_version_box = new QGroupBox(tr("Current Version Information"));
+ current_version_box_ = new QGroupBox(tr("Current Version Information"));
auto* current_version_layout = new QVBoxLayout();
current_version_label_ = new QLabel();
current_version_label_->setText("
" + tr("Current Version") +
@@ -48,9 +48,9 @@ UpdateTab::UpdateTab(QWidget* parent)
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);
+ current_version_box_->setLayout(current_version_layout);
- auto* upgrade_info_box = new QGroupBox(tr("Upgrade Information"));
+ upgrade_info_box_ = new QGroupBox(tr("Upgrade Information"));
auto* upgrade_info_layout = new QVBoxLayout();
upgrade_label_ = new QLabel();
upgrade_label_->setWordWrap(true);
@@ -61,20 +61,24 @@ UpdateTab::UpdateTab(QWidget* parent)
pb_->setTextVisible(false);
upgrade_info_layout->addWidget(upgrade_label_);
upgrade_info_layout->addWidget(pb_);
- upgrade_info_box->setLayout(upgrade_info_layout);
+ upgrade_info_box_->setLayout(upgrade_info_layout);
- auto* release_note_box = new QGroupBox(tr("Release Notes"));
+ 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);
+ release_note_box_->setLayout(release_note_layout);
- layout->addWidget(current_version_box);
- layout->addWidget(upgrade_info_box);
- layout->addWidget(release_note_box);
+ current_version_box_->hide();
+ release_note_box_->hide();
+ upgrade_info_box_->hide();
+
+ layout->addWidget(current_version_box_);
+ layout->addWidget(upgrade_info_box_);
+ layout->addWidget(release_note_box_);
setLayout(layout);
}
@@ -107,6 +111,21 @@ void UpdateTab::slot_show_version_status() {
if (is_loading_done == 0) {
MLogDebug("version info loading haven't been done yet.");
+
+ upgrade_label_->setText(
+ "" +
+ tr("Unable to retrieve the latest version information. This may be "
+ "due "
+ "to a network issue or the server being unavailable.") +
+ "" +
+ tr("Please check your internet connection or try again later.") +
+ "" + tr("Alternatively, you can visit the") +
+ " " +
+ tr("official download page") + " " +
+ tr("to check for the latest stable version.") + "");
+ upgrade_label_->show();
+ upgrade_info_box_->show();
return;
}
@@ -131,61 +150,75 @@ void UpdateTab::slot_show_version_status() {
GFGetModuleID(), GFModuleStrDup("version.release_note"),
GFModuleStrDup("")));
+ FLOG_INFO("latest version from GitHub: %1", latest_version);
+
latest_version_label_->setText("" +
tr("Latest Version From Github") + ": " +
latest_version + "");
+ current_version_box_->show();
if (is_need_upgrade != 0) {
upgrade_label_->setText(
"" + tr("Your current version is outdated.") +
"" + tr("Click") +
- " " +
+ " " +
tr("here") + " " + tr("to download the latest stable version.") +
"");
upgrade_label_->show();
+ upgrade_info_box_->show();
} else if (is_current_a_withdrawn_version != 0) {
upgrade_label_->setText(
"" +
tr("This version has critical issues and has been withdrawn. Please "
"stop using it immediately.") +
"" + tr("Click") +
- " " +
+ " " +
tr("here") + " " + tr("to download the latest stable version.") +
"");
upgrade_label_->show();
- } else if (is_current_version_released == 0) {
+ upgrade_info_box_->show();
+ } else if (!latest_version.trimmed().isEmpty() &&
+ is_current_version_released == 0) {
upgrade_label_->setText(
"" +
tr("This is an unreleased version, possibly a beta. If stability is "
"important to you, please avoid using this version.") +
"" + tr("Click") +
- " " +
+ " " +
tr("here") + " " + tr("to download the latest stable version.") +
"");
upgrade_label_->show();
+ upgrade_info_box_->show();
} else if (is_git_commit_hash_mismatch != 0) {
upgrade_label_->setText(
"" +
tr("The current version's commit hash does not match the official "
"release. This may indicate a modified or unofficial build.") +
"" + tr("Click") +
- " " +
+ " " +
tr("here") + " " +
tr("to verify your installation or download the official version.") +
"");
upgrade_label_->show();
+ upgrade_info_box_->show();
} else {
- upgrade_label_->setText(
- "" +
- tr("You are using the latest stable version. No action is required.") +
- "");
+ upgrade_label_->setText("" +
+ tr("You are using the latest stable version. No "
+ "action is required.") +
+ "");
upgrade_label_->show();
+ upgrade_info_box_->show();
}
if (!release_note.trimmed().isEmpty()) {
release_note_viewer_->clear();
release_note_viewer_->setMarkdown(release_note);
release_note_viewer_->show();
+ release_note_box_->show();
}
}
diff --git a/src/m_ver_check/UpdateTab.h b/src/m_ver_check/UpdateTab.h
index 4003a23..fef54e6 100644
--- a/src/m_ver_check/UpdateTab.h
+++ b/src/m_ver_check/UpdateTab.h
@@ -43,6 +43,9 @@ class UpdateTab : public QWidget {
QProgressBar* pb_; ///<
QTextEdit* release_note_viewer_; ///<
QString current_version_; ///<
+ QGroupBox* release_note_box_;
+ QGroupBox* upgrade_info_box_;
+ QGroupBox* current_version_box_;
public:
/**
diff --git a/src/m_ver_check/VersionCheckTask.cpp b/src/m_ver_check/VersionCheckTask.cpp
index f0da4bb..d9e5d5e 100644
--- a/src/m_ver_check/VersionCheckTask.cpp
+++ b/src/m_ver_check/VersionCheckTask.cpp
@@ -73,21 +73,20 @@ auto VersionCheckTask::Run() -> int {
void VersionCheckTask::slot_parse_reply(QNetworkReply* reply) {
if (reply->error() == QNetworkReply::NoError) {
FLOG_DEBUG("get reply from url: %1", reply->url().toString());
+ switch (replies_.indexOf(reply)) {
+ case 0:
+ slot_parse_latest_version_info(reply);
+ break;
+ case 1:
+ slot_parse_current_version_info(reply);
+ break;
+ case 2:
+ slot_parse_current_tag_info(reply);
+ break;
+ }
} else {
- FLOG_DEBUG("get reply from url: %1, error: %2", reply->url().toString(),
- reply->errorString());
- }
-
- switch (replies_.indexOf(reply)) {
- case 0:
- slot_parse_latest_version_info(reply);
- break;
- case 1:
- slot_parse_current_version_info(reply);
- break;
- case 2:
- slot_parse_current_tag_info(reply);
- break;
+ FLOG_DEBUG("get reply from url: %1, error: %2 %3", reply->url().toString(),
+ reply->errorString(), reply->readAll());
}
replies_.removeAll(reply);
@@ -113,15 +112,16 @@ void VersionCheckTask::slot_parse_latest_version_info(QNetworkReply* reply) {
}
QString latest_version = latest_reply_json["tag_name"].toString();
+ FLOG_DEBUG("raw tag name from github: %1", latest_version);
QRegularExpression re(R"(^[vV](\d+\.)?(\d+\.)?(\*|\d+))");
auto version_match = re.match(latest_version);
if (version_match.hasMatch()) {
latest_version = version_match.captured(0);
} else {
- latest_version = current_version_;
- MLogWarn(QString("latest version unknown, set to current version: %1")
- .arg(current_version_));
+ latest_version = "";
+ FLOG_WARN("the raw tag name from github: %1 cannot match regex rules",
+ latest_version);
}
bool prerelease = latest_reply_json["prerelease"].toBool();
diff --git a/src/m_ver_check/VersionCheckingModule.cpp b/src/m_ver_check/VersionCheckingModule.cpp
index d672fe7..d53c726 100644
--- a/src/m_ver_check/VersionCheckingModule.cpp
+++ b/src/m_ver_check/VersionCheckingModule.cpp
@@ -44,7 +44,7 @@
#include "VersionCheckTask.h"
GF_MODULE_API_DEFINE("com.bktus.gpgfrontend.module.version_checking",
- "VersionChecking", "1.2.0",
+ "VersionChecking", "1.2.1",
"Try checking GpgFrontend version.", "Saturneric");
DEFINE_TRANSLATIONS_STRUCTURE(ModuleVersionChecking);