mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 10:43:33 +00:00
Edit updater_dialog.h
This commit is contained in:
@@ -3,68 +3,63 @@
|
|||||||
|
|
||||||
#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 {
|
||||||
|
|
||||||
class UpdaterDialog : public QDialog {
|
// Add the declaration for the date formatting helper function.
|
||||||
Q_OBJECT
|
QString FormatDateTimeString(const std::string& iso_string);
|
||||||
|
|
||||||
public:
|
class UpdaterDialog : public QDialog {
|
||||||
explicit UpdaterDialog(QWidget* parent = nullptr);
|
Q_OBJECT
|
||||||
~UpdaterDialog() override;
|
|
||||||
|
|
||||||
void CheckForUpdates(const std::string& update_url);
|
public:
|
||||||
|
explicit UpdaterDialog(QWidget* parent = nullptr);
|
||||||
|
~UpdaterDialog() override;
|
||||||
|
|
||||||
private slots:
|
void CheckForUpdates(const std::string& update_url);
|
||||||
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();
|
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
void SetupUI();
|
void OnUpdateCheckCompleted(bool has_update, const Updater::UpdateInfo& update_info);
|
||||||
void ShowCheckingState();
|
void OnUpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total);
|
||||||
void ShowNoUpdateState();
|
void OnUpdateInstallProgress(int percentage, const QString& current_file);
|
||||||
void ShowUpdateAvailableState();
|
void OnUpdateCompleted(Updater::UpdaterService::UpdateResult result, const QString& message);
|
||||||
void ShowDownloadingState();
|
void OnUpdateError(const QString& error_message);
|
||||||
void ShowInstallingState();
|
void OnDownloadButtonClicked();
|
||||||
void ShowCompletedState();
|
void OnCancelButtonClicked();
|
||||||
void ShowErrorState();
|
void OnCloseButtonClicked();
|
||||||
void UpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total);
|
void OnRestartButtonClicked();
|
||||||
void UpdateInstallProgress(int percentage, const QString& current_file);
|
|
||||||
QString FormatBytes(qint64 bytes) const;
|
|
||||||
QString GetUpdateMessage(Updater::UpdaterService::UpdateResult result) const;
|
|
||||||
|
|
||||||
enum class State {
|
private:
|
||||||
Checking,
|
enum class State { Checking, NoUpdate, UpdateAvailable, Downloading, Installing, Completed, Error };
|
||||||
NoUpdate,
|
|
||||||
UpdateAvailable,
|
|
||||||
Downloading,
|
|
||||||
Installing,
|
|
||||||
Completed,
|
|
||||||
Error
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<Ui::UpdaterDialog> ui;
|
void SetupUI();
|
||||||
std::unique_ptr<Updater::UpdaterService> updater_service;
|
void ShowCheckingState();
|
||||||
UpdateInfo current_update_info;
|
void ShowNoUpdateState(const Updater::UpdateInfo& update_info);
|
||||||
State current_state;
|
void ShowUpdateAvailableState();
|
||||||
qint64 total_download_size;
|
void ShowDownloadingState();
|
||||||
qint64 downloaded_bytes;
|
void ShowInstallingState();
|
||||||
QTimer* progress_timer;
|
void ShowCompletedState();
|
||||||
};
|
void ShowErrorState();
|
||||||
|
QString FormatBytes(qint64 bytes) const;
|
||||||
|
QString GetUpdateMessage(Updater::UpdaterService::UpdateResult result) const;
|
||||||
|
|
||||||
|
std::unique_ptr<Ui::UpdaterDialog> ui;
|
||||||
|
std::unique_ptr<Updater::UpdaterService> updater_service;
|
||||||
|
UpdateInfo current_update_info;
|
||||||
|
State current_state;
|
||||||
|
qint64 total_download_size;
|
||||||
|
qint64 downloaded_bytes;
|
||||||
|
QTimer* progress_timer;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Updater
|
} // namespace Updater
|
||||||
|
|||||||
Reference in New Issue
Block a user