28#include <QDesktopServices>
29#include <QInputDialog>
30#include <QKeySequence>
50 QProcess::startDetached(
"steam", {steamUrl});
104 impl_(std::make_unique<
Impl>(dialogParent, libraryController, launchController,
105 detailsPanelManager, imageCache, themeManager))
120 const bool isRunning =
121 impl_->launchController && impl_->launchController->isGameRunning(gameId);
127 auto* action = menu->addAction(tr(
"\u25A0 Stop"));
128 connect(action, &QAction::triggered,
this,
131 else if (isInstalled)
133 auto* action = menu->addAction(tr(
"\u25B6 Launch"));
134 action->setShortcut(QKeySequence(Qt::Key_Return));
135 connect(action, &QAction::triggered,
this,
138 else if (isSteamGame)
141 auto* action = menu->addAction(tr(
"\u21E9 Install via Steam"));
142 connect(action, &QAction::triggered,
this, [steamAppId]()
143 {
openSteamUrl(QStringLiteral(
"steam://install/%1").arg(steamAppId)); });
155 auto* action = menu->addAction(tr(
"\u2699 Configure..."));
156 action->setShortcut(QKeySequence(QStringLiteral(
"Ctrl+G")));
157 connect(action, &QAction::triggered,
this,
160 Game* g = impl_->libraryController->getGameForEdit(gameId);
164 if (dialog.exec() == QDialog::Accepted)
166 impl_->libraryController->updateGame(gameId, *g);
167 if (impl_->detailsPanelManager)
168 impl_->detailsPanelManager->update(gameId);
179 const Game* game,
bool includeMoreSettings)
183 auto* submenu = menu->addMenu(tr(
"\u2699 Quick Settings"));
184 impl_->themeManager->styleMenu(submenu);
186 auto addToggle = [
this, submenu, gameId](
const QString& label,
bool GameRunnerConfig::* field,
189 auto* action = submenu->addAction(label);
190 action->setCheckable(
true);
191 action->setChecked(currentValue);
192 connect(action, &QAction::triggered,
this, [
this, gameId, field](
bool checked)
193 { impl_->toggleRunnerConfigFlag(
this, gameId, field, checked); });
200 submenu->addSeparator();
203 if (includeMoreSettings)
205 submenu->addSeparator();
206 auto* more = submenu->addAction(tr(
"More settings..."));
207 connect(more, &QAction::triggered,
this,
210 Game* g = impl_->libraryController->getGameForEdit(gameId);
214 if (dialog.exec() == QDialog::Accepted)
216 impl_->libraryController->updateGame(gameId, *g);
217 if (impl_->detailsPanelManager)
218 impl_->detailsPanelManager->update(gameId);
235 menu->addAction(isFav ? tr(
"\u2605 Remove from Favorites") : tr(
"\u2605 Add to Favorites"));
236 action->setShortcut(QKeySequence(Qt::Key_F));
237 connect(action, &QAction::triggered,
this,
238 [
this, gameId, isFav]()
240 Game* g = impl_->libraryController->getGameForEdit(gameId);
244 impl_->libraryController->updateGame(gameId, *g);
258 auto* submenu = menu->addMenu(tr(
"Co&llections"));
259 impl_->themeManager->styleMenu(submenu);
261 auto collections = impl_->libraryController->getCollections();
262 std::vector<std::string> gameCollections = game->
collections;
264 for (
const auto& collection : collections)
266 const bool inCollection = std::find(gameCollections.begin(), gameCollections.end(),
267 collection) != gameCollections.end();
268 auto* action = submenu->addAction(QString::fromStdString(collection));
269 action->setCheckable(
true);
270 action->setChecked(inCollection);
271 connect(action, &QAction::triggered,
this,
272 [
this, gameId, collection, inCollection]()
275 impl_->libraryController->removeGameFromCollection(gameId, collection);
277 impl_->libraryController->addGameToCollection(gameId, collection);
281 if (!collections.empty())
282 submenu->addSeparator();
284 auto* newColl = submenu->addAction(tr(
"Create New..."));
285 connect(newColl, &QAction::triggered,
this,
289 QString name = QInputDialog::getText(impl_->dialogParent, tr(
"Create Collection"),
290 tr(
"Enter collection name:"),
291 QLineEdit::Normal, QString(), &ok);
292 if (!ok || name.isEmpty())
294 std::string nameStr = name.toStdString();
295 impl_->libraryController->addCollection(nameStr);
296 impl_->libraryController->addGameToCollection(gameId, nameStr);
313 auto* action = menu->addAction(tr(
"Change &Artwork..."));
314 connect(action, &QAction::triggered,
this,
315 [
this, appId, gameId]()
317 const Game* g = impl_->libraryController->getGame(gameId);
321 dialog.
setGame(QString::fromStdString(g->
name), appId);
322 if (dialog.exec() == QDialog::Accepted && dialog.
hasSelection())
324 if (impl_->imageCache)
325 impl_->imageCache->clearAll();
326 if (impl_->detailsPanelManager)
327 impl_->detailsPanelManager->update(gameId);
342 auto* action = menu->addAction(tr(
"View on &ProtonDB"));
343 connect(action, &QAction::triggered,
this,
346 QDesktopServices::openUrl(
347 QUrl(QStringLiteral(
"https://www.protondb.com/app/%1").arg(appId)));
362 const std::string folder = gamePath.parent_path().string();
363 auto* action = menu->addAction(tr(
"Open Game &Folder"));
364 connect(action, &QAction::triggered,
this, [folder]()
365 { QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(folder))); });
383 auto* manage = menu->addAction(tr(
"Manage in &Steam..."));
384 connect(manage, &QAction::triggered,
this, [appId]()
385 {
openSteamUrl(QStringLiteral(
"steam://nav/games/details/%1").arg(appId)); });
387 auto* store = menu->addAction(tr(
"View on Steam Sto&re"));
388 connect(store, &QAction::triggered,
this,
391 QDesktopServices::openUrl(
392 QUrl(QStringLiteral(
"https://store.steampowered.com/app/%1").arg(appId)));
404 auto* action = menu->addAction(tr(
"\u2715 Remove from Library"));
405 action->setShortcut(QKeySequence::Delete);
406 connect(action, &QAction::triggered,
this,
409 auto reply = QMessageBox::question(
410 impl_->dialogParent, tr(
"Confirm Removal"),
411 tr(
"Are you sure you want to remove this game from the library?"),
412 QMessageBox::Yes | QMessageBox::No);
413 if (reply == QMessageBox::Yes)
void toggleRunnerConfigFlag(GameActionFactory *q, const std::string &gameId, bool GameRunnerConfig::*field, bool newValue)
ThemeManager * themeManager
Impl(QWidget *parentWidget, core::GameLibraryController *libCtrl, core::LaunchController *launchCtrl, DetailsPanelManager *detailsMgr, GameThumbnailCache *imgCache, ThemeManager *themeMgr)
GameThumbnailCache * imageCache
DetailsPanelManager * detailsPanelManager
core::LaunchController * launchController
core::GameLibraryController * libraryController
void addQuickSettingsSubmenu(QMenu *menu, const std::string &gameId, const Game *game, bool includeMoreSettings)
"Quick Settings" submenu with MangoHud / GameMode / Gamescope / VkBasalt toggles.
~GameActionFactory() override
void addCollectionsSubmenu(QMenu *menu, const std::string &gameId, const Game *game)
"Collections" submenu listing every collection as a checkmarked action, plus "Create New....
void gameConfigUpdated(const std::string &gameId)
Configure dialog closed Accepted OR a Quick Setting was toggled.
GameActionFactory(QWidget *dialogParent, core::GameLibraryController *libraryController, core::LaunchController *launchController, DetailsPanelManager *detailsPanelManager, GameThumbnailCache *imageCache, ThemeManager *themeManager, QObject *qparent=nullptr)
void removeGameRequested(const std::string &gameId)
Remove from Library confirmed.
void favoriteChanged(const std::string &gameId)
Favorite state flipped. Caller should refresh the list.
void addChangeArtworkAction(QMenu *menu, const std::string &gameId, const Game *game)
"Change Artwork..." — opens SteamGridDBSelectorDialog if the game has a Steam App ID.
void addFavoriteAction(QMenu *menu, const std::string &gameId, const Game *game)
Favorite toggle (text flips between Add/Remove based on current state).
void addConfigureAction(QMenu *menu, const std::string &gameId)
Configure... — opens GameConfigDialog.
void addRemoveAction(QMenu *menu, const std::string &gameId)
"Remove from Library" with confirmation QMessageBox.
void artworkChanged(const std::string &gameId)
Artwork was changed via SteamGridDBSelectorDialog.
void stopRequested(const std::string &gameId)
The Stop action was triggered. Caller calls launchController->kill.
void launchRequested(const std::string &gameId)
The Launch action was triggered. Caller runs the launch pipeline.
void addProtonDBAction(QMenu *menu, const Game *game)
"View on ProtonDB" — opens https://www.protondb.com/app/{appId} in the default browser.
void addOpenFolderAction(QMenu *menu, const Game *game)
"Open Game Folder" — opens the executable's parent directory in the file manager.
void addSteamActions(QMenu *menu, const Game *game)
Steam actions — "Manage in Steam..." (if installed) and "View on Steam Store" (always for Steam games...
void addLaunchActions(QMenu *menu, const std::string &gameId, const Game *game)
Launch (if installed + not running), Stop (if running), or Install via Steam (if Steam game + not ins...
void gameListChanged()
Collections (add / remove / create+add) changed for gameId.
Complete representation of a game in the library.
GameMetadata metadata
Descriptive information and media.
std::vector< std::string > collections
Collections this game belongs to.
bool isFavorite
Is this marked as a favorite game?
std::string name
Display name shown in UI.
GameRunnerConfig runnerConfig
How to launch and run the game.
bool isInstalled() const
Check if game is currently installed.
GameSource source
Where the game was acquired from (Steam, GOG, Local, etc.).
bool hasSelection() const
void setGame(const QString &gameName, int steamAppId=0)
@ Steam
Steam store/platform.
static void openSteamUrl(const QString &steamUrl)
void openSteamUrl(const QString &steamUrl)
Configuration for how to launch and run a game.
bool enableVkBasalt
Enable VkBasalt shader injection.
std::string executablePath
Full path to game executable.
bool enableMangoHud
Enable MangoHud performance overlay.
bool enableGameMode
Enable GameMode CPU governor optimization.
bool enableGamescope
Enable Gamescope compositor.