From ab3429ed1c69b68419d9882256c7b4986f38ff8c Mon Sep 17 00:00:00 2001 From: collecting Date: Sat, 25 Oct 2025 01:02:37 +0000 Subject: [PATCH] Edit updater_dialog.h --- src/citron/updater/updater_dialog.h | 93 ++++++++++++++--------------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/src/citron/updater/updater_dialog.h b/src/citron/updater/updater_dialog.h index d8d2afd89..fa517e345 100644 --- a/src/citron/updater/updater_dialog.h +++ b/src/citron/updater/updater_dialog.h @@ -3,68 +3,63 @@ #pragma once -#include #include -#include +#include #include "citron/updater/updater_service.h" +// Forward declare QString for the helper function. +class QString; + namespace Ui { - class UpdaterDialog; +class UpdaterDialog; } namespace Updater { - class UpdaterDialog : public QDialog { - Q_OBJECT +// Add the declaration for the date formatting helper function. +QString FormatDateTimeString(const std::string& iso_string); - public: - explicit UpdaterDialog(QWidget* parent = nullptr); - ~UpdaterDialog() override; +class UpdaterDialog : public QDialog { + Q_OBJECT - void CheckForUpdates(const std::string& update_url); +public: + explicit UpdaterDialog(QWidget* parent = nullptr); + ~UpdaterDialog() override; - private slots: - void OnUpdateCheckCompleted(bool has_update, const UpdateInfo& update_info); - void OnUpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total); - void OnUpdateInstallProgress(int percentage, const QString& current_file); - void OnUpdateCompleted(Updater::UpdaterService::UpdateResult result, const QString& message); - void OnUpdateError(const QString& error_message); - void OnDownloadButtonClicked(); - void OnCancelButtonClicked(); - void OnCloseButtonClicked(); - void OnRestartButtonClicked(); + void CheckForUpdates(const std::string& update_url); - private: - void SetupUI(); - void ShowCheckingState(); - void ShowNoUpdateState(); - void ShowUpdateAvailableState(); - void ShowDownloadingState(); - void ShowInstallingState(); - void ShowCompletedState(); - void ShowErrorState(); - void UpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total); - void UpdateInstallProgress(int percentage, const QString& current_file); - QString FormatBytes(qint64 bytes) const; - QString GetUpdateMessage(Updater::UpdaterService::UpdateResult result) const; +private slots: + void OnUpdateCheckCompleted(bool has_update, const Updater::UpdateInfo& update_info); + void OnUpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total); + void OnUpdateInstallProgress(int percentage, const QString& current_file); + void OnUpdateCompleted(Updater::UpdaterService::UpdateResult result, const QString& message); + void OnUpdateError(const QString& error_message); + void OnDownloadButtonClicked(); + void OnCancelButtonClicked(); + void OnCloseButtonClicked(); + void OnRestartButtonClicked(); - enum class State { - Checking, - NoUpdate, - UpdateAvailable, - Downloading, - Installing, - Completed, - Error - }; +private: + enum class State { Checking, NoUpdate, UpdateAvailable, Downloading, Installing, Completed, Error }; - std::unique_ptr ui; - std::unique_ptr updater_service; - UpdateInfo current_update_info; - State current_state; - qint64 total_download_size; - qint64 downloaded_bytes; - QTimer* progress_timer; - }; + void SetupUI(); + void ShowCheckingState(); + void ShowNoUpdateState(const Updater::UpdateInfo& update_info); + void ShowUpdateAvailableState(); + void ShowDownloadingState(); + void ShowInstallingState(); + void ShowCompletedState(); + void ShowErrorState(); + QString FormatBytes(qint64 bytes) const; + QString GetUpdateMessage(Updater::UpdaterService::UpdateResult result) const; + + std::unique_ptr ui; + std::unique_ptr updater_service; + UpdateInfo current_update_info; + State current_state; + qint64 total_download_size; + qint64 downloaded_bytes; + QTimer* progress_timer; +}; } // namespace Updater