game_launcher
1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
toolbar_manager.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// ==============================================================================
3
// ui/qt/toolbar_manager.h
4
// ==============================================================================
5
// Owner of the main-window toolbar widget tree and the code that builds it.
6
// Extracted from MainWindow as the follow-on to MED-7 (DetailsPanelManager).
7
// ==============================================================================
8
// Responsibilities:
9
// - Construct the DraggableToolbar and all of its sections:
10
// * Menu — hamburger button + main popup menu
11
// * Panels — toggle buttons for sidebar / games / details / monitor /
12
// Home Assistant
13
// * Controls — search, sort, view-mode buttons, zoom slider
14
// * Monitor — btop/htop/top/shell selector (HAVE_QTERMWIDGET)
15
// * Running — running-game status widget
16
// - Persist section order, lock state, and search/zoom widths via
17
// SettingsController.
18
// - Apply theme updates to toolbar widgets.
19
//
20
// Dependencies (injected via constructor):
21
// - QMainWindow* — parent for widgets + dialog parenting
22
// - core::GameLibraryController* — library-read used by System Info /
23
// Library Statistics dialogs
24
// - core::LaunchController* — unused today but reserved so the
25
// running-game status widget can migrate
26
// - core::SettingsController* — persistence of toolbar state + read of
27
// HAVE_WEBENGINE / HAVE_QTERMWIDGET
28
// enable flags
29
//
30
// Signal surface (handled by MainWindow):
31
// Input events:
32
// searchTextChanged / sortChanged / zoomChanged / viewModeChanged
33
// Menu actions:
34
// addGameRequested, importGamesRequested, installFromLutrisRequested,
35
// refreshLibraryRequested, settingsRequested, manageRunnersRequested,
36
// libraryStatisticsRequested, exportImportRequested,
37
// downloadQueueRequested, exitRequested
38
// Theme:
39
// themeSelected(QString themeId)
40
// Panel toggles:
41
// panelToggleRequested(QString name) where name is one of
42
// "sidebar" | "games" | "details" | "monitor" | "ha"
43
// Running-game interaction:
44
// runningGameDetailsRequested() — user clicked the running-game widget
45
// Monitor (HAVE_QTERMWIDGET):
46
// monitorCommandRequested(QString cmd) — combobox or restart button
47
// asked to (re)start a command
48
//
49
// Notes:
50
// - View-mode QActions (list / grid / compact) are exposed via accessors
51
// because the command palette and keyboard-shortcut handlers in
52
// MainWindow need to check/update them.
53
// - Impl is hidden behind a pimpl; MainWindow doesn't see the internal
54
// widget graph.
55
// ==============================================================================
56
57
#pragma once
58
59
#include <QObject>
60
#include <QString>
61
#include <memory>
62
63
class
ThemeManager
;
64
class
QMainWindow;
65
class
QAction;
66
class
QActionGroup;
67
class
QComboBox;
68
class
QLabel;
69
class
QLineEdit;
70
class
QPushButton;
71
class
QSlider;
72
class
QTimer;
73
class
DraggableToolbar
;
74
class
RunningGameStatusWidget
;
75
class
QToolButton;
76
77
// MainWindow-side enums (declared in mainwindow.h but forwarded here so the
78
// signal signatures don't require pulling in that header).
79
enum class
ViewMode
;
80
81
namespace
core
82
{
83
class
GameLibraryController
;
84
class
LaunchController
;
85
class
SettingsController
;
86
}
// namespace core
87
88
class
ToolbarManager
:
public
QObject
89
{
90
Q_OBJECT
91
92
public
:
93
ToolbarManager
(QMainWindow* mainWindow,
core::GameLibraryController
* libCtrl,
94
core::LaunchController
* launchCtrl,
core::SettingsController
* settingsCtrl,
95
ThemeManager
* themeManager, QObject* qparent =
nullptr
);
96
~ToolbarManager
()
override
;
97
98
/// Build the toolbar. Must be called exactly once after construction.
99
void
setupToolbar
();
100
101
/// Re-apply theme colours to toolbar widgets.
102
void
applyTheme
();
103
104
// -------------------------------------------------------------------------
105
// Widget accessors for MainWindow code that reaches past the toolbar
106
// boundary:
107
// - View-mode actions are driven by the command palette + keyboard
108
// shortcuts.
109
// - Panel toggle buttons need `setChecked()` updates after
110
// programmatic panel toggles.
111
// - Search edit is focused by Ctrl+F.
112
// - Running-game status widget is updated from the running-game timer.
113
// -------------------------------------------------------------------------
114
DraggableToolbar
*
draggableToolbar
()
const
;
115
116
QLineEdit*
searchEdit
()
const
;
117
QComboBox*
sortCombo
()
const
;
118
QSlider*
zoomSlider
()
const
;
119
QLabel*
zoomLabel
()
const
;
120
121
QAction*
listViewAction
()
const
;
122
QAction*
gridViewAction
()
const
;
123
QAction*
compactViewAction
()
const
;
124
QActionGroup*
viewModeGroup
()
const
;
125
126
QPushButton*
panelSidebarButton
()
const
;
127
QPushButton*
panelGamesButton
()
const
;
128
QPushButton*
panelDetailsButton
()
const
;
129
#ifdef HAVE_QTERMWIDGET
130
QPushButton* panelMonitorButton()
const
;
131
QComboBox* monitorTypeCombo()
const
;
132
QPushButton* monitorRestartButton()
const
;
133
#endif
134
#ifdef HAVE_WEBENGINE
135
QPushButton* panelHAButton()
const
;
136
#endif
137
138
RunningGameStatusWidget
*
runningGameStatusWidget
()
const
;
139
140
/// Hamburger menu button — toggled visible/hidden by MainWindow depending
141
/// on the user's "hamburger vs menu bar" preference.
142
QToolButton*
hamburgerButton
()
const
;
143
144
/// Rebuild the theme submenu's checked state after a theme change.
145
void
refreshThemeMenuSelection
();
146
147
signals:
148
// Toolbar input events ----------------------------------------------------
149
void
searchTextChanged
(
const
QString& text);
150
void
sortChanged
(
int
index);
151
void
zoomChanged
(
int
value);
152
void
viewModeChanged
(
ViewMode
mode);
153
154
// Menu actions ------------------------------------------------------------
155
void
addGameRequested
();
156
void
importGamesRequested
();
157
void
installFromLutrisRequested
();
158
void
refreshLibraryRequested
();
159
void
settingsRequested
();
160
void
manageRunnersRequested
();
161
void
libraryStatisticsRequested
();
162
void
exportImportRequested
();
163
void
downloadQueueRequested
();
164
void
exitRequested
();
165
166
// Theme -------------------------------------------------------------------
167
void
themeSelected
(
const
QString& themeId);
168
169
// Panel toggles (panelName: sidebar | games | details | monitor | ha) -----
170
void
panelToggleRequested
(
const
QString& panelName);
171
172
// Running-game interaction ------------------------------------------------
173
void
runningGameDetailsRequested
();
174
175
// Monitor (HAVE_QTERMWIDGET only) -----------------------------------------
176
void
monitorCommandRequested
(
const
QString& command);
177
void
monitorRestartRequested
();
178
179
private
:
180
class
Impl
;
181
std::unique_ptr<Impl> impl_;
182
};
DraggableToolbar
Definition
draggable_toolbar.h:33
RunningGameStatusWidget
Compact widget showing running game status in the toolbar.
Definition
running_game_status_widget.h:24
ThemeManager
Definition
theme_manager.h:85
ToolbarManager::Impl
Definition
toolbar_manager.cpp:45
ToolbarManager::panelToggleRequested
void panelToggleRequested(const QString &panelName)
ToolbarManager::viewModeChanged
void viewModeChanged(ViewMode mode)
ToolbarManager::themeSelected
void themeSelected(const QString &themeId)
ToolbarManager::ToolbarManager
ToolbarManager(QMainWindow *mainWindow, core::GameLibraryController *libCtrl, core::LaunchController *launchCtrl, core::SettingsController *settingsCtrl, ThemeManager *themeManager, QObject *qparent=nullptr)
Definition
toolbar_manager.cpp:143
ToolbarManager::hamburgerButton
QToolButton * hamburgerButton() const
Hamburger menu button — toggled visible/hidden by MainWindow depending on the user's "hamburger vs me...
Definition
toolbar_manager.cpp:827
ToolbarManager::downloadQueueRequested
void downloadQueueRequested()
ToolbarManager::addGameRequested
void addGameRequested()
ToolbarManager::compactViewAction
QAction * compactViewAction() const
Definition
toolbar_manager.cpp:780
ToolbarManager::searchEdit
QLineEdit * searchEdit() const
Definition
toolbar_manager.cpp:755
ToolbarManager::viewModeGroup
QActionGroup * viewModeGroup() const
Definition
toolbar_manager.cpp:784
ToolbarManager::panelGamesButton
QPushButton * panelGamesButton() const
Definition
toolbar_manager.cpp:793
ToolbarManager::setupToolbar
void setupToolbar()
Build the toolbar. Must be called exactly once after construction.
Definition
toolbar_manager.cpp:158
ToolbarManager::settingsRequested
void settingsRequested()
ToolbarManager::panelSidebarButton
QPushButton * panelSidebarButton() const
Definition
toolbar_manager.cpp:789
ToolbarManager::installFromLutrisRequested
void installFromLutrisRequested()
ToolbarManager::zoomSlider
QSlider * zoomSlider() const
Definition
toolbar_manager.cpp:763
ToolbarManager::exitRequested
void exitRequested()
ToolbarManager::monitorCommandRequested
void monitorCommandRequested(const QString &command)
ToolbarManager::runningGameStatusWidget
RunningGameStatusWidget * runningGameStatusWidget() const
Definition
toolbar_manager.cpp:822
ToolbarManager::zoomChanged
void zoomChanged(int value)
ToolbarManager::panelDetailsButton
QPushButton * panelDetailsButton() const
Definition
toolbar_manager.cpp:797
ToolbarManager::runningGameDetailsRequested
void runningGameDetailsRequested()
ToolbarManager::monitorRestartRequested
void monitorRestartRequested()
ToolbarManager::sortChanged
void sortChanged(int index)
ToolbarManager::searchTextChanged
void searchTextChanged(const QString &text)
ToolbarManager::exportImportRequested
void exportImportRequested()
ToolbarManager::sortCombo
QComboBox * sortCombo() const
Definition
toolbar_manager.cpp:759
ToolbarManager::importGamesRequested
void importGamesRequested()
ToolbarManager::listViewAction
QAction * listViewAction() const
Definition
toolbar_manager.cpp:772
ToolbarManager::libraryStatisticsRequested
void libraryStatisticsRequested()
ToolbarManager::zoomLabel
QLabel * zoomLabel() const
Definition
toolbar_manager.cpp:767
ToolbarManager::manageRunnersRequested
void manageRunnersRequested()
ToolbarManager::draggableToolbar
DraggableToolbar * draggableToolbar() const
Definition
toolbar_manager.cpp:751
ToolbarManager::refreshThemeMenuSelection
void refreshThemeMenuSelection()
Rebuild the theme submenu's checked state after a theme change.
Definition
toolbar_manager.cpp:832
ToolbarManager::applyTheme
void applyTheme()
Re-apply theme colours to toolbar widgets.
Definition
toolbar_manager.cpp:683
ToolbarManager::gridViewAction
QAction * gridViewAction() const
Definition
toolbar_manager.cpp:776
ToolbarManager::~ToolbarManager
~ToolbarManager() override
ToolbarManager::refreshLibraryRequested
void refreshLibraryRequested()
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
core
Definition
app_controller.h:15
ui
qt
managers
toolbar_manager.h
Generated by
1.16.1