game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
shortcuts_controller.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// ui/qt/shortcuts_controller.cpp
4// ==============================================================================
5// Extracted from MainWindow::setupKeyboardShortcuts() and
6// MainWindow::registerPaletteCommands() on 2026-04-19. ~1,017 LoC of
7// mostly-declarative shortcut/palette registration relocated. Behaviour
8// preserved verbatim; every private MainWindow method/member call is
9// routed through the back-pointer `mw_` (class is declared friend of
10// MainWindow).
11// ==============================================================================
12
14
15#include "command_palette.h"
37#include "mainwindow.h"
45#include "models/game.h"
51#include "shortcut_manager.h"
52#include "util/logger.h"
57#ifdef HAVE_WEBENGINE
59#endif
60#ifdef HAVE_QTERMWIDGET
62#endif
64#include "theme_manager.h"
65
66#include <QAction>
67#include <QActionGroup>
68#include <QApplication>
69#include <QClipboard>
70#include <QDesktopServices>
71#include <QGuiApplication>
72#include <QInputDialog>
73#include <QKeySequence>
74#include <QLineEdit>
75#include <QMenu>
76#include <QMessageBox>
77#include <QPointer>
78#include <QProcess>
79#include <QPushButton>
80#include <QShortcut>
81#include <QSlider>
82#include <QThreadPool>
83#include <QTimer>
84#include <QUrl>
85
86#include <algorithm>
87#include <functional>
88
89// ==============================================================================
90// Ctor / dtor
91// ==============================================================================
92
94 : QObject(qparent), mw_(mainWindow)
95{
96}
97
99
100// ==============================================================================
101// Extracted bodies
102// ==============================================================================
103
105{
106 // Initialize the centralized shortcut manager
108
109 // Register shortcuts with the manager for future customization support
110 // These are registered in addition to the existing QShortcuts below for backwards compatibility
111 // The manager provides persistence, conflict detection, and UI for customization
112
113 ShortcutBuilder("global.commandPalette")
114 .label("Command Palette")
116 .shortcut("Ctrl+Shift+P")
117 .description("Open command palette for quick access to all actions")
118 .global(true)
119 .action(
120 [this]()
121 {
122 if (mw_->commandPalette_)
123 mw_->commandPalette_->showPalette();
124 })
125 .registerWith(ShortcutManager::instance());
126
127 ShortcutBuilder("global.search")
128 .label("Focus Search")
130 .shortcut("Ctrl+F")
131 .description("Focus the search input")
132 .action(
133 [this]()
134 {
135 mw_->searchEdit_->setFocus();
136 mw_->searchEdit_->selectAll();
137 })
138 .registerWith(ShortcutManager::instance());
139
140 ShortcutBuilder("global.settings")
141 .label("Open Settings")
143 .shortcut("Ctrl+,")
144 .description("Open application settings")
145 .action([this]() { mw_->onSettingsClicked(); })
146 .registerWith(ShortcutManager::instance());
147
148 ShortcutBuilder("global.refresh")
149 .label("Refresh Library")
151 .shortcut("F5")
152 .description("Refresh game library")
153 .action([this]() { mw_->onRefreshLibrary(); })
154 .registerWith(ShortcutManager::instance());
155
156 ShortcutBuilder("game.launch")
157 .label("Launch Game")
159 .shortcut("Return")
160 .description("Launch the selected game")
161 .action([this]() { mw_->onLaunchClicked(); })
162 .canExecute([this]() { return !mw_->selectedGameId_.empty(); })
163 .registerWith(ShortcutManager::instance());
164
165 ShortcutBuilder("game.configure")
166 .label("Configure Game")
168 .shortcut("Ctrl+G")
169 .description("Open game configuration dialog")
170 .action(
171 [this]()
172 {
173 if (!mw_->selectedGameId_.empty())
174 {
175 Game* game = mw_->libraryController_->getGameForEdit(mw_->selectedGameId_);
176 if (game)
177 {
178 GameConfigDialog dialog(game, mw_);
179 if (dialog.exec() == QDialog::Accepted)
180 {
181 mw_->libraryController_->updateGame(mw_->selectedGameId_, *game);
182 mw_->detailsPanelManager_->update(mw_->selectedGameId_);
183 }
184 }
185 }
186 })
187 .canExecute([this]() { return !mw_->selectedGameId_.empty(); })
188 .registerWith(ShortcutManager::instance());
189
190 ShortcutBuilder("game.favorite")
191 .label("Toggle Favorite")
193 .shortcut("F")
194 .description("Toggle favorite status for selected game")
195 .action([this]() { mw_->toggleSelectedFavorite(); })
196 .canExecute([this]() { return !mw_->selectedGameId_.empty(); })
197 .registerWith(ShortcutManager::instance());
198
199 ShortcutBuilder("game.delete")
200 .label("Remove from Library")
202 .shortcut("Delete")
203 .description("Remove selected game(s) from library")
204 .action([this]() { mw_->deleteSelectedGame(); })
205 .canExecute([this]() { return !mw_->selectedGameId_.empty(); })
206 .registerWith(ShortcutManager::instance());
207
208 ShortcutBuilder("view.list")
209 .label("List View")
211 .shortcut("Ctrl+1")
212 .description("Switch to list view")
213 .action(
214 [this]()
215 {
216 mw_->listViewAction_->setChecked(true);
217 mw_->onViewModeChanged(ViewMode::List);
218 })
219 .registerWith(ShortcutManager::instance());
220
221 ShortcutBuilder("view.grid")
222 .label("Grid View")
224 .shortcut("Ctrl+2")
225 .description("Switch to grid view")
226 .action(
227 [this]()
228 {
229 mw_->gridViewAction_->setChecked(true);
230 mw_->onViewModeChanged(ViewMode::Grid);
231 })
232 .registerWith(ShortcutManager::instance());
233
234 ShortcutBuilder("view.compact")
235 .label("Compact View")
237 .shortcut("Ctrl+3")
238 .description("Switch to compact view")
239 .action(
240 [this]()
241 {
242 mw_->compactViewAction_->setChecked(true);
243 mw_->onViewModeChanged(ViewMode::Compact);
244 })
245 .registerWith(ShortcutManager::instance());
246
247 ShortcutBuilder("view.zoomIn")
248 .label("Zoom In")
250 .shortcut("Ctrl++")
251 .description("Increase zoom level")
252 .action(
253 [this]()
254 {
255 if (mw_->zoomSlider_)
256 mw_->zoomSlider_->setValue(
257 qMin(mw_->zoomSlider_->maximum(), mw_->zoomSlider_->value() + 10));
258 })
259 .registerWith(ShortcutManager::instance());
260
261 ShortcutBuilder("view.zoomOut")
262 .label("Zoom Out")
264 .shortcut("Ctrl+-")
265 .description("Decrease zoom level")
266 .action(
267 [this]()
268 {
269 if (mw_->zoomSlider_)
270 mw_->zoomSlider_->setValue(
271 qMax(mw_->zoomSlider_->minimum(), mw_->zoomSlider_->value() - 10));
272 })
273 .registerWith(ShortcutManager::instance());
274
275 ShortcutBuilder("view.zoomReset")
276 .label("Reset Zoom")
278 .shortcut("Ctrl+0")
279 .description("Reset zoom to 100%")
280 .action(
281 [this]()
282 {
283 if (mw_->zoomSlider_)
284 mw_->zoomSlider_->setValue(100);
285 })
286 .registerWith(ShortcutManager::instance());
287
288 ShortcutBuilder("panels.sidebar")
289 .label("Toggle Sidebar")
291 .shortcut("Ctrl+H")
292 .description("Show or hide the sidebar panel")
293 .action(
294 [this]()
295 {
296 if (mw_->sidebarContainer_)
297 mw_->togglePanel(mw_->sidebarContainer_, mw_->panelSidebarBtn_, "Sidebar");
298 })
299 .registerWith(ShortcutManager::instance());
300
301 ShortcutBuilder("panels.details")
302 .label("Toggle Details")
304 .shortcut("Ctrl+D")
305 .description("Show or hide the details panel")
306 .action(
307 [this]()
308 {
309 if (mw_->detailsContainer_)
310 mw_->togglePanel(mw_->detailsContainer_, mw_->panelDetailsBtn_, "Details");
311 })
312 .registerWith(ShortcutManager::instance());
313
314#ifdef HAVE_WEBENGINE
315 ShortcutBuilder("panels.homeassistant")
316 .label("Toggle Home Assistant")
318 .shortcut("Ctrl+Shift+H")
319 .description("Show or hide the Home Assistant panel")
320 .action(
321 [this]()
322 {
323 if (mw_->haContainer_)
324 {
325 bool willShow = !mw_->haContainer_->isVisible();
326 mw_->togglePanel(mw_->haContainer_, mw_->panelHABtn_, "Home Assistant");
327 if (willShow && mw_->haPanel_)
328 mw_->haPanel_->loadDashboard();
329 }
330 })
331 .registerWith(ShortcutManager::instance());
332#endif
333
334 ShortcutBuilder("nav.first")
335 .label("Go to First Game")
337 .shortcut("Home")
338 .description("Jump to first game in list")
339 .action(
340 [this]()
341 {
342 if (mw_->gameListProxy_ && mw_->gameListProxy_->rowCount() > 0)
343 {
344 mw_->gameList_->setCurrentIndex(mw_->gameListProxy_->index(0, 0));
345 mw_->gameList_->scrollToTop();
346 }
347 })
348 .registerWith(ShortcutManager::instance());
349
350 ShortcutBuilder("nav.last")
351 .label("Go to Last Game")
353 .shortcut("End")
354 .description("Jump to last game in list")
355 .action(
356 [this]()
357 {
358 if (mw_->gameListProxy_ && mw_->gameListProxy_->rowCount() > 0)
359 {
360 const int last = mw_->gameListProxy_->rowCount() - 1;
361 mw_->gameList_->setCurrentIndex(mw_->gameListProxy_->index(last, 0));
362 mw_->gameList_->scrollToBottom();
363 }
364 })
365 .registerWith(ShortcutManager::instance());
366
367 ShortcutBuilder("global.cheatsheet")
368 .label("Keyboard Shortcuts")
370 .shortcut("?")
371 .description("Show keyboard shortcut cheat sheet")
372 .action(
373 [this]()
374 {
375 auto* sheet = new ShortcutCheatSheet(mw_);
376 sheet->show();
377 })
378 .registerWith(ShortcutManager::instance());
379
380 // Load any saved customizations
382
383 // =========================================================================
384 // Additional shortcuts not covered by ShortcutManager above
385 // =========================================================================
386 // Registering via ShortcutBuilder keeps them in the customization UI and —
387 // critically — avoids double-registration, which Qt treats as an
388 // "ambiguous shortcut" (fires activatedAmbiguously on both copies, so
389 // neither `activated` slot runs). The pre-refactor code had ~20 duplicates
390 // here that silently broke Delete / F / Return / F5 on the game list.
391
392 ShortcutBuilder("game.launchCtrl")
393 .label("Launch Game (Ctrl+Enter)")
395 .shortcut("Ctrl+Return")
396 .description("Alternative launch binding (Ctrl+Enter)")
397 .action([this]() { mw_->onLaunchClicked(); })
398 .canExecute([this]() { return !mw_->selectedGameId_.empty(); })
399 .registerWith(ShortcutManager::instance());
400
401 ShortcutBuilder("game.selectAll")
402 .label("Select All Games")
404 .shortcut("Ctrl+A")
405 .description("Select all games in the current view")
406 .action([this]() { mw_->gameList_->selectAll(); })
407 .registerWith(ShortcutManager::instance());
408
409 ShortcutBuilder("global.clearSearch")
410 .label("Clear Search")
412 .shortcut("Escape")
413 .description("Clear the search box and return focus to the game list")
414 .action(
415 [this]()
416 {
417 if (mw_->searchEdit_ && !mw_->searchEdit_->text().isEmpty())
418 {
419 mw_->searchEdit_->clear();
420 if (mw_->gameList_)
421 mw_->gameList_->setFocus();
422 }
423 })
424 .canExecute([this]() { return mw_->searchEdit_ && !mw_->searchEdit_->text().isEmpty(); })
425 .registerWith(ShortcutManager::instance());
426
427 ShortcutBuilder("import.addGame")
428 .label("Add Game Manually")
430 .shortcut("Ctrl+N")
431 .description("Open the add-game dialog")
432 .action([this]() { mw_->onAddGameClicked(); })
433 .registerWith(ShortcutManager::instance());
434
435 // (Search debounce timer now lives inside ToolbarManager, which emits
436 // searchTextChanged with the already-debounced value.)
437
438 // Setup frame metrics update timer (refresh running game stats every 500ms)
439 // Uses lightweight mw_->detailsPanelManager_->updateRunningInfo() instead of full
440 // mw_->detailsPanelManager_->update()
441 mw_->frameMetricsTimer_ = new QTimer(mw_);
442 mw_->frameMetricsTimer_->setObjectName("frameMetricsTimer"); // For start/stop on minimize
443 mw_->frameMetricsTimer_->setInterval(750); // 750ms (was 500ms) - smoother but less CPU
444 connect(mw_->frameMetricsTimer_, &QTimer::timeout, mw_,
445 [this]()
446 {
447 // Only update if a game is selected and running - use lightweight method
448 if (!mw_->selectedGameId_.empty() &&
449 mw_->launchController_->isGameRunning(mw_->selectedGameId_))
450 {
451 mw_->detailsPanelManager_->updateRunningInfo(mw_->selectedGameId_);
452 }
453
454 // Update running game status widget in toolbar
455 mw_->updateRunningGameStatus();
456 });
457 mw_->frameMetricsTimer_->start();
458}
459
461{
462 if (!mw_->commandPalette_)
463 return;
464
465 std::vector<PaletteCommand> commands;
466
467 // =========================================================================
468 // Games Category
469 // =========================================================================
470
471 commands.push_back(CommandBuilder("game.launch")
472 .label("Launch Game")
473 .category("Games")
474 .shortcut("Enter")
475 .icon("\u25B6") // Play
476 .description("Launch the currently selected game")
477 .priority(100)
478 .action([this]() { mw_->onLaunchClicked(); })
480 [this]()
481 {
482 return !mw_->selectedGameId_.empty() &&
483 !mw_->launchController_->isGameRunning(
484 mw_->selectedGameId_);
485 })
486 .build());
487
488 commands.push_back(
489 CommandBuilder("game.stop")
490 .label("Stop Game")
491 .category("Games")
492 .icon("\xE2\x96\xA0") // Stop square
493 .description("Stop the currently running game")
494 .priority(99)
495 .action([this]() { mw_->onStopClicked(); })
497 [this]()
498 {
499 return !mw_->selectedGameId_.empty() &&
500 mw_->launchController_->isGameRunning(mw_->selectedGameId_);
501 })
503 [this]()
504 {
505 return !mw_->selectedGameId_.empty() &&
506 mw_->launchController_->isGameRunning(mw_->selectedGameId_);
507 })
508 .build());
509
510 commands.push_back(
511 CommandBuilder("game.configure")
512 .label("Configure Game...")
513 .category("Games")
514 .shortcut("Ctrl+G")
515 .icon("\xE2\x9A\x99") // Gear
516 .description("Open game configuration dialog")
517 .priority(80)
518 .action(
519 [this]()
520 {
521 if (!mw_->selectedGameId_.empty())
522 {
523 Game* game = mw_->libraryController_->getGameForEdit(mw_->selectedGameId_);
524 if (game)
525 {
526 GameConfigDialog dialog(game, mw_);
527 if (dialog.exec() == QDialog::Accepted)
528 {
529 mw_->libraryController_->updateGame(mw_->selectedGameId_, *game);
530 mw_->detailsPanelManager_->update(mw_->selectedGameId_);
531 }
532 }
533 }
534 })
535 .enabledWhen([this]() { return !mw_->selectedGameId_.empty(); })
536 .build());
537
538 commands.push_back(CommandBuilder("game.favorite")
539 .label("Toggle Favorite")
540 .category("Games")
541 .shortcut("F")
542 .icon("\u2605") // Star
543 .description("Add or remove game from favorites")
544 .priority(70)
545 .action([this]() { mw_->toggleSelectedFavorite(); })
546 .enabledWhen([this]() { return !mw_->selectedGameId_.empty(); })
547 .build());
548
549 commands.push_back(
550 CommandBuilder("game.openFolder")
551 .label("Open Game Folder")
552 .category("Games")
553 .icon("\u25A1") // Folder
554 .description("Open the game's installation folder in file manager")
555 .priority(60)
556 .action(
557 [this]()
558 {
559 if (!mw_->selectedGameId_.empty())
560 {
561 const Game* game = mw_->libraryController_->getGame(mw_->selectedGameId_);
562 if (game && !game->runnerConfig.executablePath.empty())
563 {
564 std::filesystem::path exePath(game->runnerConfig.executablePath);
565 QString folderPath =
566 QString::fromStdString(exePath.parent_path().string());
567 QDesktopServices::openUrl(QUrl::fromLocalFile(folderPath));
568 }
569 }
570 })
571 .enabledWhen([this]() { return !mw_->selectedGameId_.empty(); })
572 .build());
573
574 commands.push_back(CommandBuilder("game.protondb")
575 .label("View on ProtonDB")
576 .category("Games")
577 .icon("\u2617") // Wine
578 .description("Open ProtonDB page for mw_ game")
579 .priority(50)
580 .action(
581 [this]()
582 {
583 if (!mw_->selectedGameId_.empty())
584 {
585 const Game* game =
586 mw_->libraryController_->getGame(mw_->selectedGameId_);
587 if (game && game->metadata.steamAppId > 0)
588 {
589 QString url = QString("https://www.protondb.com/app/%1")
590 .arg(game->metadata.steamAppId);
591 QDesktopServices::openUrl(QUrl(url));
592 }
593 }
594 })
596 [this]()
597 {
598 if (mw_->selectedGameId_.empty())
599 return false;
600 const Game* game =
601 mw_->libraryController_->getGame(mw_->selectedGameId_);
602 return game && game->metadata.steamAppId > 0;
603 })
604 .build());
605
606 commands.push_back(CommandBuilder("game.delete")
607 .label("Remove from Library")
608 .category("Games")
609 .shortcut("Delete")
610 .icon("\u2715") // Remove
611 .description("Remove the selected game(s) from library")
612 .priority(10)
613 .action([this]() { mw_->deleteSelectedGame(); })
614 .enabledWhen([this]() { return !mw_->selectedGameId_.empty(); })
615 .build());
616
617 // =========================================================================
618 // Import Category
619 // =========================================================================
620
621 commands.push_back(CommandBuilder("import.addGame")
622 .label("Add Game Manually...")
623 .category("Import")
624 .shortcut("Ctrl+N")
625 .icon("\xE2\x9E\x95") // Plus
626 .description("Add a new game to the library manually")
627 .priority(90)
628 .action([this]() { mw_->onAddGameClicked(); })
629 .build());
630
631 commands.push_back(
632 CommandBuilder("import.scan")
633 .label("Import Games...")
634 .category("Import")
635 .icon("\u21E9") // Import
636 .description("Scan and import games from various sources")
637 .priority(85)
638 .action(
639 [this]()
640 {
641 GameImportDialog dialog(mw_->libraryController_.get(), mw_);
642 if (dialog.exec() == QDialog::Accepted)
643 {
645 mw_->libraryController_->getAllGames(),
646 [this](const std::string& gameId,
647 const std::function<void(Game&)>& updater)
648 { mw_->libraryController_->executeWithGame(gameId, updater); });
649 mw_->updateSourceFilters();
650 mw_->updateCategoryCounts();
651 mw_->refreshGameList();
652 QTimer::singleShot(500, mw_, [this]() { mw_->fetchMissingProtonDB(); });
653 }
654 })
655 .build());
656
657 commands.push_back(CommandBuilder("import.lutris")
658 .label("Install from Lutris...")
659 .category("Import")
660 .icon("\u2617") // Wine
661 .description("Search and install games from Lutris database")
662 .priority(80)
663 .action(
664 [this]()
665 {
666 LutrisSearchDialog dialog(mw_->libraryController_.get(), mw_);
667 dialog.exec();
668 })
669 .build());
670
671 commands.push_back(CommandBuilder("import.refresh")
672 .label("Refresh Library")
673 .category("Import")
674 .shortcut("F5")
675 .icon("\u21BB") // Refresh
676 .description("Refresh the game library")
677 .priority(70)
678 .action([this]() { mw_->onRefreshLibrary(); })
679 .build());
680
681 // =========================================================================
682 // View Category
683 // =========================================================================
684
685 commands.push_back(CommandBuilder("view.list")
686 .label("List View")
687 .category("View")
688 .shortcut("Ctrl+1")
689 .icon("\xE2\x98\xB0") // List icon
690 .description("Switch to list view")
691 .priority(90)
692 .action(
693 [this]()
694 {
695 mw_->listViewAction_->setChecked(true);
696 mw_->onViewModeChanged(ViewMode::List);
697 })
698 .build());
699
700 commands.push_back(CommandBuilder("view.grid")
701 .label("Grid View")
702 .category("View")
703 .shortcut("Ctrl+2")
704 .icon("\xE2\x8A\x9E") // Grid icon
705 .description("Switch to grid view")
706 .priority(89)
707 .action(
708 [this]()
709 {
710 mw_->gridViewAction_->setChecked(true);
711 mw_->onViewModeChanged(ViewMode::Grid);
712 })
713 .build());
714
715 commands.push_back(CommandBuilder("view.compact")
716 .label("Compact View")
717 .category("View")
718 .shortcut("Ctrl+3")
719 .icon("\xE2\x96\xA4") // Compact icon
720 .description("Switch to compact view")
721 .priority(88)
722 .action(
723 [this]()
724 {
725 mw_->compactViewAction_->setChecked(true);
726 mw_->onViewModeChanged(ViewMode::Compact);
727 })
728 .build());
729
730 commands.push_back(CommandBuilder("view.toggleSidebar")
731 .label("Toggle Sidebar")
732 .category("View")
733 .shortcut("Ctrl+H")
734 .icon("\xE2\x96\x8C") // Left bar
735 .description("Show or hide the sidebar panel")
736 .priority(80)
737 .action(
738 [this]()
739 {
740 if (mw_->sidebarContainer_)
741 mw_->togglePanel(mw_->sidebarContainer_,
742 mw_->panelSidebarBtn_, "Sidebar");
743 })
744 .build());
745
746 commands.push_back(CommandBuilder("view.toggleDetails")
747 .label("Toggle Details Panel")
748 .category("View")
749 .shortcut("Ctrl+D")
750 .icon("\xE2\x96\x90") // Right bar
751 .description("Show or hide the details panel")
752 .priority(79)
753 .action(
754 [this]()
755 {
756 if (mw_->detailsContainer_)
757 mw_->togglePanel(mw_->detailsContainer_,
758 mw_->panelDetailsBtn_, "Details");
759 })
760 .build());
761
762#ifdef HAVE_QTERMWIDGET
763 commands.push_back(CommandBuilder("view.toggleMonitor")
764 .label("Toggle System Monitor")
765 .category("View")
766 .icon("\u25B2") // Chart
767 .description("Show or hide the system monitor panel")
768 .priority(78)
769 .action(
770 [this]()
771 {
772 if (mw_->terminalContainer_)
773 mw_->togglePanel(mw_->terminalContainer_,
774 mw_->panelMonitorBtn_, "Monitor");
775 })
776 .build());
777#endif
778
779#ifdef HAVE_WEBENGINE
780 commands.push_back(CommandBuilder("view.toggleHomeAssistant")
781 .label("Toggle Home Assistant")
782 .category("View")
783 .icon("\u2302") // House
784 .description("Show or hide the Home Assistant panel")
785 .priority(77)
786 .action(
787 [this]()
788 {
789 if (mw_->haContainer_)
790 {
791 bool willShow = !mw_->haContainer_->isVisible();
792 mw_->togglePanel(mw_->haContainer_, mw_->panelHABtn_,
793 "Home Assistant");
794 if (willShow && mw_->haPanel_)
795 mw_->haPanel_->loadDashboard();
796 }
797 })
798 .build());
799#endif
800
801 commands.push_back(CommandBuilder("view.focusSearch")
802 .label("Focus Search")
803 .category("View")
804 .shortcut("Ctrl+F")
805 .icon("\u2315") // Search
806 .description("Focus the search input")
807 .priority(70)
808 .action(
809 [this]()
810 {
811 mw_->searchEdit_->setFocus();
812 mw_->searchEdit_->selectAll();
813 })
814 .build());
815
816 commands.push_back(CommandBuilder("view.clearSearch")
817 .label("Clear Search")
818 .category("View")
819 .shortcut("Escape")
820 .icon("\xE2\x9C\x95") // X
821 .description("Clear the search filter")
822 .priority(69)
823 .action(
824 [this]()
825 {
826 mw_->searchEdit_->clear();
827 mw_->gameList_->setFocus();
828 })
829 .enabledWhen([this]() { return !mw_->searchEdit_->text().isEmpty(); })
830 .build());
831
832 commands.push_back(
833 CommandBuilder("view.zoomIn")
834 .label("Zoom In")
835 .category("View")
836 .shortcut("Ctrl++")
837 .icon("\xE2\x9E\x95") // Plus
838 .description("Increase zoom level")
839 .priority(60)
840 .action(
841 [this]()
842 {
843 if (mw_->zoomSlider_)
844 mw_->zoomSlider_->setValue(
845 qMin(mw_->zoomSlider_->maximum(), mw_->zoomSlider_->value() + 10));
846 })
847 .build());
848
849 commands.push_back(
850 CommandBuilder("view.zoomOut")
851 .label("Zoom Out")
852 .category("View")
853 .shortcut("Ctrl+-")
854 .icon("\xE2\x9E\x96") // Minus
855 .description("Decrease zoom level")
856 .priority(59)
857 .action(
858 [this]()
859 {
860 if (mw_->zoomSlider_)
861 mw_->zoomSlider_->setValue(
862 qMax(mw_->zoomSlider_->minimum(), mw_->zoomSlider_->value() - 10));
863 })
864 .build());
865
866 commands.push_back(CommandBuilder("view.zoomReset")
867 .label("Reset Zoom")
868 .category("View")
869 .shortcut("Ctrl+0")
870 .icon("\u2315") // Search
871 .description("Reset zoom to 100%")
872 .priority(58)
873 .action(
874 [this]()
875 {
876 if (mw_->zoomSlider_)
877 mw_->zoomSlider_->setValue(100);
878 })
879 .build());
880
881 // =========================================================================
882 // Tools Category
883 // =========================================================================
884
885 commands.push_back(CommandBuilder("tools.runners")
886 .label("Manage Runners...")
887 .category("Tools")
888 .icon("\u25A3") // Package
889 .description("Manage Proton and Wine versions")
890 .priority(90)
891 .action(
892 [this]()
893 {
894 RunnerManagerDialog dialog(mw_);
895 dialog.exec();
896 })
897 .build());
898
899 commands.push_back(CommandBuilder("tools.systemInfo")
900 .label("System Info...")
901 .category("Tools")
902 .icon("\u25B2") // Chart
903 .description("View detailed system information")
904 .priority(80)
905 .action(
906 [this]()
907 {
909 widget->setWindowFlag(Qt::Window);
910 widget->setWindowTitle("System Readiness");
911 widget->resize(600, 700);
912 widget->show();
913 })
914 .build());
915
916 commands.push_back(CommandBuilder("tools.perfProfiles")
917 .label("Performance Profiles...")
918 .category("Tools")
919 .icon("\xE2\x9A\xA1") // Lightning
920 .description("Manage per-game performance profiles")
921 .priority(85)
922 .action(
923 [this]()
924 {
925 // Get currently selected game if any
926 const Game* game =
927 mw_->selectedGameId_.empty()
928 ? nullptr
929 : mw_->libraryController_->getGame(mw_->selectedGameId_);
930 if (mw_->performanceProfileService_)
931 {
933 game, mw_->performanceProfileService_.get(), mw_);
934 dialog.exec();
935 }
936 })
937 .build());
938
939 // =========================================================================
940 // Settings Category
941 // =========================================================================
942
943 commands.push_back(CommandBuilder("settings.open")
944 .label("Settings...")
945 .category("Settings")
946 .shortcut("Ctrl+,")
947 .icon("\xE2\x9A\x99") // Gear
948 .description("Open application settings")
949 .priority(100)
950 .action([this]() { mw_->onSettingsClicked(); })
951 .build());
952
953 // Add theme commands
954 auto& themeManager = ThemeManager::instance();
955 for (const QString& themeId : themeManager.getAvailableThemeIds())
956 {
957 const Theme* theme = themeManager.getTheme(themeId);
958 if (!theme)
959 continue;
960 QString capturedId = themeId; // Capture by value for lambda
961 commands.push_back(
962 CommandBuilder(QString("settings.theme.%1").arg(themeId))
963 .label(QString("Theme: %1").arg(theme->displayName))
964 .category("Settings")
965 .icon("\u25D0") // Theme
966 .description(QString("Switch to %1 theme").arg(theme->displayName))
967 .priority(50)
968 .action([capturedId]() { ThemeManager::instance().setTheme(capturedId); })
969 .build());
970 }
971
972 // =========================================================================
973 // Navigation Category
974 // =========================================================================
975
976 commands.push_back(CommandBuilder("nav.allGames")
977 .label("Go to All Games")
978 .category("Navigation")
979 .icon("\u25A6") // Games
980 .description("Show all games in library")
981 .priority(90)
982 .action(
983 [this]()
984 {
985 if (mw_->sidebarManager_)
986 mw_->sidebarManager_->selectCategoryByRow(0);
987 mw_->currentCategory_ = 0;
988 mw_->currentCollection_.clear();
989 mw_->refreshGameList();
990 })
991 .build());
992
993 commands.push_back(CommandBuilder("nav.favorites")
994 .label("Go to Favorites")
995 .category("Navigation")
996 .icon("\u2605") // Star
997 .description("Show favorite games")
998 .priority(85)
999 .action(
1000 [this]()
1001 {
1002 if (mw_->sidebarManager_)
1003 mw_->sidebarManager_->selectCategoryByText(
1004 QStringLiteral("Favorites"));
1005 })
1006 .build());
1007
1008 commands.push_back(CommandBuilder("nav.recentlyPlayed")
1009 .label("Go to Recently Played")
1010 .category("Navigation")
1011 .icon("\u23F1") // Clock
1012 .description("Show recently played games")
1013 .priority(84)
1014 .action(
1015 [this]()
1016 {
1017 if (mw_->sidebarManager_)
1018 mw_->sidebarManager_->selectCategoryByText(
1019 QStringLiteral("Recently"));
1020 })
1021 .build());
1022
1023 commands.push_back(CommandBuilder("nav.running")
1024 .label("Go to Running Games")
1025 .category("Navigation")
1026 .icon("\xE2\x96\xB6") // Play
1027 .description("Show currently running games")
1028 .priority(83)
1029 .action(
1030 [this]()
1031 {
1032 if (mw_->sidebarManager_)
1033 mw_->sidebarManager_->selectCategoryByText(
1034 QStringLiteral("Running"));
1035 })
1036 .build());
1037
1038 commands.push_back(CommandBuilder("nav.updates")
1039 .label("Go to Updates Available")
1040 .category("Navigation")
1041 .icon("\xE2\xAC\x86") // Up arrow
1042 .description("Show games with pending updates")
1043 .priority(82)
1044 .action(
1045 [this]()
1046 {
1047 if (mw_->sidebarManager_)
1048 mw_->sidebarManager_->selectCategoryByText(
1049 QStringLiteral("Updates"));
1050 })
1051 .build());
1052
1053 commands.push_back(CommandBuilder("tools.cheatsheet")
1054 .label("Keyboard Shortcuts")
1055 .category("Tools")
1056 .shortcut("?")
1057 .icon("\xE2\x8C\xA8") // Keyboard
1058 .description("Show keyboard shortcut cheat sheet")
1059 .priority(80)
1060 .action(
1061 [this]()
1062 {
1063 auto* sheet = new ShortcutCheatSheet(mw_);
1064 sheet->show();
1065 })
1066 .build());
1067
1068 // =========================================================================
1069 // Application Category
1070 // =========================================================================
1071
1072 commands.push_back(CommandBuilder("app.exit")
1073 .label("Exit")
1074 .category("Application")
1075 .icon("\u2715") // Exit
1076 .description("Exit the application")
1077 .priority(10)
1078 .action(
1079 [this]()
1080 {
1081 mw_->forceQuit_ = true;
1082 mw_->close();
1083 })
1084 .build());
1085
1086 // Register all commands
1087 mw_->commandPalette_->registerCommands(commands);
1088
1089 // =========================================================================
1090 // Dynamic Commands Provider (for context-sensitive commands)
1091 // =========================================================================
1092
1093 mw_->commandPalette_->registerDynamicProvider(
1094 [this]() -> std::vector<PaletteCommand>
1095 {
1096 std::vector<PaletteCommand> dynamic;
1097
1098 // Add "Stop [Game Name]" for each running game
1099 auto runningGames = mw_->launchController_->getAllRunningGames();
1100 for (const auto& info : runningGames)
1101 {
1102 std::string gameId = info.gameId;
1103 QString gameName = QString::fromStdString(info.gameName);
1104 dynamic.push_back(
1105 CommandBuilder(QString("dynamic.stop.%1").arg(QString::fromStdString(gameId)))
1106 .label(QString("Stop %1").arg(gameName))
1107 .category("Running Games")
1108 .icon("\xE2\x96\xA0") // Stop square
1109 .description(QString("Stop %1").arg(gameName))
1110 .priority(200) // High priority for running games
1111 .action([this, gameId]() { mw_->launchController_->stopGame(gameId); })
1112 .build());
1113 }
1114
1115 // Add collection navigation commands
1116 auto collections = mw_->libraryController_->getCollections();
1117 for (const auto& collection : collections)
1118 {
1119 QString collName = QString::fromStdString(collection);
1120 dynamic.push_back(
1121 CommandBuilder(QString("nav.collection.%1").arg(collName))
1122 .label(QString("Go to Collection: %1").arg(collName))
1123 .category("Navigation")
1124 .icon("\u25A3") // Collections
1125 .description(QString("Show games in %1 collection").arg(collName))
1126 .priority(70)
1127 .action(
1128 [this, collection]()
1129 {
1130 mw_->currentCollection_ = collection;
1131 mw_->currentCategory_ = 0;
1132 mw_->refreshGameList();
1133 })
1134 .build());
1135 }
1136
1137 return dynamic;
1138 });
1139}
Fluent builder for creating PaletteCommand objects.
CommandBuilder & visibleWhen(std::function< bool()> fn)
CommandBuilder & priority(int p)
CommandBuilder & icon(const QString &icon)
CommandBuilder & category(const QString &cat)
CommandBuilder & enabledWhen(std::function< bool()> fn)
CommandBuilder & description(const QString &desc)
PaletteCommand build() const
CommandBuilder & action(std::function< void()> fn)
Unified dialog for importing games from all sources.
void scanForRunningGames(const std::vector< Game * > &games, GameAccessCallback gameAccessCallback)
static GameProcessManager & instance()
Complete representation of a game in the library.
Definition game.h:767
GameMetadata metadata
Descriptive information and media.
Definition game.h:785
GameRunnerConfig runnerConfig
How to launch and run the game.
Definition game.h:784
Dialog for managing performance profiles for a game.
Fluent builder for creating ShortcutAction objects.
ShortcutBuilder & label(const QString &label)
ShortcutBuilder & description(const QString &desc)
ShortcutBuilder & category(const QString &cat)
ShortcutBuilder & action(std::function< void()> fn)
ShortcutBuilder & shortcut(const QKeySequence &seq)
ShortcutBuilder & global(bool g=true)
static ShortcutManager & instance()
Get singleton instance.
void loadCustomizations()
Load custom shortcuts from settings.
void initialize(QWidget *mainWidget)
Initialize manager with main widget for shortcut context.
ShortcutsController(MainWindow *mainWindow, QObject *qparent=nullptr)
void setupKeyboardShortcuts()
Register global / game / view keyboard shortcuts with ShortcutManager::instance().
void registerPaletteCommands()
Populate the command palette with every PaletteCommand.
~ShortcutsController() override
Compact widget showing system gaming readiness at a glance.
static ThemeManager & instance()
constexpr const char * View
constexpr const char * Global
constexpr const char * Navigation
constexpr const char * GameActions
constexpr const char * Panels
int steamAppId
Steam App ID (0 if not a Steam game).
Definition game.h:575
std::string executablePath
Full path to game executable.
Definition game.h:141
QString displayName