game_launcher
1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
sidebar_manager.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// ==============================================================================
3
// ui/qt/sidebar_manager.h
4
// ==============================================================================
5
// Owner of the left-hand sidebar widget tree. Third in the MED-* manager
6
// family (after DetailsPanelManager and ToolbarManager). Extracted 2026-04-19.
7
// ==============================================================================
8
// Responsibilities:
9
// - Build the sidebar QWidget with four CollapsibleSections:
10
// Library (category filters: All / Favorites / Recently Played / …)
11
// Sources (per-source filter: Steam, GOG, Epic, Lutris, …)
12
// Runner (per-runner filter: Native / Proton / Wine variants)
13
// Collections (user-defined collections with CRUD)
14
// - Own all four QListWidgets + the "+" Create Collection button +
15
// the right-click Delete Collection menu on the collections list.
16
// - Expose the helper methods that keep counts and selections in sync:
17
// populateRunnerVersions / updateSourceFilters /
18
// updateCategoryCounts / updateCollectionsList.
19
// - Re-apply theme colours to the sidebar + all four lists.
20
//
21
// Dependencies (injected via constructor):
22
// - core::GameLibraryController* — read all games, add/remove collections
23
// - core::SettingsController* — unused directly, reserved for future
24
// CollapsibleSection state exposure
25
// - QtNotificationService* — success toast on collection creation
26
//
27
// Signal surface (handled by MainWindow):
28
// - categoryChanged(int row) — Library section selection
29
// - sourceChanged() — Sources section selection
30
// - runnerChanged() — Runner section selection
31
// - collectionChanged(QString name) — Collections selection; empty means
32
// "All" (no collection filter)
33
// - collectionDeleted(QString name) — After the user confirmed deletion
34
// in the context menu
35
//
36
// Widget accessors (needed by cross-module callers):
37
// - categoryList() / sourceFilterList() / runnerFilterList() /
38
// collectionsList() — raw pointers to the QListWidgets so that existing
39
// refreshGameList() + keyboard-shortcut / command-palette code can
40
// read selection state without threading the manager everywhere.
41
// - widget() — the sidebar root, for splitter integration.
42
//
43
// Notes on modernisation:
44
// The four lists are QListWidget today. A future pass may migrate them to
45
// QListView + per-list QAbstractListModel subclasses (identified in the
46
// 2026-04 Qt audit). This extraction is a drop-in prerequisite; the
47
// accessor surface is narrow enough that the migration can happen inside
48
// SidebarManager without touching MainWindow.
49
// ==============================================================================
50
51
#pragma once
52
53
#include <QObject>
54
#include <QString>
55
#include <memory>
56
57
class
ThemeManager
;
58
class
QWidget;
59
class
QtNotificationService
;
60
61
namespace
core
62
{
63
class
GameLibraryController
;
64
class
LaunchController
;
65
class
SettingsController
;
66
}
// namespace core
67
68
class
SidebarManager
:
public
QObject
69
{
70
Q_OBJECT
71
72
public
:
73
SidebarManager
(
core::GameLibraryController
* libraryController,
74
core::LaunchController
* launchController,
75
core::SettingsController
* settingsController,
76
QtNotificationService
* notificationService,
ThemeManager
* themeManager,
77
QWidget* parent, QObject* qparent =
nullptr
);
78
~SidebarManager
()
override
;
79
80
/// Build the sidebar widget tree. Call once after construction.
81
void
setupSidebar
();
82
83
/// Re-apply theme colours (called from MainWindow::applyTheme()).
84
void
applyTheme
();
85
86
/// The root widget — slot into MainWindow's splitter.
87
QWidget*
widget
()
const
;
88
89
// Helper methods that keep counts + selection in sync. Called by
90
// MainWindow from refreshGameList() / on library mutation.
91
void
populateRunnerVersions
();
92
void
updateSourceFilters
();
93
void
updateCategoryCounts
();
94
void
updateCollectionsList
();
95
void
showCreateCollectionDialog
(QWidget* dialogParent);
96
97
// Semantic accessors — replace the raw QListWidget pointers the
98
// QListWidget era exposed. Each of the four lists is now a QListView
99
// backed by a QAbstractListModel subclass (see sidebar_models.h), so
100
// the only sanctioned reads are by semantic meaning.
101
int
selectedCategoryIndex
()
const
;
102
int
selectedSourceValue
()
const
;
///< GameSource enum int, -1 = "All"
103
QString
selectedRunnerVersion
()
const
;
///< "" = "All", "native" = Native
104
QString
selectedCollection
()
const
;
///< "" = "All"
105
106
// Programmatic selection mutation — used by keyboard shortcuts,
107
// command palette, and the empty-state "Show All Games" button.
108
void
selectCategoryByRow
(
int
row);
109
void
selectCategoryByText
(
const
QString& partialText);
110
void
clearCollectionsSelection
();
111
112
signals:
113
void
categoryChanged
(
int
row);
114
void
sourceChanged
();
115
void
runnerChanged
();
116
void
collectionChanged
(
const
QString& collectionName);
117
void
collectionDeleted
(
const
QString& collectionName);
118
119
private
:
120
class
Impl
;
121
std::unique_ptr<Impl> impl_;
122
};
QtNotificationService
Definition
qt_notification_service.h:88
SidebarManager::Impl
Definition
sidebar_manager.cpp:66
SidebarManager::selectedCollection
QString selectedCollection() const
"" = "All"
Definition
sidebar_manager.cpp:438
SidebarManager::setupSidebar
void setupSidebar()
Build the sidebar widget tree. Call once after construction.
Definition
sidebar_manager.cpp:163
SidebarManager::selectedSourceValue
int selectedSourceValue() const
GameSource enum int, -1 = "All".
Definition
sidebar_manager.cpp:416
SidebarManager::populateRunnerVersions
void populateRunnerVersions()
Definition
sidebar_manager.cpp:480
SidebarManager::runnerChanged
void runnerChanged()
SidebarManager::selectCategoryByRow
void selectCategoryByRow(int row)
Definition
sidebar_manager.cpp:449
SidebarManager::applyTheme
void applyTheme()
Re-apply theme colours (called from MainWindow::applyTheme()).
Definition
sidebar_manager.cpp:364
SidebarManager::sourceChanged
void sourceChanged()
SidebarManager::showCreateCollectionDialog
void showCreateCollectionDialog(QWidget *dialogParent)
Definition
sidebar_manager.cpp:594
SidebarManager::selectedCategoryIndex
int selectedCategoryIndex() const
Definition
sidebar_manager.cpp:407
SidebarManager::widget
QWidget * widget() const
The root widget — slot into MainWindow's splitter.
Definition
sidebar_manager.cpp:402
SidebarManager::selectCategoryByText
void selectCategoryByText(const QString &partialText)
Definition
sidebar_manager.cpp:459
SidebarManager::updateSourceFilters
void updateSourceFilters()
Definition
sidebar_manager.cpp:504
SidebarManager::clearCollectionsSelection
void clearCollectionsSelection()
Definition
sidebar_manager.cpp:469
SidebarManager::updateCategoryCounts
void updateCategoryCounts()
Definition
sidebar_manager.cpp:524
SidebarManager::collectionDeleted
void collectionDeleted(const QString &collectionName)
SidebarManager::SidebarManager
SidebarManager(core::GameLibraryController *libraryController, core::LaunchController *launchController, core::SettingsController *settingsController, QtNotificationService *notificationService, ThemeManager *themeManager, QWidget *parent, QObject *qparent=nullptr)
Definition
sidebar_manager.cpp:146
SidebarManager::categoryChanged
void categoryChanged(int row)
SidebarManager::selectedRunnerVersion
QString selectedRunnerVersion() const
"" = "All", "native" = Native
Definition
sidebar_manager.cpp:427
SidebarManager::~SidebarManager
~SidebarManager() override
SidebarManager::collectionChanged
void collectionChanged(const QString &collectionName)
SidebarManager::updateCollectionsList
void updateCollectionsList()
Definition
sidebar_manager.cpp:571
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
core
Definition
app_controller.h:15
ui
qt
managers
sidebar_manager.h
Generated by
1.16.1