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
63class ThemeManager;
64class QMainWindow;
65class QAction;
66class QActionGroup;
67class QComboBox;
68class QLabel;
69class QLineEdit;
70class QPushButton;
71class QSlider;
72class QTimer;
75class 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).
79enum class ViewMode;
80
81namespace core
82{
86} // namespace core
87
88class 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 // -------------------------------------------------------------------------
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
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.
146
147 signals:
148 // Toolbar input events ----------------------------------------------------
149 void searchTextChanged(const QString& text);
150 void sortChanged(int index);
151 void zoomChanged(int value);
153
154 // Menu actions ------------------------------------------------------------
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 ------------------------------------------------
174
175 // Monitor (HAVE_QTERMWIDGET only) -----------------------------------------
176 void monitorCommandRequested(const QString& command);
178
179 private:
180 class Impl;
181 std::unique_ptr<Impl> impl_;
182};
Compact widget showing running game status in the toolbar.
void panelToggleRequested(const QString &panelName)
void viewModeChanged(ViewMode mode)
void themeSelected(const QString &themeId)
ToolbarManager(QMainWindow *mainWindow, core::GameLibraryController *libCtrl, core::LaunchController *launchCtrl, core::SettingsController *settingsCtrl, ThemeManager *themeManager, QObject *qparent=nullptr)
QToolButton * hamburgerButton() const
Hamburger menu button — toggled visible/hidden by MainWindow depending on the user's "hamburger vs me...
void downloadQueueRequested()
void addGameRequested()
QAction * compactViewAction() const
QLineEdit * searchEdit() const
QActionGroup * viewModeGroup() const
QPushButton * panelGamesButton() const
void setupToolbar()
Build the toolbar. Must be called exactly once after construction.
void settingsRequested()
QPushButton * panelSidebarButton() const
void installFromLutrisRequested()
QSlider * zoomSlider() const
void exitRequested()
void monitorCommandRequested(const QString &command)
RunningGameStatusWidget * runningGameStatusWidget() const
void zoomChanged(int value)
QPushButton * panelDetailsButton() const
void runningGameDetailsRequested()
void monitorRestartRequested()
void sortChanged(int index)
void searchTextChanged(const QString &text)
void exportImportRequested()
QComboBox * sortCombo() const
void importGamesRequested()
QAction * listViewAction() const
void libraryStatisticsRequested()
QLabel * zoomLabel() const
void manageRunnersRequested()
DraggableToolbar * draggableToolbar() const
void refreshThemeMenuSelection()
Rebuild the theme submenu's checked state after a theme change.
void applyTheme()
Re-apply theme colours to toolbar widgets.
QAction * gridViewAction() const
~ToolbarManager() override
void refreshLibraryRequested()
ViewMode
Definition mainwindow.h:75