From 52bcd981ba6a888d8d86dd3e0932d9edfdd849b6 Mon Sep 17 00:00:00 2001 From: saturneric Date: Wed, 11 Jun 2025 01:18:10 +0200 Subject: feat(version_checking): add update checking api selection and caching - add bktus api support for version checking - implement version info caching with timestamp - add manual check button in update tab - support api selection from settings - add json serialization for version info --- src/m_ver_check/SoftwareVersion.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/m_ver_check/SoftwareVersion.cpp') diff --git a/src/m_ver_check/SoftwareVersion.cpp b/src/m_ver_check/SoftwareVersion.cpp index 9f53791..c6dbf6e 100644 --- a/src/m_ver_check/SoftwareVersion.cpp +++ b/src/m_ver_check/SoftwareVersion.cpp @@ -32,6 +32,8 @@ #include #include +#include +#include #include #include "GFModuleCommonUtils.hpp" @@ -64,3 +66,34 @@ auto SoftwareVersion::GitCommitHashMismatch() const -> bool { remote_commit_hash_by_tag, local_commit_hash); return remote_commit_hash_by_tag.trimmed() != local_commit_hash.trimmed(); } + +auto SoftwareVersion::ToJson() const -> QJsonObject { + QJsonObject obj; + obj["api"] = api; + obj["latest_version"] = latest_version; + obj["current_version"] = current_version; + obj["current_version_publish_in_remote"] = current_version_publish_in_remote; + obj["current_commit_hash_publish_in_remote"] = + current_commit_hash_publish_in_remote; + obj["publish_date"] = publish_date; + obj["release_note"] = release_note; + obj["remote_commit_hash_by_tag"] = remote_commit_hash_by_tag; + obj["local_commit_hash"] = local_commit_hash; + obj["timestamp"] = timestamp.toSecsSinceEpoch(); + return obj; +} + +void SoftwareVersion::FromJson(const QJsonObject& obj) { + api = obj.value("api").toString(); + latest_version = obj.value("latest_version").toString(); + current_version = obj.value("current_version").toString(); + current_version_publish_in_remote = + obj.value("current_version_publish_in_remote").toBool(); + current_commit_hash_publish_in_remote = + obj.value("current_commit_hash_publish_in_remote").toBool(); + publish_date = obj.value("publish_date").toString(); + release_note = obj.value("release_note").toString(); + remote_commit_hash_by_tag = obj.value("remote_commit_hash_by_tag").toString(); + local_commit_hash = obj.value("local_commit_hash").toString(); + timestamp = QDateTime::fromSecsSinceEpoch(obj.value("timestamp").toInt()); +} -- cgit v1.2.3