game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
gameimportdialog.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/gameimportdialog.h
4// ==============================================================================
5// Unified game import dialog for all sources
6// ==============================================================================
7// Provides a single interface to import games from:
8// - Steam (installed + owned games)
9// - Lutris (Wine game manager)
10// - Bottles (Wine prefix manager)
11// - Heroic Launcher (Epic + GOG)
12// - Legendary (Epic Games CLI)
13// - Native Linux games
14// - Wine prefixes
15// ==============================================================================
16
17#pragma once
18
21
22#include <QCheckBox>
23#include <QDialog>
24#include <QGroupBox>
25#include <QLabel>
26#include <QProgressBar>
27#include <QPushButton>
28#include <QThread>
29#include <QTreeWidget>
30
31namespace core
32{
34}
35
36class ThemeManager;
37
38// ==============================================================================
39// Import Source Configuration
40// ==============================================================================
41
42/**
43 * @brief Configuration for which sources to scan
44 */
46{
47 bool steam = true;
48 bool lutris = true;
49 bool bottles = true;
50 bool heroicEpic = true;
51 bool heroicGOG = true;
52 bool legendary = true;
53 bool nativeGames = true;
54 bool winePrefixes = false; // Off by default (slower, less useful)
55};
56
57/**
58 * @brief Statistics for a single import source
59 */
61{
62 QString name;
63 QString icon;
64 int gamesFound = 0;
65 int gamesNew = 0; // Not already in library
66 bool available = false;
67 bool enabled = true;
68};
69
70// ==============================================================================
71// Unified Import Item
72// ==============================================================================
73
74/**
75 * @brief Unified structure for all importable games
76 *
77 * Wraps either a SteamGame or ScannedGame with common interface
78 */
80{
92
93 QString name;
95 QString sourceName; // Display name: "Steam", "Lutris", etc.
96 QString sourceIcon; // Icon/emoji for source
97 QString runner; // "Native", "Wine", "Proton"
98 QString path; // Install path or executable
99 uint64_t sizeBytes = 0;
100 bool isInstalled = true;
101 bool alreadyImported = false;
103
104 // Underlying data (one will be set)
105 std::shared_ptr<SteamGame> steamGame;
106 std::shared_ptr<ScannedGame> scannedGame;
107
108 // Convert to Game for import
109 Game toGame() const;
110
111 // Get unique ID for deduplication
112 QString getUniqueId() const;
113};
114
115// ==============================================================================
116// Import Worker
117// ==============================================================================
118
119/**
120 * @brief Background worker for scanning all sources
121 */
122class GameImportWorker : public QObject
123{
124 Q_OBJECT
125
126 public:
127 explicit GameImportWorker(QObject* parent = nullptr);
128
129 void setSourceConfig(const ImportSourceConfig& config);
130
131 public slots:
132 void doScan();
133 void cancel();
134
135 signals:
136 void progressUpdate(const QString& source, const QString& operation, int percent);
137 void sourceComplete(const QString& source, int gamesFound);
138 void scanComplete(const std::vector<ImportableGame>& games);
139 void scanError(const QString& error);
140
141 private:
142 void scanSteam();
143 void scanLutris();
144 void scanBottles();
145 void scanHeroic();
146 void scanLegendary();
147 void scanNative();
148 void scanWinePrefixes();
149 void deduplicateResults();
150
151 ImportSourceConfig config_;
152 std::vector<ImportableGame> results_;
153 std::atomic<bool> cancelled_{false};
154};
155
156// ==============================================================================
157// Unified Import Dialog
158// ==============================================================================
159
160/**
161 * @brief Unified dialog for importing games from all sources
162 *
163 * Replaces both SteamImportDialog and GameScannerImportDialog with a single
164 * cohesive interface that allows users to:
165 * - Select which sources to scan
166 * - See per-source statistics
167 * - Filter and select games to import
168 * - Import selected games with one click
169 */
170class GameImportDialog : public QDialog
171{
172 Q_OBJECT
173
174 public:
175 explicit GameImportDialog(core::GameLibraryController* libraryController,
176 QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
177 ~GameImportDialog() override;
178
179 private slots:
180 void onScanClicked();
181 void onProgressUpdate(const QString& source, const QString& operation, int percent);
182 void onSourceComplete(const QString& source, int gamesFound);
183 void onScanComplete(const std::vector<ImportableGame>& games);
184 void onScanError(const QString& error);
185 void onImportClicked();
186 void onSelectAll();
187 void onSelectNone();
188 void onSelectInstalled();
189 void onFilterChanged();
190 void onSourceToggled();
191 void onItemChanged(QTreeWidgetItem* item, int column);
192 void applyTheme();
193
194 private:
195 void setupUI();
196 void setupSourcePanel();
197 void setupResultsPanel();
198 void updateSourceStats();
199 void populateGameList();
200 void updateStats();
201 void markAlreadyImported();
202
203 QString getSourceDisplayName(ImportableGame::SourceType type) const;
204 QString getSourceIcon(ImportableGame::SourceType type) const;
205 QString getRunnerDisplayName(const QString& runner) const;
206 QString formatSize(uint64_t bytes) const;
207
208 // UI Components - Source Selection
209 QGroupBox* sourceGroup_;
210 QCheckBox* steamCheck_;
211 QCheckBox* lutrisCheck_;
212 QCheckBox* bottlesCheck_;
213 QCheckBox* heroicEpicCheck_;
214 QCheckBox* heroicGOGCheck_;
215 QCheckBox* legendaryCheck_;
216 QCheckBox* nativeCheck_;
217 QCheckBox* winePrefixCheck_;
218
219 // Source stats labels
220 QLabel* steamStats_;
221 QLabel* lutrisStats_;
222 QLabel* bottlesStats_;
223 QLabel* heroicEpicStats_;
224 QLabel* heroicGOGStats_;
225 QLabel* legendaryStats_;
226 QLabel* nativeStats_;
227 QLabel* winePrefixStats_;
228
229 // UI Components - Progress
230 QProgressBar* progressBar_;
231 QLabel* statusLabel_;
232
233 // UI Components - Results
234 QTreeWidget* gameTree_;
235 QCheckBox* hideImportedCheck_;
236 QCheckBox* showInstalledOnlyCheck_;
237 QLabel* statsLabel_;
238
239 // UI Components - Actions
240 QPushButton* scanBtn_;
241 QPushButton* selectAllBtn_;
242 QPushButton* selectNoneBtn_;
243 QPushButton* selectInstalledBtn_;
244 QPushButton* importBtn_;
245 QPushButton* closeBtn_;
246
247 // State
248 core::GameLibraryController* libraryController_;
249 QThread* workerThread_ = nullptr;
250 GameImportWorker* worker_ = nullptr;
251 std::vector<ImportableGame> importableGames_;
252 ImportSourceConfig sourceConfig_;
253 std::map<ImportableGame::SourceType, ImportSourceStats> sourceStats_;
254 bool scanning_ = false;
255
256 ThemeManager* themeManager_;
257};
GameImportDialog(core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
Background worker for scanning all sources.
void sourceComplete(const QString &source, int gamesFound)
void scanComplete(const std::vector< ImportableGame > &games)
void progressUpdate(const QString &source, const QString &operation, int percent)
void scanError(const QString &error)
void setSourceConfig(const ImportSourceConfig &config)
GameImportWorker(QObject *parent=nullptr)
Complete representation of a game in the library.
Definition game.h:767
Configuration for which sources to scan.
Statistics for a single import source.
Unified structure for all importable games.
QString getUniqueId() const
Game toGame() const
std::shared_ptr< SteamGame > steamGame
std::shared_ptr< ScannedGame > scannedGame
SourceType sourceType