game_launcher
1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
menubar_manager.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// ==============================================================================
3
// ui/qt/menubar_manager.h
4
// ==============================================================================
5
// Owner of the QMenuBar + all five top-level menus (File / Game / View /
6
// Tools / Help). Fourth manager in the MED-* family, extracted 2026-04-19.
7
// ==============================================================================
8
// Responsibilities:
9
// - Build the menu bar and the five top-level menus.
10
// - Populate the Game and View menus dynamically via aboutToShow, so
11
// per-game actions (Launch/Stop/Configure/Favorite/Collections) and
12
// current-state indicators (sort/view-mode checkboxes, panel
13
// visibility checkboxes) reflect the live model.
14
// - Own Quick-Settings toggles (MangoHud, GameMode, Gamescope, VkBasalt),
15
// Collections add/remove per game, Change Artwork, Library
16
// Statistics, and Install-from-Lutris flows — all have injected
17
// dependencies and don't need MainWindow state beyond the selected
18
// game id.
19
//
20
// Design parity with ToolbarManager / SidebarManager / DetailsPanelManager:
21
// - QObject-based, signal emissions for every action whose side-effect
22
// needs MainWindow state (addGame, removeGame, refresh, etc.).
23
// - Inline handling for actions whose dependencies are injected
24
// (libraryController mutations, dialogs that only need a parent).
25
// - Pimpl pattern hides the menu construction details.
26
//
27
// Selected-game tracking:
28
// MainWindow owns selectedGameId_. Before each Game menu open,
29
// MainWindow passes it via setSelectedGameId() so the aboutToShow
30
// handler has fresh state without reaching back into MainWindow.
31
// ==============================================================================
32
33
#pragma once
34
35
#include <QObject>
36
#include <QString>
37
#include <functional>
38
#include <memory>
39
#include <string>
40
41
class
ThemeManager
;
42
class
QMainWindow;
43
class
QMenuBar;
44
class
GameActionFactory
;
45
class
GameThumbnailCache
;
46
class
DetailsPanelManager
;
47
48
enum class
ViewMode
;
49
enum class
SortOption
;
50
51
namespace
core
52
{
53
class
GameLibraryController
;
54
class
LaunchController
;
55
class
SettingsController
;
56
}
// namespace core
57
58
class
MenuBarManager
:
public
QObject
59
{
60
Q_OBJECT
61
62
public
:
63
MenuBarManager
(QMainWindow* mainWindow,
core::GameLibraryController
* libraryController,
64
core::LaunchController
* launchController,
65
core::SettingsController
* settingsController,
66
DetailsPanelManager
* detailsPanelManager,
GameThumbnailCache
* imageCache,
67
GameActionFactory
* actionFactory,
ThemeManager
* themeManager,
68
QObject* qparent =
nullptr
);
69
~MenuBarManager
()
override
;
70
71
/// Build the menu bar and all five top-level menus. Call once.
72
void
setupMenus
();
73
74
/// Re-apply theme styling to every menu. MainWindow::applyTheme() drives
75
/// this on theme change; individual menus were already restyled on
76
/// aboutToShow before that signal, but this keeps the menu bar itself
77
/// consistent.
78
void
applyTheme
();
79
80
/// Propagate the current selection. MainWindow calls this every time
81
/// selectedGameId_ changes so the Game menu's aboutToShow handler can
82
/// read fresh state without grabbing MainWindow.
83
void
setSelectedGameId
(
const
std::string& gameId);
84
85
/// Current view-mode / sort-option — needed so the View menu's
86
/// checkbox indicators and Sort By radio group reflect reality.
87
void
setViewMode
(
ViewMode
mode);
88
void
setSortOption
(
SortOption
sort);
89
90
/// Panel-visibility getter. MainWindow installs a single functor so
91
/// the View menu's aboutToShow can tick the current panels without us
92
/// holding references to the container widgets. The functor receives
93
/// a panel name ("sidebar" | "games" | "details" | "monitor" | "ha")
94
/// and returns whether that panel is currently visible.
95
using
PanelVisibilityQuery
= std::function<bool(
const
QString&)>;
96
void
setPanelVisibilityQuery
(
PanelVisibilityQuery
query);
97
98
signals:
99
// Shared with ToolbarManager where applicable (same semantic names so
100
// MainWindow connects both to the same slot):
101
void
addGameRequested
();
102
void
importGamesRequested
();
103
void
installFromLutrisRequested
();
104
void
exportImportRequested
();
105
void
refreshLibraryRequested
();
106
void
settingsRequested
();
107
void
manageRunnersRequested
();
108
void
libraryStatisticsRequested
();
109
void
downloadQueueRequested
();
110
void
exitRequested
();
111
void
themeSelected
(
const
QString& themeId);
112
void
viewModeSelected
(
ViewMode
mode);
113
void
sortSelected
(
SortOption
sort);
114
void
panelToggleRequested
(
const
QString& name);
115
116
// Menu-bar-specific — relayed from the factory. MainWindow's existing
117
// slots listen here for back-compat and to avoid wiring the factory
118
// directly to MainWindow from two call sites.
119
void
launchRequested
(
const
std::string& gameId);
120
void
stopRequested
(
const
std::string& gameId);
121
void
favoriteChanged
(
const
std::string& gameId);
// factory already toggled
122
void
removeGameRequested
(
const
std::string& gameId);
123
void
artworkChanged
(
const
std::string& gameId);
124
125
// Zoom (MainWindow routes to ToolbarManager's slider):
126
void
zoomInRequested
();
127
void
zoomOutRequested
();
128
void
zoomResetRequested
();
129
130
// Menu mode (hamburger vs menu bar):
131
void
menuModeToggled
(
bool
useHamburger);
132
133
// Refresh notifications — relayed from GameActionFactory after it
134
// performs per-game mutations (Quick Settings toggle, Configure dialog
135
// accept, Collections add/remove). MainWindow handles the concrete
136
// refreshes (updateCollectionsList, refreshGameList, updateGameRow,
137
// image cache invalidation, etc.). artworkChanged is declared above
138
// in the menu-bar-specific block.
139
void
gameConfigUpdated
(
const
std::string& gameId);
140
void
gameListChanged
();
// source filters + category counts + gameList
141
void
runnersListChanged
();
142
void
commandPaletteRequested
();
143
144
private
:
145
class
Impl
;
146
std::unique_ptr<Impl> impl_;
147
};
DetailsPanelManager
Definition
details_panel_manager.h:61
GameActionFactory
Definition
game_action_factory.h:57
GameThumbnailCache
Definition
game_thumbnail_cache.h:41
MenuBarManager::Impl
Definition
menubar_manager.cpp:38
MenuBarManager::libraryStatisticsRequested
void libraryStatisticsRequested()
MenuBarManager::installFromLutrisRequested
void installFromLutrisRequested()
MenuBarManager::addGameRequested
void addGameRequested()
MenuBarManager::PanelVisibilityQuery
std::function< bool(const QString &)> PanelVisibilityQuery
Panel-visibility getter.
Definition
menubar_manager.h:95
MenuBarManager::gameListChanged
void gameListChanged()
MenuBarManager::setSortOption
void setSortOption(SortOption sort)
Definition
menubar_manager.cpp:523
MenuBarManager::zoomInRequested
void zoomInRequested()
MenuBarManager::sortSelected
void sortSelected(SortOption sort)
MenuBarManager::commandPaletteRequested
void commandPaletteRequested()
MenuBarManager::favoriteChanged
void favoriteChanged(const std::string &gameId)
MenuBarManager::stopRequested
void stopRequested(const std::string &gameId)
MenuBarManager::manageRunnersRequested
void manageRunnersRequested()
MenuBarManager::refreshLibraryRequested
void refreshLibraryRequested()
MenuBarManager::setViewMode
void setViewMode(ViewMode mode)
Current view-mode / sort-option — needed so the View menu's checkbox indicators and Sort By radio gro...
Definition
menubar_manager.cpp:518
MenuBarManager::~MenuBarManager
~MenuBarManager() override
MenuBarManager::setPanelVisibilityQuery
void setPanelVisibilityQuery(PanelVisibilityQuery query)
Definition
menubar_manager.cpp:528
MenuBarManager::runnersListChanged
void runnersListChanged()
MenuBarManager::importGamesRequested
void importGamesRequested()
MenuBarManager::removeGameRequested
void removeGameRequested(const std::string &gameId)
MenuBarManager::setupMenus
void setupMenus()
Build the menu bar and all five top-level menus. Call once.
Definition
menubar_manager.cpp:126
MenuBarManager::setSelectedGameId
void setSelectedGameId(const std::string &gameId)
Propagate the current selection.
Definition
menubar_manager.cpp:513
MenuBarManager::launchRequested
void launchRequested(const std::string &gameId)
MenuBarManager::viewModeSelected
void viewModeSelected(ViewMode mode)
MenuBarManager::exportImportRequested
void exportImportRequested()
MenuBarManager::gameConfigUpdated
void gameConfigUpdated(const std::string &gameId)
MenuBarManager::zoomOutRequested
void zoomOutRequested()
MenuBarManager::panelToggleRequested
void panelToggleRequested(const QString &name)
MenuBarManager::exitRequested
void exitRequested()
MenuBarManager::themeSelected
void themeSelected(const QString &themeId)
MenuBarManager::downloadQueueRequested
void downloadQueueRequested()
MenuBarManager::applyTheme
void applyTheme()
Re-apply theme styling to every menu.
Definition
menubar_manager.cpp:478
MenuBarManager::MenuBarManager
MenuBarManager(QMainWindow *mainWindow, core::GameLibraryController *libraryController, core::LaunchController *launchController, core::SettingsController *settingsController, DetailsPanelManager *detailsPanelManager, GameThumbnailCache *imageCache, GameActionFactory *actionFactory, ThemeManager *themeManager, QObject *qparent=nullptr)
Definition
menubar_manager.cpp:85
MenuBarManager::settingsRequested
void settingsRequested()
MenuBarManager::artworkChanged
void artworkChanged(const std::string &gameId)
MenuBarManager::zoomResetRequested
void zoomResetRequested()
MenuBarManager::menuModeToggled
void menuModeToggled(bool useHamburger)
ThemeManager
Definition
theme_manager.h:85
core::GameLibraryController
Definition
game_library_controller.h:102
core::LaunchController
Definition
launch_controller.h:100
core::SettingsController
Definition
settings_controller.h:128
ViewMode
ViewMode
Definition
mainwindow.h:75
SortOption
SortOption
Definition
mainwindow.h:86
core
Definition
app_controller.h:15
ui
qt
managers
menubar_manager.h
Generated by
1.16.1