game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
status_indicators.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// status_indicators.h
4// ==============================================================================
5// Rich status bar indicators for running games, downloads, and system stats
6// ==============================================================================
7// Provides clickable status indicators that show:
8// - Running games count with quick-stop menu
9// - Download progress with game list
10// - Cloud sync status
11// - System stats (GPU temp, memory - optional)
12// ==============================================================================
13
14#pragma once
15
16#include <QLabel>
17#include <QMenu>
18#include <QMouseEvent>
19#include <QTimer>
20#include <QWidget>
21#include <functional>
22#include <vector>
23
24// Forward declarations
25namespace core
26{
29} // namespace core
31class ThemeManager;
32
33// ==============================================================================
34// Clickable Status Indicator Base
35// ==============================================================================
36
37/**
38 * @class StatusIndicator
39 * @brief Base class for clickable status bar indicators
40 *
41 * Provides consistent styling and click behavior for status bar widgets.
42 */
43class StatusIndicator : public QWidget
44{
45 Q_OBJECT
46
47 public:
48 explicit StatusIndicator(QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
49
50 void setIcon(const QString& icon);
51 void setText(const QString& text);
52 void setTooltipText(const QString& tip);
53
54 signals:
55 void clicked();
56
57 protected:
58 void paintEvent(QPaintEvent* event) override;
59 void enterEvent(QEnterEvent* event) override;
60 void leaveEvent(QEvent* event) override;
61 void mousePressEvent(QMouseEvent* event) override;
62 void mouseReleaseEvent(QMouseEvent* event) override;
63
64 void updateTextColors();
65
66 QLabel* iconLabel_ = nullptr;
67 QLabel* textLabel_ = nullptr;
68 bool hovered_ = false;
69 bool pressed_ = false;
71};
72
73// ==============================================================================
74// Running Games Indicator
75// ==============================================================================
76
77/**
78 * @class RunningGamesIndicator
79 * @brief Shows count of running games with quick-stop menu
80 */
82{
83 Q_OBJECT
84
85 public:
86 explicit RunningGamesIndicator(core::LaunchController* launchController,
87 QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
88
89 void refresh();
90
91 signals:
92 void stopGameRequested(const std::string& gameId);
93 void showGameRequested(const std::string& gameId);
94
95 private:
96 void showContextMenu();
97 core::LaunchController* launchController_ = nullptr;
98 QTimer* refreshTimer_ = nullptr;
99};
100
101// ==============================================================================
102// Downloads Indicator
103// ==============================================================================
104
105/**
106 * @class DownloadsIndicator
107 * @brief Shows active downloads with progress
108 */
110{
111 Q_OBJECT
112
113 public:
114 explicit DownloadsIndicator(SteamDownloadMonitor* downloadMonitor, QWidget* parent = nullptr,
115 ThemeManager* themeManager = nullptr);
116
117 void refresh();
118
119 public slots:
120 void onDownloadProgress(uint32_t appId, double progress, const QString& status);
121 void onDownloadComplete(uint32_t appId);
122
123 private:
124 void showContextMenu();
125
126 struct DownloadInfo
127 {
128 uint32_t appId;
129 QString gameName;
130 double progress;
131 QString status;
132 };
133
134 SteamDownloadMonitor* downloadMonitor_ = nullptr;
135 std::vector<DownloadInfo> activeDownloads_;
136 QTimer* refreshTimer_ = nullptr;
137};
138
139// ==============================================================================
140// Updates Available Indicator
141// ==============================================================================
142
143/**
144 * @class UpdatesIndicator
145 * @brief Shows count of games with updates available
146 */
148{
149 Q_OBJECT
150
151 public:
152 explicit UpdatesIndicator(core::GameLibraryController* libraryController,
153 QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
154
155 void refresh();
156 int updateCount() const
157 {
158 return updateCount_;
159 }
160
161 signals:
163
164 private:
165 void showContextMenu();
166 core::GameLibraryController* libraryController_ = nullptr;
167 QTimer* refreshTimer_ = nullptr;
168 int updateCount_ = 0;
169};
170
171// ==============================================================================
172// Library Stats Indicator
173// ==============================================================================
174
175/**
176 * @class LibraryStatsIndicator
177 * @brief Shows library statistics (game count, playtime)
178 */
180{
181 Q_OBJECT
182
183 public:
184 explicit LibraryStatsIndicator(core::GameLibraryController* libraryController,
185 QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
186
187 void refresh();
188
189 private:
190 void showContextMenu();
191 core::GameLibraryController* libraryController_ = nullptr;
192};
193
194// ==============================================================================
195// Status Bar Container
196// ==============================================================================
197
198/**
199 * @class StatusBarContainer
200 * @brief Container widget for all status indicators
201 *
202 * Manages layout and visibility of status indicators in the status bar.
203 */
204class StatusBarContainer : public QWidget
205{
206 Q_OBJECT
207
208 public:
209 explicit StatusBarContainer(core::LaunchController* launchController,
210 core::GameLibraryController* libraryController,
211 SteamDownloadMonitor* downloadMonitor, QWidget* parent = nullptr,
212 ThemeManager* themeManager = nullptr);
213
214 void refresh();
215
217 {
218 return runningGames_;
219 }
221 {
222 return downloads_;
223 }
225 {
226 return updates_;
227 }
229 {
230 return libraryStats_;
231 }
232
233 signals:
234 void stopGameRequested(const std::string& gameId);
235 void showGameRequested(const std::string& gameId);
237
238 private:
239 RunningGamesIndicator* runningGames_ = nullptr;
240 DownloadsIndicator* downloads_ = nullptr;
241 UpdatesIndicator* updates_ = nullptr;
242 LibraryStatsIndicator* libraryStats_ = nullptr;
243 ThemeManager* themeManager_;
244};
Shows active downloads with progress.
void onDownloadProgress(uint32_t appId, double progress, const QString &status)
DownloadsIndicator(SteamDownloadMonitor *downloadMonitor, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void onDownloadComplete(uint32_t appId)
Shows library statistics (game count, playtime).
LibraryStatsIndicator(core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
Shows count of running games with quick-stop menu.
void showGameRequested(const std::string &gameId)
RunningGamesIndicator(core::LaunchController *launchController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void stopGameRequested(const std::string &gameId)
void stopGameRequested(const std::string &gameId)
LibraryStatsIndicator * libraryStatsIndicator() const
StatusBarContainer(core::LaunchController *launchController, core::GameLibraryController *libraryController, SteamDownloadMonitor *downloadMonitor, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
DownloadsIndicator * downloadsIndicator() const
RunningGamesIndicator * runningGamesIndicator() const
void showGameRequested(const std::string &gameId)
UpdatesIndicator * updatesIndicator() const
void leaveEvent(QEvent *event) override
void setIcon(const QString &icon)
void paintEvent(QPaintEvent *event) override
void setTooltipText(const QString &tip)
StatusIndicator(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void mouseReleaseEvent(QMouseEvent *event) override
void setText(const QString &text)
ThemeManager * themeManager_
void mousePressEvent(QMouseEvent *event) override
void enterEvent(QEnterEvent *event) override
Monitors Steam download/install progress for games.
Shows count of games with updates available.
UpdatesIndicator(core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)