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
57class ThemeManager;
58class QWidget;
60
61namespace core
62{
66} // namespace core
67
68class SidebarManager : public QObject
69{
70 Q_OBJECT
71
72 public:
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.
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);
111
112 signals:
113 void categoryChanged(int row);
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};
QString selectedCollection() const
"" = "All"
void setupSidebar()
Build the sidebar widget tree. Call once after construction.
int selectedSourceValue() const
GameSource enum int, -1 = "All".
void runnerChanged()
void selectCategoryByRow(int row)
void applyTheme()
Re-apply theme colours (called from MainWindow::applyTheme()).
void sourceChanged()
void showCreateCollectionDialog(QWidget *dialogParent)
int selectedCategoryIndex() const
QWidget * widget() const
The root widget — slot into MainWindow's splitter.
void selectCategoryByText(const QString &partialText)
void clearCollectionsSelection()
void collectionDeleted(const QString &collectionName)
SidebarManager(core::GameLibraryController *libraryController, core::LaunchController *launchController, core::SettingsController *settingsController, QtNotificationService *notificationService, ThemeManager *themeManager, QWidget *parent, QObject *qparent=nullptr)
void categoryChanged(int row)
QString selectedRunnerVersion() const
"" = "All", "native" = Native
~SidebarManager() override
void collectionChanged(const QString &collectionName)