Edit updater_dialog.h

This commit is contained in:
collecting
2025-10-25 01:02:37 +00:00
parent ee7aebca9b
commit ab3429ed1c

View File

@@ -3,17 +3,22 @@
#pragma once #pragma once
#include <memory>
#include <QDialog> #include <QDialog>
#include <QTimer> #include <memory>
#include "citron/updater/updater_service.h" #include "citron/updater/updater_service.h"
// Forward declare QString for the helper function.
class QString;
namespace Ui { namespace Ui {
class UpdaterDialog; class UpdaterDialog;
} }
namespace Updater { namespace Updater {
// Add the declaration for the date formatting helper function.
QString FormatDateTimeString(const std::string& iso_string);
class UpdaterDialog : public QDialog { class UpdaterDialog : public QDialog {
Q_OBJECT Q_OBJECT
@@ -24,7 +29,7 @@ namespace Updater {
void CheckForUpdates(const std::string& update_url); void CheckForUpdates(const std::string& update_url);
private slots: private slots:
void OnUpdateCheckCompleted(bool has_update, const UpdateInfo& update_info); void OnUpdateCheckCompleted(bool has_update, const Updater::UpdateInfo& update_info);
void OnUpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total); void OnUpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total);
void OnUpdateInstallProgress(int percentage, const QString& current_file); void OnUpdateInstallProgress(int percentage, const QString& current_file);
void OnUpdateCompleted(Updater::UpdaterService::UpdateResult result, const QString& message); void OnUpdateCompleted(Updater::UpdaterService::UpdateResult result, const QString& message);
@@ -35,29 +40,19 @@ namespace Updater {
void OnRestartButtonClicked(); void OnRestartButtonClicked();
private: private:
enum class State { Checking, NoUpdate, UpdateAvailable, Downloading, Installing, Completed, Error };
void SetupUI(); void SetupUI();
void ShowCheckingState(); void ShowCheckingState();
void ShowNoUpdateState(); void ShowNoUpdateState(const Updater::UpdateInfo& update_info);
void ShowUpdateAvailableState(); void ShowUpdateAvailableState();
void ShowDownloadingState(); void ShowDownloadingState();
void ShowInstallingState(); void ShowInstallingState();
void ShowCompletedState(); void ShowCompletedState();
void ShowErrorState(); 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 FormatBytes(qint64 bytes) const;
QString GetUpdateMessage(Updater::UpdaterService::UpdateResult result) const; QString GetUpdateMessage(Updater::UpdaterService::UpdateResult result) const;
enum class State {
Checking,
NoUpdate,
UpdateAvailable,
Downloading,
Installing,
Completed,
Error
};
std::unique_ptr<Ui::UpdaterDialog> ui; std::unique_ptr<Ui::UpdaterDialog> ui;
std::unique_ptr<Updater::UpdaterService> updater_service; std::unique_ptr<Updater::UpdaterService> updater_service;
UpdateInfo current_update_info; UpdateInfo current_update_info;