game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
download_queue_dialog.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// download_queue_dialog.h
4// ==============================================================================
5// Download Queue Manager Dialog - Monitor and control Steam downloads
6// ==============================================================================
7// Provides a comprehensive interface for:
8// - Viewing all active and queued downloads
9// - Pause/resume/cancel individual downloads
10// - Reorder download queue priority
11// - View download history
12// - Bandwidth limiting controls
13// - Download speed graphs
14// ==============================================================================
15
16#pragma once
17
18#include <QDateTime>
19#include <QDialog>
20#include <QHideEvent>
21#include <QLabel>
22#include <QListWidget>
23#include <QProgressBar>
24#include <QPushButton>
25#include <QShowEvent>
26#include <QTabWidget>
27#include <QTimer>
28#include <vector>
29
30// Forward declarations
31class QGroupBox;
32class QSlider;
33class QSpinBox;
34class QCheckBox;
36class ThemeManager;
37
38namespace core
39{
41}
42
43// ==============================================================================
44// Download Item Widget - Displays single download with controls
45// ==============================================================================
46
47class DownloadItemWidget : public QWidget
48{
49 Q_OBJECT
50
51 public:
52 explicit DownloadItemWidget(uint32_t appId, const QString& gameName, QWidget* parent = nullptr,
53 ThemeManager* themeManager = nullptr);
55
56 uint32_t appId() const
57 {
58 return appId_;
59 }
60 QString gameName() const
61 {
62 return gameName_;
63 }
64
65 void setProgress(double progress, uint64_t bytesDownloaded, uint64_t totalBytes);
66 void setSpeed(double bytesPerSec);
67 void setStatus(const QString& status);
68 void setQueuePosition(int position); // 0 = active, 1+ = queued
69 void setPaused(bool paused);
70 bool isPaused() const
71 {
72 return isPaused_;
73 }
74
75 signals:
76 void pauseRequested(uint32_t appId);
77 void resumeRequested(uint32_t appId);
78 void cancelRequested(uint32_t appId);
79 void moveUpRequested(uint32_t appId);
80 void moveDownRequested(uint32_t appId);
82
83 public slots:
84 void applyTheme();
85
86 private:
87 void setupUI();
88 QString formatBytes(uint64_t bytes) const;
89 QString formatSpeed(double bytesPerSec) const;
90 QString formatETA(uint64_t remaining, double speed) const;
91
92 uint32_t appId_;
93 QString gameName_;
94 bool isPaused_ = false;
95 double lastSpeed_ = 0.0;
96
97 // UI elements
98 QLabel* coverLabel_ = nullptr;
99 QLabel* nameLabel_ = nullptr;
100 QLabel* statusLabel_ = nullptr;
101 QLabel* progressTextLabel_ = nullptr;
102 QLabel* speedLabel_ = nullptr;
103 QLabel* etaLabel_ = nullptr;
104 QProgressBar* progressBar_ = nullptr;
105 QPushButton* pauseResumeBtn_ = nullptr;
106 QPushButton* cancelBtn_ = nullptr;
107 QPushButton* moveUpBtn_ = nullptr;
108 QPushButton* moveDownBtn_ = nullptr;
109 ThemeManager* themeManager_;
110};
111
112// ==============================================================================
113// Download History Item
114// ==============================================================================
115
117{
118 uint32_t appId;
119 QString gameName;
120 uint64_t totalBytes;
121 QDateTime completedAt;
124 bool wasUpdate; // true = update, false = fresh install
125};
126
127// ==============================================================================
128// Download Stats Widget - Shows overall download statistics
129// ==============================================================================
130
131class DownloadStatsWidget : public QWidget
132{
133 Q_OBJECT
134
135 public:
136 explicit DownloadStatsWidget(QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
137
138 void setActiveCount(int count);
139 void setQueuedCount(int count);
140 void setTotalSpeed(double bytesPerSec);
141 void setTotalRemaining(uint64_t bytes);
142 void setEstimatedTime(int seconds);
143
144 public slots:
145 void applyTheme();
146
147 private:
148 QLabel* activeCountLabel_ = nullptr;
149 QLabel* queuedCountLabel_ = nullptr;
150 QLabel* speedLabel_ = nullptr;
151 QLabel* remainingLabel_ = nullptr;
152 QLabel* etaLabel_ = nullptr;
153 ThemeManager* themeManager_;
154};
155
156// ==============================================================================
157// Bandwidth Control Widget
158// ==============================================================================
159
160class BandwidthControlWidget : public QWidget
161{
162 Q_OBJECT
163
164 public:
165 explicit BandwidthControlWidget(QWidget* parent = nullptr,
166 ThemeManager* themeManager = nullptr);
167
168 bool isLimitEnabled() const;
169 int getLimitMBps() const;
170
171 signals:
172 void limitChanged(bool enabled, int mbps);
173
174 public slots:
175 void applyTheme();
176
177 private slots:
178 void onLimitToggled(bool checked);
179 void onLimitValueChanged(int value);
180
181 private:
182 QCheckBox* limitCheckbox_ = nullptr;
183 QSlider* limitSlider_ = nullptr;
184 QSpinBox* limitSpinbox_ = nullptr;
185 QLabel* limitLabel_ = nullptr;
186 ThemeManager* themeManager_;
187};
188
189// ==============================================================================
190// Download Queue Manager Dialog
191// ==============================================================================
192
193class DownloadQueueDialog : public QDialog
194{
195 Q_OBJECT
196
197 public:
198 explicit DownloadQueueDialog(SteamDownloadMonitor* downloadMonitor,
199 core::GameLibraryController* libraryController,
200 QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
201 ~DownloadQueueDialog() override;
202
203 signals:
204 void downloadPaused(uint32_t appId);
205 void downloadResumed(uint32_t appId);
206 void downloadCancelled(uint32_t appId);
207 void openGameRequested(const QString& gameId);
208
209 protected:
210 void showEvent(QShowEvent* event) override;
211 void hideEvent(QHideEvent* event) override;
212
213 private slots:
214 void onRefresh();
215 void onPauseAll();
216 void onResumeAll();
217 void onClearCompleted();
218 void onPauseRequested(uint32_t appId);
219 void onResumeRequested(uint32_t appId);
220 void onCancelRequested(uint32_t appId);
221 void onMoveUpRequested(uint32_t appId);
222 void onMoveDownRequested(uint32_t appId);
223 void onOpenInSteamRequested(uint32_t appId);
224 void onBandwidthLimitChanged(bool enabled, int mbps);
225 void onDownloadProgress(uint32_t appId, double progress, const QString& status);
226 void onDownloadComplete(uint32_t appId);
227 void applyTheme();
228
229 private:
230 void setupUI();
231 void setupActiveTab(QWidget* tab);
232 void setupUpdatesTab(QWidget* tab);
233 void setupHistoryTab(QWidget* tab);
234 void setupSettingsTab(QWidget* tab);
235 void updateDownloadList();
236 void updateUpdatesList();
237 void updateStats();
238 void addDownloadItem(uint32_t appId, const QString& gameName, int queuePosition);
239 void removeDownloadItem(uint32_t appId);
240 DownloadItemWidget* findDownloadItem(uint32_t appId);
241 void loadHistory();
242 void saveHistory();
243 void addToHistory(uint32_t appId, const QString& gameName, uint64_t bytes, int duration,
244 bool wasUpdate);
245 QString formatBytes(uint64_t bytes) const;
246 QString formatDuration(int seconds) const;
247
248 // Dependencies
249 SteamDownloadMonitor* downloadMonitor_ = nullptr;
250 core::GameLibraryController* libraryController_ = nullptr;
251
252 // State
253 std::vector<DownloadHistoryItem> downloadHistory_;
254 bool allPaused_ = false;
255
256 // UI - Main
257 QTabWidget* tabWidget_ = nullptr;
258
259 // UI - Active downloads tab
260 QWidget* activeTab_ = nullptr;
261 DownloadStatsWidget* statsWidget_ = nullptr;
262 QListWidget* downloadList_ = nullptr;
263 QPushButton* pauseAllBtn_ = nullptr;
264 QPushButton* resumeAllBtn_ = nullptr;
265 QPushButton* refreshBtn_ = nullptr;
266 QLabel* activeEmptyLabel_ = nullptr;
267
268 // UI - Updates available tab
269 QWidget* updatesTab_ = nullptr;
270 QListWidget* updatesList_ = nullptr;
271 QPushButton* updateAllBtn_ = nullptr;
272 QLabel* updatesCountLabel_ = nullptr;
273
274 // UI - History tab
275 QWidget* historyTab_ = nullptr;
276 QListWidget* historyList_ = nullptr;
277 QPushButton* clearHistoryBtn_ = nullptr;
278 QLabel* historyStatsLabel_ = nullptr;
279
280 // UI - Settings tab
281 QWidget* settingsTab_ = nullptr;
282 BandwidthControlWidget* bandwidthWidget_ = nullptr;
283 QCheckBox* autoStartCheckbox_ = nullptr;
284 QCheckBox* notifyCompleteCheckbox_ = nullptr;
285
286 // Refresh timer
287 QTimer* refreshTimer_ = nullptr;
288
289 ThemeManager* themeManager_;
290};
void limitChanged(bool enabled, int mbps)
BandwidthControlWidget(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void setStatus(const QString &status)
void pauseRequested(uint32_t appId)
DownloadItemWidget(uint32_t appId, const QString &gameName, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void cancelRequested(uint32_t appId)
void setQueuePosition(int position)
~DownloadItemWidget() override
void moveUpRequested(uint32_t appId)
void setSpeed(double bytesPerSec)
void resumeRequested(uint32_t appId)
void moveDownRequested(uint32_t appId)
void openInSteamRequested(uint32_t appId)
void setProgress(double progress, uint64_t bytesDownloaded, uint64_t totalBytes)
void showEvent(QShowEvent *event) override
void downloadResumed(uint32_t appId)
void hideEvent(QHideEvent *event) override
void openGameRequested(const QString &gameId)
void downloadPaused(uint32_t appId)
void downloadCancelled(uint32_t appId)
DownloadQueueDialog(SteamDownloadMonitor *downloadMonitor, core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void setTotalRemaining(uint64_t bytes)
void setEstimatedTime(int seconds)
void setTotalSpeed(double bytesPerSec)
DownloadStatsWidget(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
Monitors Steam download/install progress for games.