game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
game_verification_dialog.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/game_verification_dialog.h
4// ==============================================================================
5// Dialog for verifying and repairing game file integrity
6// ==============================================================================
7
8#pragma once
9
11
12#include <QDialog>
13#include <QLabel>
14#include <QProgressBar>
15#include <QPushButton>
16#include <QTableWidget>
17#include <QThread>
18#include <QTimer>
19#include <atomic>
20#include <memory>
21
22// Forward declarations
23class QGroupBox;
24class QStackedWidget;
25class QTextEdit;
26class ThemeManager;
27
28// ==============================================================================
29// Verification Worker - Runs verification in background thread
30// ==============================================================================
31
32class VerificationWorker : public QObject
33{
34 Q_OBJECT
35
36 public:
37 explicit VerificationWorker(QObject* parent = nullptr);
38
39 void setGameInfo(const QString& gameId, const QString& gameName, const QString& gamePath,
40 int steamAppId);
41
42 signals:
43 void progress(const QString& status, int percent, const QString& currentFile,
44 int filesProcessed, int totalFiles);
45 void finished(bool success, const GameVerificationResult& result);
46 void error(const QString& message);
47
48 public slots:
49 void doVerify();
50 void cancel();
51
52 private:
53 QString gameId_;
54 QString gameName_;
55 QString gamePath_;
56 int steamAppId_ = 0;
57 std::atomic<bool> cancelled_{false};
58 std::unique_ptr<FileVerificationService> service_;
59};
60
61// ==============================================================================
62// File Result Widget - Shows single file verification result
63// ==============================================================================
64
65class FileResultWidget : public QWidget
66{
67 Q_OBJECT
68
69 public:
70 explicit FileResultWidget(const FileVerificationResult& result, QWidget* parent = nullptr,
71 ThemeManager* themeManager = nullptr);
72
74 {
75 return result_;
76 }
77
78 public slots:
79 void applyTheme();
80
81 private:
83 QLabel* statusIcon_ = nullptr;
84 QLabel* pathLabel_ = nullptr;
85 QLabel* detailLabel_ = nullptr;
86 ThemeManager* themeManager_;
87};
88
89// ==============================================================================
90// Verification Summary Widget
91// ==============================================================================
92
93class VerificationSummaryWidget : public QWidget
94{
95 Q_OBJECT
96
97 public:
98 explicit VerificationSummaryWidget(QWidget* parent = nullptr,
99 ThemeManager* themeManager = nullptr);
100
101 void setResult(const GameVerificationResult& result);
102 void clear();
103
104 public slots:
105 void applyTheme();
106
107 private:
108 QLabel* statusIcon_ = nullptr;
109 QLabel* statusLabel_ = nullptr;
110 QLabel* totalFilesLabel_ = nullptr;
111 QLabel* validFilesLabel_ = nullptr;
112 QLabel* invalidFilesLabel_ = nullptr;
113 QLabel* missingFilesLabel_ = nullptr;
114 QLabel* extraFilesLabel_ = nullptr;
115 QLabel* totalSizeLabel_ = nullptr;
116 QLabel* timeLabel_ = nullptr;
117 QProgressBar* integrityBar_ = nullptr;
118 ThemeManager* themeManager_;
119};
120
121// ==============================================================================
122// Game Verification Dialog
123// ==============================================================================
124
125class GameVerificationDialog : public QDialog
126{
127 Q_OBJECT
128
129 public:
130 explicit GameVerificationDialog(QWidget* parent = nullptr,
131 ThemeManager* themeManager = nullptr);
132 ~GameVerificationDialog() override;
133
134 // Set the game to verify
135 void setGame(const QString& gameId, const QString& gameName, const QString& gamePath,
136 int steamAppId = 0);
137
138 // Get verification result
140 {
141 return result_;
142 }
143 bool wasVerified() const
144 {
145 return verified_;
146 }
147
148 private slots:
149 void onVerifyClicked();
150 void onCancelClicked();
151 void onCloseClicked();
152 void onProgress(const QString& status, int percent, const QString& currentFile,
153 int filesProcessed, int totalFiles);
154 void onFinished(bool success, const GameVerificationResult& result);
155 void onError(const QString& message);
156 void onShowDetailsToggled(bool checked);
157 void applyTheme();
158
159 private:
160 void setupUI();
161 void setupGameInfoSection(QWidget* container);
162 void setupProgressSection(QWidget* container);
163 void setupResultsSection(QWidget* container);
164 void showPage(int index);
165 void updateFileList();
166 QString formatBytes(int64_t bytes) const;
167 QString formatDuration(int ms) const;
168
169 // Game info
170 QString gameId_;
171 QString gameName_;
172 QString gamePath_;
173 int steamAppId_ = 0;
174
175 // Result
177 bool verified_ = false;
178
179 // UI - Pages
180 QStackedWidget* pageStack_ = nullptr;
181
182 // UI - Start page
183 QWidget* startPage_ = nullptr;
184 QLabel* gameNameLabel_ = nullptr;
185 QLabel* gamePathLabel_ = nullptr;
186 QLabel* gameTypeLabel_ = nullptr;
187 QPushButton* verifyBtn_ = nullptr;
188
189 // UI - Progress page
190 QWidget* progressPage_ = nullptr;
191 QLabel* progressStatusLabel_ = nullptr;
192 QProgressBar* progressBar_ = nullptr;
193 QLabel* progressFileLabel_ = nullptr;
194 QLabel* progressCountLabel_ = nullptr;
195 QPushButton* cancelBtn_ = nullptr;
196
197 // UI - Results page
198 QWidget* resultsPage_ = nullptr;
199 VerificationSummaryWidget* summaryWidget_ = nullptr;
200 QPushButton* showDetailsBtn_ = nullptr;
201 QTableWidget* fileTable_ = nullptr;
202 QGroupBox* detailsGroup_ = nullptr;
203 QPushButton* verifyAgainBtn_ = nullptr;
204 QPushButton* closeBtn_ = nullptr;
205
206 // Threading
207 QThread* workerThread_ = nullptr;
208 VerificationWorker* worker_ = nullptr;
209 std::atomic<bool> verifying_{false};
210
211 ThemeManager* themeManager_;
212};
const FileVerificationResult & result() const
FileResultWidget(const FileVerificationResult &result, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
const GameVerificationResult & getResult() const
GameVerificationDialog(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void setGame(const QString &gameId, const QString &gameName, const QString &gamePath, int steamAppId=0)
void setResult(const GameVerificationResult &result)
VerificationSummaryWidget(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void setGameInfo(const QString &gameId, const QString &gameName, const QString &gamePath, int steamAppId)
VerificationWorker(QObject *parent=nullptr)
void finished(bool success, const GameVerificationResult &result)
void progress(const QString &status, int percent, const QString &currentFile, int filesProcessed, int totalFiles)
void error(const QString &message)
Result of verifying a single file.
Complete verification result for a game.