game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
library_export_dialog.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/library_export_dialog.h
4// ==============================================================================
5// Dialog for exporting and importing game library data
6// ==============================================================================
7
8#pragma once
9
10#include <QButtonGroup>
11#include <QCheckBox>
12#include <QComboBox>
13#include <QDialog>
14#include <QGroupBox>
15#include <QLabel>
16#include <QLineEdit>
17#include <QListWidget>
18#include <QProgressBar>
19#include <QPushButton>
20#include <QRadioButton>
21#include <QStackedWidget>
22#include <QTabWidget>
23#include <QTextEdit>
24#include <QThread>
25#include <atomic>
26#include <memory>
27
28// Forward declarations
29namespace core
30{
32}
33
34class ThemeManager;
35class Game;
36
37// ==============================================================================
38// Export Worker - Runs export/import operations in background
39// ==============================================================================
40
41class LibraryExportWorker : public QObject
42{
43 Q_OBJECT
44
45 public:
54
55 explicit LibraryExportWorker(QObject* parent = nullptr);
56
57 void setOperation(Operation op);
58 void setFilePath(const QString& path);
60 void setSelectedGames(const std::vector<std::string>& gameIds);
61 void setOverwriteExisting(bool overwrite);
62
63 signals:
64 void progress(int current, int total, const QString& status);
65 void finished(bool success, const QString& message);
66 void error(const QString& message);
67
68 public slots:
69 void doWork();
70 void cancel();
71
72 private:
73 void exportJson();
74 void exportCsv();
75 void importJson();
76 void backupDatabase();
77 void restoreDatabase();
78
80 QString filePath_;
81 core::GameLibraryController* controller_ = nullptr;
82 std::vector<std::string> selectedGameIds_;
83 bool overwriteExisting_ = false;
84 std::atomic<bool> cancelled_{false};
85};
86
87// ==============================================================================
88// Export Options Widget
89// ==============================================================================
90
91class ExportOptionsWidget : public QWidget
92{
93 Q_OBJECT
94
95 public:
96 explicit ExportOptionsWidget(QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
97
98 enum class ExportFormat
99 {
102 };
103
111
112 ExportFormat getFormat() const;
113 ExportScope getScope() const;
114 QString getSelectedCollection() const;
115 QString getSelectedSource() const;
116 bool includeStatistics() const;
117 bool includeConfigurations() const;
118
119 void setCollections(const QStringList& collections);
120 void setSources(const QStringList& sources);
121
122 public slots:
123 void applyTheme();
124
125 private slots:
126 void onScopeChanged();
127
128 private:
129 void setupUI();
130
131 QRadioButton* jsonRadio_ = nullptr;
132 QRadioButton* csvRadio_ = nullptr;
133 QButtonGroup* formatGroup_ = nullptr;
134
135 QRadioButton* allGamesRadio_ = nullptr;
136 QRadioButton* selectedRadio_ = nullptr;
137 QRadioButton* byCollectionRadio_ = nullptr;
138 QRadioButton* bySourceRadio_ = nullptr;
139 QButtonGroup* scopeGroup_ = nullptr;
140
141 QComboBox* collectionCombo_ = nullptr;
142 QComboBox* sourceCombo_ = nullptr;
143
144 QCheckBox* includeStatsCheck_ = nullptr;
145 QCheckBox* includeConfigsCheck_ = nullptr;
146 ThemeManager* themeManager_;
147};
148
149// ==============================================================================
150// Import Options Widget
151// ==============================================================================
152
153class ImportOptionsWidget : public QWidget
154{
155 Q_OBJECT
156
157 public:
158 explicit ImportOptionsWidget(QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
159
160 bool overwriteExisting() const;
161 bool importStatistics() const;
162 bool importConfigurations() const;
163
164 public slots:
165 void applyTheme();
166
167 private:
168 void setupUI();
169
170 QCheckBox* overwriteCheck_ = nullptr;
171 QCheckBox* importStatsCheck_ = nullptr;
172 QCheckBox* importConfigsCheck_ = nullptr;
173 QLabel* warningLabel_ = nullptr;
174 ThemeManager* themeManager_;
175};
176
177// ==============================================================================
178// Backup Options Widget
179// ==============================================================================
180
181class BackupOptionsWidget : public QWidget
182{
183 Q_OBJECT
184
185 public:
186 explicit BackupOptionsWidget(QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
187
188 bool includeImages() const;
189 bool compressBackup() const;
190
191 public slots:
192 void applyTheme();
193
194 private:
195 void setupUI();
196
197 QCheckBox* includeImagesCheck_ = nullptr;
198 QCheckBox* compressCheck_ = nullptr;
199 QLabel* sizeEstimateLabel_ = nullptr;
200 ThemeManager* themeManager_;
201};
202
203// ==============================================================================
204// Library Export Dialog
205// ==============================================================================
206
207class LibraryExportDialog : public QDialog
208{
209 Q_OBJECT
210
211 public:
212 explicit LibraryExportDialog(QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
213 ~LibraryExportDialog() override;
214
216 void setSelectedGameIds(const std::vector<std::string>& ids);
217
218 private slots:
219 void onExportClicked();
220 void onImportClicked();
221 void onBackupClicked();
222 void onRestoreClicked();
223 void onBrowseExport();
224 void onBrowseImport();
225 void onBrowseBackup();
226 void onBrowseRestore();
227 void onProgress(int current, int total, const QString& status);
228 void onOperationFinished(bool success, const QString& message);
229 void onError(const QString& message);
230 void applyTheme();
231
232 private:
233 void setupUI();
234 void setupExportTab(QWidget* tab);
235 void setupImportTab(QWidget* tab);
236 void setupBackupTab(QWidget* tab);
237 void startOperation(LibraryExportWorker::Operation op, const QString& filePath);
238 void setOperationInProgress(bool inProgress);
239
240 core::GameLibraryController* controller_ = nullptr;
241 std::vector<std::string> selectedGameIds_;
242
243 // UI Components
244 QTabWidget* tabWidget_ = nullptr;
245
246 // Export tab
247 ExportOptionsWidget* exportOptions_ = nullptr;
248 QLineEdit* exportPathEdit_ = nullptr;
249 QPushButton* exportBrowseBtn_ = nullptr;
250 QPushButton* exportBtn_ = nullptr;
251
252 // Import tab
253 ImportOptionsWidget* importOptions_ = nullptr;
254 QLineEdit* importPathEdit_ = nullptr;
255 QPushButton* importBrowseBtn_ = nullptr;
256 QPushButton* importBtn_ = nullptr;
257 QTextEdit* importPreview_ = nullptr;
258
259 // Backup tab
260 BackupOptionsWidget* backupOptions_ = nullptr;
261 QLineEdit* backupPathEdit_ = nullptr;
262 QPushButton* backupBrowseBtn_ = nullptr;
263 QPushButton* backupBtn_ = nullptr;
264 QLineEdit* restorePathEdit_ = nullptr;
265 QPushButton* restoreBrowseBtn_ = nullptr;
266 QPushButton* restoreBtn_ = nullptr;
267
268 // Progress
269 QStackedWidget* contentStack_ = nullptr;
270 QWidget* progressWidget_ = nullptr;
271 QLabel* progressLabel_ = nullptr;
272 QProgressBar* progressBar_ = nullptr;
273 QPushButton* cancelBtn_ = nullptr;
274
275 // Result
276 QWidget* resultWidget_ = nullptr;
277 QLabel* resultIcon_ = nullptr;
278 QLabel* resultLabel_ = nullptr;
279 QTextEdit* resultDetails_ = nullptr;
280 QPushButton* doneBtn_ = nullptr;
281
282 // Close button
283 QPushButton* closeBtn_ = nullptr;
284
285 // Threading
286 QThread* workerThread_ = nullptr;
287 LibraryExportWorker* worker_ = nullptr;
288 std::atomic<bool> operationInProgress_{false};
289
290 ThemeManager* themeManager_;
291};
BackupOptionsWidget(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
ExportScope getScope() const
void setSources(const QStringList &sources)
ExportOptionsWidget(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
ExportFormat getFormat() const
void setCollections(const QStringList &collections)
QString getSelectedCollection() const
Complete representation of a game in the library.
Definition game.h:767
ImportOptionsWidget(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void setController(core::GameLibraryController *controller)
void setSelectedGameIds(const std::vector< std::string > &ids)
LibraryExportDialog(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void progress(int current, int total, const QString &status)
void setSelectedGames(const std::vector< std::string > &gameIds)
void setController(core::GameLibraryController *controller)
void setOverwriteExisting(bool overwrite)
void setOperation(Operation op)
LibraryExportWorker(QObject *parent=nullptr)
void setFilePath(const QString &path)
void finished(bool success, const QString &message)
void error(const QString &message)