15#include <QDesktopServices>
19#include <QPainterPath>
30 auto* layout =
new QHBoxLayout(
this);
31 layout->setContentsMargins(6, 2, 6, 2);
32 layout->setSpacing(4);
39 textLabel_->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
42 setCursor(Qt::PointingHandCursor);
43 setMouseTracking(
true);
68 QPainter painter(
this);
69 painter.setRenderHint(QPainter::Antialiasing);
77 path.addRoundedRect(rect().adjusted(1, 1, -1, -1), 4, 4);
78 painter.fillPath(path, c.
accent);
83 path.addRoundedRect(rect().adjusted(1, 1, -1, -1), 4, 4);
95 iconLabel_->setStyleSheet(QString(
"color: %1; font-family: '%2'; font-size: %3px;")
98 textLabel_->setStyleSheet(QString(
"color: %1; font-size: %2px;")
99 .arg(textColor.name())
122 if (event->button() == Qt::LeftButton)
132 if (event->button() == Qt::LeftButton &&
pressed_)
137 if (rect().contains(event->pos()))
150 :
StatusIndicator(parent, themeManager), launchController_(launchController)
159 refreshTimer_ =
new QTimer(
this);
160 refreshTimer_->setInterval(2000);
162 refreshTimer_->start();
169 if (!launchController_)
172 auto runningGames = launchController_->getAllRunningGames();
173 size_t count = runningGames.size();
182 setText(QString(
"%1 Running").arg(count));
186 QString tooltip =
"Running games:\n";
187 for (
const auto& info : runningGames)
190 QString::fromUtf8(
"\xE2\x80\xA2 ") + QString::fromStdString(info.gameName) +
"\n";
198void RunningGamesIndicator::showContextMenu()
200 if (!launchController_)
204 if (runningGames.empty())
210 for (
const auto& info : runningGames)
212 QString gameName = QString::fromStdString(info.gameName);
213 std::string gameId = info.gameId;
215 QMenu* gameMenu = menu.addMenu(QString(
"\u25B6 ") + gameName);
218 QAction* showAction = gameMenu->addAction(
"Show in Library");
219 connect(showAction, &QAction::triggered,
this,
222 gameMenu->addSeparator();
224 QAction* stopAction = gameMenu->addAction(QString::fromUtf8(
"\xE2\x96\xA0 Stop"));
225 connect(stopAction, &QAction::triggered,
this,
229 if (runningGames.size() > 1)
232 QAction* stopAllAction = menu.addAction(QString::fromUtf8(
"\xE2\x96\xA0 Stop All Games"));
233 connect(stopAllAction, &QAction::triggered,
this,
234 [
this, runningGames]()
236 for (
const auto& info : runningGames)
243 menu.exec(mapToGlobal(QPoint(0, -menu.sizeHint().height())));
252 :
StatusIndicator(parent, themeManager), downloadMonitor_(downloadMonitor)
261 refreshTimer_ =
new QTimer(
this);
262 refreshTimer_->setInterval(1000);
264 refreshTimer_->start();
270 activeDownloads_.erase(std::remove_if(activeDownloads_.begin(), activeDownloads_.end(),
271 [](
const DownloadInfo& d)
272 { return d.progress >= 100.0; }),
273 activeDownloads_.end());
275 if (activeDownloads_.empty())
282 if (activeDownloads_.size() == 1)
284 setText(QString(
"%1%").arg(
static_cast<int>(activeDownloads_[0].progress)));
288 setText(QString(
"%1 downloads").arg(activeDownloads_.size()));
292 QString tooltip =
"Active downloads:\n";
293 for (
const auto& dl : activeDownloads_)
295 tooltip += QString(
"%1: %2%\n").arg(dl.gameName).arg(
static_cast<int>(dl.progress));
306 auto it = std::find_if(activeDownloads_.begin(), activeDownloads_.end(),
307 [appId](
const DownloadInfo& d) { return d.appId == appId; });
309 if (it != activeDownloads_.end())
311 it->progress = progress;
318 info.gameName = QString(
"App %1").arg(appId);
319 info.progress = progress;
320 info.status = status;
321 activeDownloads_.push_back(info);
329 activeDownloads_.erase(std::remove_if(activeDownloads_.begin(), activeDownloads_.end(),
330 [appId](
const DownloadInfo& d)
331 { return d.appId == appId; }),
332 activeDownloads_.end());
337void DownloadsIndicator::showContextMenu()
339 if (activeDownloads_.empty())
345 for (
const auto& dl : activeDownloads_)
347 QString text = QString(
"%1 - %2%").arg(dl.gameName).arg(
static_cast<int>(dl.progress));
348 QAction* action = menu.addAction(QString(
"\u21E9 ") + text);
349 action->setEnabled(
false);
352 menu.exec(mapToGlobal(QPoint(0, -menu.sizeHint().height())));
361 :
StatusIndicator(parent, themeManager), libraryController_(libraryController)
371 refreshTimer_ =
new QTimer(
this);
373 refreshTimer_->start(60000);
380 if (!libraryController_)
383 auto allGames = libraryController_->getFilteredGames();
386 for (
const auto* game : allGames)
388 if (!game || game->source !=
GameSource::Steam || game->metadata.steamAppId <= 0)
399 if (updateCount_ > 0)
401 setText(QString(
"%1 Update%2").arg(updateCount_).arg(updateCount_ == 1 ?
"" :
"s"));
402 setTooltipText(QString(
"%1 game%2 %3 updates available\nClick to view")
404 .arg(updateCount_ == 1 ?
"" :
"s")
405 .arg(updateCount_ == 1 ?
"has" :
"have"));
416void UpdatesIndicator::showContextMenu()
418 if (!libraryController_ || updateCount_ == 0)
424 QAction* headerAction =
425 menu.addAction(QString::fromUtf8(
"\xE2\xAC\x86 Updates Available (%1)").arg(updateCount_));
426 headerAction->setEnabled(
false);
433 for (
const auto* game : allGames)
435 if (!game || game->source !=
GameSource::Steam || game->metadata.steamAppId <= 0)
442 uint32_t appId =
static_cast<uint32_t
>(game->metadata.steamAppId);
443 QString gameName = QString::fromStdString(game->name);
445 QAction* gameAction = menu.addAction(gameName);
446 connect(gameAction, &QAction::triggered,
this,
450 QDesktopServices::openUrl(QUrl(QString(
"steam://install/%1").arg(appId)));
455 if (updateCount_ > 10)
457 QAction* moreAction =
458 menu.addAction(QString(
"... and %1 more").arg(updateCount_ - 10));
459 moreAction->setEnabled(
false);
468 QAction* updateAllAction = menu.addAction(
"Update All via Steam");
469 connect(updateAllAction, &QAction::triggered,
this,
470 []() { QDesktopServices::openUrl(QUrl(
"steam://open/downloads")); });
472 menu.exec(mapToGlobal(QPoint(0, -menu.sizeHint().height())));
481 :
StatusIndicator(parent, themeManager), libraryController_(libraryController)
493 if (!libraryController_)
496 size_t totalGames = libraryController_->getGameCount();
497 size_t favoriteCount = 0;
498 size_t installedCount = 0;
501 auto allGames = libraryController_->getFilteredGames();
502 for (
const auto* game : allGames)
504 if (game->isFavorite)
506 if (game->isInstalled())
510 setText(QString(
"%1 Games").arg(totalGames));
512 QString tooltip = QString(
"Library Statistics:\n"
524void LibraryStatsIndicator::showContextMenu()
526 if (!libraryController_)
535 size_t favoriteCount = 0;
536 size_t installedCount = 0;
537 size_t steamCount = 0;
538 size_t lutrisCount = 0;
540 for (
const auto* game : allGames)
542 if (game->isFavorite)
544 if (game->isInstalled())
552 QAction* totalAction = menu.addAction(QString(
"Total Games: %1").arg(totalGames));
553 totalAction->setEnabled(
false);
557 QAction* installedAction =
558 menu.addAction(QString::fromUtf8(
"\xE2\x9C\x93 Installed: %1").arg(installedCount));
559 installedAction->setEnabled(
false);
561 QAction* favAction = menu.addAction(QString(
"\u2605 Favorites: %1").arg(favoriteCount));
562 favAction->setEnabled(
false);
568 QAction* steamAction = menu.addAction(QString(
"\u25B6 Steam: %1").arg(steamCount));
569 steamAction->setEnabled(
false);
574 QAction* lutrisAction = menu.addAction(QString(
"\u2617 Lutris: %1").arg(lutrisCount));
575 lutrisAction->setEnabled(
false);
578 menu.exec(mapToGlobal(QPoint(0, -menu.sizeHint().height())));
589 : QWidget(parent), themeManager_(themeManager ? themeManager : &
ThemeManager::instance())
591 auto* layout =
new QHBoxLayout(
this);
592 layout->setContentsMargins(0, 0, 0, 0);
593 layout->setSpacing(8);
597 layout->addWidget(libraryStats_);
600 auto* sep1 =
new QLabel(QString::fromUtf8(
"\xE2\x94\x82"),
this);
601 sep1->setStyleSheet(QString(
"color: %1;").arg(themeManager_->colors().textMuted.name()));
602 layout->addWidget(sep1);
606 layout->addWidget(runningGames_);
614 layout->addWidget(downloads_);
618 layout->addWidget(updates_);
621 layout->addStretch();
626 runningGames_->refresh();
627 downloads_->refresh();
629 libraryStats_->refresh();
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)
static const QString & solidFamily()
Get the loaded Solid font family name.
static QString text(char32_t codepoint)
Convert a codepoint to a QString glyph.
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)
StatusBarContainer(core::LaunchController *launchController, core::GameLibraryController *libraryController, SteamDownloadMonitor *downloadMonitor, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void showGameRequested(const std::string &gameId)
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.
static SteamDownloadProgress readGameState(uint32_t appId)
Read current state of a game directly from its appmanifest.
void styleMenu(QMenu *menu) const
Apply complete menu styling (stylesheet + palette) to a QMenu.
Shows count of games with updates available.
UpdatesIndicator(core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
std::vector< const Game * > getFilteredGames() const
Get the currently filtered and sorted game list (returns copy for thread safety).
size_t getGameCount() const
Get total game count.
std::vector< RunningGameInfo > getAllRunningGames() const
Get all currently running games.
@ Steam
Steam store/platform.
@ Lutris
Lutris community scripts.
constexpr char32_t ArrowUp
constexpr char32_t CirclePlay
constexpr char32_t Gamepad
constexpr char32_t Download
bool needsUpdate(uint32_t flags)
Check if a game needs an update.