game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
library_export_dialog.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/library_export_dialog.cpp
4// ==============================================================================
5// Implementation of library export/import/backup dialog
6// ==============================================================================
7
9#include "theme_manager.h"
10
12#include "models/game.h"
13
14#include <QApplication>
15#include <QDateTime>
16#include <QDir>
17#include <QFile>
18#include <QFileDialog>
19#include <QFileInfo>
20#include <QGridLayout>
21#include <QHBoxLayout>
22#include <QJsonArray>
23#include <QJsonDocument>
24#include <QJsonObject>
25#include <QMessageBox>
26#include <QScrollArea>
27#include <QStandardPaths>
28#include <QTextStream>
29#include <QVBoxLayout>
30
31// ==============================================================================
32// LibraryExportWorker Implementation
33// ==============================================================================
34
35LibraryExportWorker::LibraryExportWorker(QObject* parent) : QObject(parent) {}
36
38{
39 operation_ = op;
40}
41
42void LibraryExportWorker::setFilePath(const QString& path)
43{
44 filePath_ = path;
45}
46
48{
49 controller_ = controller;
50}
51
52void LibraryExportWorker::setSelectedGames(const std::vector<std::string>& gameIds)
53{
54 selectedGameIds_ = gameIds;
55}
56
58{
59 overwriteExisting_ = overwrite;
60}
61
63{
64 cancelled_ = true;
65}
66
68{
69 cancelled_ = false;
70
71 switch (operation_)
72 {
74 exportJson();
75 break;
77 exportCsv();
78 break;
80 importJson();
81 break;
83 backupDatabase();
84 break;
86 restoreDatabase();
87 break;
88 }
89}
90
91void LibraryExportWorker::exportJson()
92{
93 if (!controller_)
94 {
95 emit error("No library controller available");
96 return;
97 }
98
99 emit progress(0, 100, "Gathering games...");
100
101 auto allGames = controller_->getAllGames();
102
103 // Filter to selected games if specified
104 std::vector<Game*> gamesToExport;
105 if (selectedGameIds_.empty())
106 {
107 gamesToExport = allGames;
108 }
109 else
110 {
111 for (auto* game : allGames)
112 {
113 for (const auto& id : selectedGameIds_)
114 {
115 if (game->id == id)
116 {
117 gamesToExport.push_back(game);
118 break;
119 }
120 }
121 }
122 }
123
124 if (gamesToExport.empty())
125 {
126 emit error("No games to export");
127 return;
128 }
129
130 emit progress(10, 100, QString("Exporting %1 games...").arg(gamesToExport.size()));
131
132 QJsonArray gamesArray;
133 int processed = 0;
134
135 for (auto* game : gamesToExport)
136 {
137 if (cancelled_)
138 {
139 emit error("Export cancelled");
140 return;
141 }
142
143 QJsonObject gameObj;
144
145 // Core properties
146 gameObj["id"] = QString::fromStdString(game->id);
147 gameObj["name"] = QString::fromStdString(game->name);
148 gameObj["source"] = static_cast<int>(game->source);
149 gameObj["runner"] = static_cast<int>(game->runner);
150 gameObj["status"] = static_cast<int>(game->status);
151 gameObj["isFavorite"] = game->isFavorite;
152 gameObj["installPath"] = QString::fromStdString(game->installPath);
153 gameObj["installSizeBytes"] = static_cast<qint64>(game->installSizeBytes);
154 gameObj["completionStatus"] = static_cast<int>(game->completionStatus);
155 gameObj["userNotes"] = QString::fromStdString(game->userNotes);
156
157 // Runner configuration
158 QJsonObject runnerConfig;
159 runnerConfig["runnerType"] = QString::fromStdString(game->runnerConfig.runnerType);
160 runnerConfig["runnerVersion"] = QString::fromStdString(game->runnerConfig.runnerVersion);
161 runnerConfig["executablePath"] = QString::fromStdString(game->runnerConfig.executablePath);
162 runnerConfig["workingDirectory"] =
163 QString::fromStdString(game->runnerConfig.workingDirectory);
164 runnerConfig["arguments"] = QString::fromStdString(game->runnerConfig.arguments);
165 runnerConfig["winePrefix"] = QString::fromStdString(game->runnerConfig.winePrefix);
166 runnerConfig["winePath"] = QString::fromStdString(game->runnerConfig.winePath);
167 runnerConfig["wineDLL"] = QString::fromStdString(game->runnerConfig.wineDLL);
168 runnerConfig["protonVersion"] = QString::fromStdString(game->runnerConfig.protonVersion);
169 runnerConfig["useVirtualDesktop"] = game->runnerConfig.useVirtualDesktop;
170 runnerConfig["virtualDesktopWidth"] = game->runnerConfig.virtualDesktopWidth;
171 runnerConfig["virtualDesktopHeight"] = game->runnerConfig.virtualDesktopHeight;
172 runnerConfig["enableMangoHud"] = game->runnerConfig.enableMangoHud;
173 runnerConfig["enableGameMode"] = game->runnerConfig.enableGameMode;
174 runnerConfig["enableGamePerformance"] = game->runnerConfig.enableGamePerformance;
175 runnerConfig["enableVkBasalt"] = game->runnerConfig.enableVkBasalt;
176 runnerConfig["enableGamescope"] = game->runnerConfig.enableGamescope;
177 runnerConfig["gamescopeWidth"] = game->runnerConfig.gamescopeWidth;
178 runnerConfig["gamescopeHeight"] = game->runnerConfig.gamescopeHeight;
179 runnerConfig["gamescopeRefreshRate"] = game->runnerConfig.gamescopeRefreshRate;
180 runnerConfig["gamescopeFullscreen"] = game->runnerConfig.gamescopeFullscreen;
181 runnerConfig["gamescopeBorderless"] = game->runnerConfig.gamescopeBorderless;
182 runnerConfig["gamescopeEnableFSR"] = game->runnerConfig.gamescopeEnableFSR;
183 runnerConfig["gamescopeFSRSharpness"] = game->runnerConfig.gamescopeFSRSharpness;
184 runnerConfig["enableFsync"] = game->runnerConfig.enableFsync;
185 runnerConfig["autoDetectSync"] = game->runnerConfig.autoDetectSync;
186 runnerConfig["enableDetailedLogging"] = game->runnerConfig.enableDetailedLogging;
187 runnerConfig["useSteamDefaults"] = game->runnerConfig.useSteamDefaults;
188
189 // Environment variables
190 QJsonObject envVars;
191 for (const auto& [key, value] : game->runnerConfig.environmentVariables)
192 {
193 envVars[QString::fromStdString(key)] = QString::fromStdString(value);
194 }
195 runnerConfig["environmentVariables"] = envVars;
196
197 // Exclude processes
198 QJsonArray excludeProcs;
199 for (const auto& proc : game->runnerConfig.excludeProcesses)
200 {
201 excludeProcs.append(QString::fromStdString(proc));
202 }
203 runnerConfig["excludeProcesses"] = excludeProcs;
204
205 gameObj["runnerConfig"] = runnerConfig;
206
207 // Metadata
208 QJsonObject metadata;
209 metadata["coverArtPath"] = QString::fromStdString(game->metadata.coverArtPath);
210 metadata["bannerPath"] = QString::fromStdString(game->metadata.bannerPath);
211 metadata["description"] = QString::fromStdString(game->metadata.description);
212 metadata["developer"] = QString::fromStdString(game->metadata.developer);
213 metadata["publisher"] = QString::fromStdString(game->metadata.publisher);
214 metadata["releaseYear"] = game->metadata.releaseYear;
215 metadata["userRating"] = static_cast<double>(game->metadata.userRating);
216 metadata["isSteamGame"] = game->metadata.isSteamGame;
217 metadata["steamAppId"] = game->metadata.steamAppId;
218 metadata["steamLaunchOptions"] = QString::fromStdString(game->metadata.steamLaunchOptions);
219
220 // Image paths
221 QJsonObject imagePaths;
222 imagePaths["verticalCover"] =
223 QString::fromStdString(game->metadata.imagePaths.verticalCover);
224 imagePaths["heroImage"] = QString::fromStdString(game->metadata.imagePaths.heroImage);
225 imagePaths["logo"] = QString::fromStdString(game->metadata.imagePaths.logo);
226 imagePaths["header"] = QString::fromStdString(game->metadata.imagePaths.header);
227 imagePaths["icon"] = QString::fromStdString(game->metadata.imagePaths.icon);
228 metadata["imagePaths"] = imagePaths;
229
230 // Genres and tags
231 QJsonArray genres;
232 for (const auto& genre : game->metadata.genres)
233 {
234 genres.append(QString::fromStdString(genre));
235 }
236 metadata["genres"] = genres;
237
238 QJsonArray tags;
239 for (const auto& tag : game->metadata.tags)
240 {
241 tags.append(QString::fromStdString(tag));
242 }
243 metadata["tags"] = tags;
244
245 gameObj["metadata"] = metadata;
246
247 // Statistics
248 QJsonObject statistics;
249 statistics["timesLaunched"] = game->statistics.timesLaunched;
250 statistics["totalPlayTimeSeconds"] = game->statistics.totalPlayTimeSeconds;
251 statistics["lastPlayed"] = static_cast<qint64>(game->statistics.lastPlayed);
252 statistics["dateAdded"] = static_cast<qint64>(game->statistics.dateAdded);
253 statistics["dateInstalled"] = static_cast<qint64>(game->statistics.dateInstalled);
254 statistics["crashCount"] = game->statistics.crashCount;
255 gameObj["statistics"] = statistics;
256
257 // Collections
258 QJsonArray collections;
259 for (const auto& coll : game->collections)
260 {
261 collections.append(QString::fromStdString(coll));
262 }
263 gameObj["collections"] = collections;
264
265 gamesArray.append(gameObj);
266
267 processed++;
268 int progressPercent = 10 + (processed * 80 / static_cast<int>(gamesToExport.size()));
269 emit progress(
270 progressPercent, 100,
271 QString("Exported %1 of %2 games...").arg(processed).arg(gamesToExport.size()));
272 }
273
274 emit progress(90, 100, "Writing file...");
275
276 // Create export document
277 QJsonObject root;
278 root["version"] = 1;
279 root["exportDate"] = QDateTime::currentDateTime().toString(Qt::ISODate);
280 root["gameCount"] = static_cast<int>(gamesToExport.size());
281 root["games"] = gamesArray;
282
283 // Also export collections
284 QJsonArray collectionsArray;
285 for (const auto& coll : controller_->getCollections())
286 {
287 collectionsArray.append(QString::fromStdString(coll));
288 }
289 root["collections"] = collectionsArray;
290
291 QJsonDocument doc(root);
292
293 QFile file(filePath_);
294 if (!file.open(QIODevice::WriteOnly))
295 {
296 emit error(QString("Failed to open file for writing: %1").arg(file.errorString()));
297 return;
298 }
299
300 file.write(doc.toJson(QJsonDocument::Indented));
301 file.close();
302
303 emit progress(100, 100, "Export complete!");
304 emit finished(
305 true,
306 QString("Successfully exported %1 games to:\n%2").arg(gamesToExport.size()).arg(filePath_));
307}
308
309void LibraryExportWorker::exportCsv()
310{
311 if (!controller_)
312 {
313 emit error("No library controller available");
314 return;
315 }
316
317 emit progress(0, 100, "Gathering games...");
318
319 auto allGames = controller_->getAllGames();
320
321 // Filter to selected games if specified
322 std::vector<Game*> gamesToExport;
323 if (selectedGameIds_.empty())
324 {
325 gamesToExport = allGames;
326 }
327 else
328 {
329 for (auto* game : allGames)
330 {
331 for (const auto& id : selectedGameIds_)
332 {
333 if (game->id == id)
334 {
335 gamesToExport.push_back(game);
336 break;
337 }
338 }
339 }
340 }
341
342 if (gamesToExport.empty())
343 {
344 emit error("No games to export");
345 return;
346 }
347
348 emit progress(10, 100, QString("Exporting %1 games to CSV...").arg(gamesToExport.size()));
349
350 QFile file(filePath_);
351 if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
352 {
353 emit error(QString("Failed to open file for writing: %1").arg(file.errorString()));
354 return;
355 }
356
357 QTextStream stream(&file);
358
359 // CSV Header
360 stream << "ID,Name,Source,Runner,Status,Favorite,Install Path,Playtime (hours),"
361 << "Times Launched,Last Played,Date Added,Developer,Publisher,Release Year,"
362 << "Steam App ID,Genres,Collections,Completion Status,User Rating\n";
363
364 auto escapeCSV = [](const QString& str) -> QString
365 {
366 QString escaped = str;
367 if (escaped.contains(',') || escaped.contains('"') || escaped.contains('\n'))
368 {
369 escaped.replace("\"", "\"\"");
370 return "\"" + escaped + "\"";
371 }
372 return escaped;
373 };
374
375 auto sourceToString = [](GameSource source) -> QString
376 {
377 switch (source)
378 {
380 return "Local";
382 return "Steam";
383 case GameSource::GOG:
384 return "GOG";
385 case GameSource::Epic:
386 return "Epic";
387 case GameSource::Itch:
388 return "Itch";
390 return "Lutris";
392 return "Flatpak";
393 default:
394 return "Unknown";
395 }
396 };
397
398 auto runnerToString = [](GameRunner runner) -> QString
399 {
400 switch (runner)
401 {
403 return "Native";
404 case GameRunner::Wine:
405 return "Wine";
407 return "Proton";
409 return "DOSBox";
411 return "ScummVM";
412 default:
413 return "Unknown";
414 }
415 };
416
417 auto completionToString = [](CompletionStatus status) -> QString
418 {
419 switch (status)
420 {
422 return "Not Played";
424 return "Playing";
426 return "Beaten";
428 return "Completed";
430 return "On Hold";
432 return "Abandoned";
434 return "Played";
435 default:
436 return "Unknown";
437 }
438 };
439
440 int processed = 0;
441 for (auto* game : gamesToExport)
442 {
443 if (cancelled_)
444 {
445 file.close();
446 emit error("Export cancelled");
447 return;
448 }
449
450 // Join genres with semicolons
451 QString genres;
452 for (size_t i = 0; i < game->metadata.genres.size(); ++i)
453 {
454 if (i > 0)
455 genres += ";";
456 genres += QString::fromStdString(game->metadata.genres[i]);
457 }
458
459 // Join collections with semicolons
460 QString collections;
461 for (size_t i = 0; i < game->collections.size(); ++i)
462 {
463 if (i > 0)
464 collections += ";";
465 collections += QString::fromStdString(game->collections[i]);
466 }
467
468 double playtimeHours = game->statistics.totalPlayTimeSeconds / 3600.0;
469
470 QString lastPlayedStr =
471 game->statistics.lastPlayed > 0
472 ? QDateTime::fromSecsSinceEpoch(game->statistics.lastPlayed).toString("yyyy-MM-dd")
473 : "";
474 QString dateAddedStr =
475 game->statistics.dateAdded > 0
476 ? QDateTime::fromSecsSinceEpoch(game->statistics.dateAdded).toString("yyyy-MM-dd")
477 : "";
478
479 stream << escapeCSV(QString::fromStdString(game->id)) << ","
480 << escapeCSV(QString::fromStdString(game->name)) << ","
481 << sourceToString(game->source) << "," << runnerToString(game->runner) << ","
482 << static_cast<int>(game->status) << "," << (game->isFavorite ? "Yes" : "No") << ","
483 << escapeCSV(QString::fromStdString(game->installPath)) << ","
484 << QString::number(playtimeHours, 'f', 1) << "," << game->statistics.timesLaunched
485 << "," << lastPlayedStr << "," << dateAddedStr << ","
486 << escapeCSV(QString::fromStdString(game->metadata.developer)) << ","
487 << escapeCSV(QString::fromStdString(game->metadata.publisher)) << ","
488 << game->metadata.releaseYear << "," << game->metadata.steamAppId << ","
489 << escapeCSV(genres) << "," << escapeCSV(collections) << ","
490 << completionToString(game->completionStatus) << ","
491 << QString::number(static_cast<double>(game->metadata.userRating), 'f', 1) << "\n";
492
493 processed++;
494 int progressPercent = 10 + (processed * 85 / static_cast<int>(gamesToExport.size()));
495 emit progress(
496 progressPercent, 100,
497 QString("Exported %1 of %2 games...").arg(processed).arg(gamesToExport.size()));
498 }
499
500 file.close();
501
502 emit progress(100, 100, "Export complete!");
503 emit finished(true, QString("Successfully exported %1 games to CSV:\n%2")
504 .arg(gamesToExport.size())
505 .arg(filePath_));
506}
507
508void LibraryExportWorker::importJson()
509{
510 if (!controller_)
511 {
512 emit error("No library controller available");
513 return;
514 }
515
516 emit progress(0, 100, "Reading file...");
517
518 QFile file(filePath_);
519 if (!file.open(QIODevice::ReadOnly))
520 {
521 emit error(QString("Failed to open file: %1").arg(file.errorString()));
522 return;
523 }
524
525 QByteArray data = file.readAll();
526 file.close();
527
528 emit progress(10, 100, "Parsing JSON...");
529
530 QJsonParseError parseError;
531 QJsonDocument doc = QJsonDocument::fromJson(data, &parseError);
532 if (parseError.error != QJsonParseError::NoError)
533 {
534 emit error(QString("JSON parse error: %1").arg(parseError.errorString()));
535 return;
536 }
537
538 QJsonObject root = doc.object();
539 int version = root["version"].toInt(1);
540
541 if (version > 1)
542 {
543 emit error(QString("Unsupported export format version: %1").arg(version));
544 return;
545 }
546
547 QJsonArray gamesArray = root["games"].toArray();
548 if (gamesArray.isEmpty())
549 {
550 emit error("No games found in import file");
551 return;
552 }
553
554 emit progress(20, 100, QString("Importing %1 games...").arg(gamesArray.size()));
555
556 int imported = 0;
557 int skipped = 0;
558 int updated = 0;
559
560 for (int i = 0; i < gamesArray.size(); ++i)
561 {
562 if (cancelled_)
563 {
564 emit error("Import cancelled");
565 return;
566 }
567
568 QJsonObject gameObj = gamesArray[i].toObject();
569
570 Game game;
571
572 // Core properties
573 game.id = gameObj["id"].toString().toStdString();
574 game.name = gameObj["name"].toString().toStdString();
575 game.source = static_cast<GameSource>(gameObj["source"].toInt());
576 game.runner = static_cast<GameRunner>(gameObj["runner"].toInt());
577 game.status = static_cast<GameStatus>(gameObj["status"].toInt());
578 game.isFavorite = gameObj["isFavorite"].toBool();
579 game.installPath = gameObj["installPath"].toString().toStdString();
580 game.installSizeBytes =
581 static_cast<uint64_t>(gameObj["installSizeBytes"].toVariant().toLongLong());
582 game.completionStatus = static_cast<CompletionStatus>(gameObj["completionStatus"].toInt());
583 game.userNotes = gameObj["userNotes"].toString().toStdString();
584
585 // Runner config
586 QJsonObject runnerConfigObj = gameObj["runnerConfig"].toObject();
587 game.runnerConfig.runnerType = runnerConfigObj["runnerType"].toString().toStdString();
588 game.runnerConfig.runnerVersion = runnerConfigObj["runnerVersion"].toString().toStdString();
590 runnerConfigObj["executablePath"].toString().toStdString();
592 runnerConfigObj["workingDirectory"].toString().toStdString();
593 game.runnerConfig.arguments = runnerConfigObj["arguments"].toString().toStdString();
594 game.runnerConfig.winePrefix = runnerConfigObj["winePrefix"].toString().toStdString();
595 game.runnerConfig.winePath = runnerConfigObj["winePath"].toString().toStdString();
596 game.runnerConfig.wineDLL = runnerConfigObj["wineDLL"].toString().toStdString();
597 game.runnerConfig.protonVersion = runnerConfigObj["protonVersion"].toString().toStdString();
598 game.runnerConfig.useVirtualDesktop = runnerConfigObj["useVirtualDesktop"].toBool();
599 game.runnerConfig.virtualDesktopWidth = runnerConfigObj["virtualDesktopWidth"].toInt(1920);
601 runnerConfigObj["virtualDesktopHeight"].toInt(1080);
602 game.runnerConfig.enableMangoHud = runnerConfigObj["enableMangoHud"].toBool();
603 game.runnerConfig.enableGameMode = runnerConfigObj["enableGameMode"].toBool();
604 game.runnerConfig.enableGamePerformance = runnerConfigObj["enableGamePerformance"].toBool();
605 game.runnerConfig.enableVkBasalt = runnerConfigObj["enableVkBasalt"].toBool();
606 game.runnerConfig.enableGamescope = runnerConfigObj["enableGamescope"].toBool();
607 game.runnerConfig.gamescopeWidth = runnerConfigObj["gamescopeWidth"].toInt();
608 game.runnerConfig.gamescopeHeight = runnerConfigObj["gamescopeHeight"].toInt();
609 game.runnerConfig.gamescopeRefreshRate = runnerConfigObj["gamescopeRefreshRate"].toInt();
610 game.runnerConfig.gamescopeFullscreen = runnerConfigObj["gamescopeFullscreen"].toBool(true);
611 game.runnerConfig.gamescopeBorderless = runnerConfigObj["gamescopeBorderless"].toBool();
612 game.runnerConfig.gamescopeEnableFSR = runnerConfigObj["gamescopeEnableFSR"].toBool();
613 game.runnerConfig.gamescopeFSRSharpness = runnerConfigObj["gamescopeFSRSharpness"].toInt(5);
614 game.runnerConfig.enableFsync = runnerConfigObj["enableFsync"].toBool(true);
615 game.runnerConfig.autoDetectSync = runnerConfigObj["autoDetectSync"].toBool(true);
616 game.runnerConfig.enableDetailedLogging = runnerConfigObj["enableDetailedLogging"].toBool();
617 game.runnerConfig.useSteamDefaults = runnerConfigObj["useSteamDefaults"].toBool();
618
619 // Environment variables
620 QJsonObject envVarsObj = runnerConfigObj["environmentVariables"].toObject();
621 for (const QString& key : envVarsObj.keys())
622 {
623 game.runnerConfig.environmentVariables[key.toStdString()] =
624 envVarsObj[key].toString().toStdString();
625 }
626
627 // Exclude processes
628 QJsonArray excludeProcsArray = runnerConfigObj["excludeProcesses"].toArray();
629 for (const auto& proc : excludeProcsArray)
630 {
631 game.runnerConfig.excludeProcesses.push_back(proc.toString().toStdString());
632 }
633
634 // Metadata
635 QJsonObject metadataObj = gameObj["metadata"].toObject();
636 game.metadata.coverArtPath = metadataObj["coverArtPath"].toString().toStdString();
637 game.metadata.bannerPath = metadataObj["bannerPath"].toString().toStdString();
638 game.metadata.description = metadataObj["description"].toString().toStdString();
639 game.metadata.developer = metadataObj["developer"].toString().toStdString();
640 game.metadata.publisher = metadataObj["publisher"].toString().toStdString();
641 game.metadata.releaseYear = metadataObj["releaseYear"].toInt();
642 game.metadata.userRating = static_cast<float>(metadataObj["userRating"].toDouble());
643 game.metadata.isSteamGame = metadataObj["isSteamGame"].toBool();
644 game.metadata.steamAppId = metadataObj["steamAppId"].toInt();
646 metadataObj["steamLaunchOptions"].toString().toStdString();
647
648 // Image paths
649 QJsonObject imagePathsObj = metadataObj["imagePaths"].toObject();
651 imagePathsObj["verticalCover"].toString().toStdString();
652 game.metadata.imagePaths.heroImage = imagePathsObj["heroImage"].toString().toStdString();
653 game.metadata.imagePaths.logo = imagePathsObj["logo"].toString().toStdString();
654 game.metadata.imagePaths.header = imagePathsObj["header"].toString().toStdString();
655 game.metadata.imagePaths.icon = imagePathsObj["icon"].toString().toStdString();
656
657 // Genres
658 QJsonArray genresArray = metadataObj["genres"].toArray();
659 for (const auto& genre : genresArray)
660 {
661 game.metadata.genres.push_back(genre.toString().toStdString());
662 }
663
664 // Tags
665 QJsonArray tagsArray = metadataObj["tags"].toArray();
666 for (const auto& tag : tagsArray)
667 {
668 game.metadata.tags.push_back(tag.toString().toStdString());
669 }
670
671 // Statistics
672 QJsonObject statsObj = gameObj["statistics"].toObject();
673 game.statistics.timesLaunched = statsObj["timesLaunched"].toInt();
674 game.statistics.totalPlayTimeSeconds = statsObj["totalPlayTimeSeconds"].toDouble();
676 static_cast<time_t>(statsObj["lastPlayed"].toVariant().toLongLong());
677 game.statistics.dateAdded =
678 static_cast<time_t>(statsObj["dateAdded"].toVariant().toLongLong());
680 static_cast<time_t>(statsObj["dateInstalled"].toVariant().toLongLong());
681 game.statistics.crashCount = statsObj["crashCount"].toInt();
682
683 // Collections
684 QJsonArray collectionsArray = gameObj["collections"].toArray();
685 for (const auto& coll : collectionsArray)
686 {
687 game.collections.push_back(coll.toString().toStdString());
688 }
689
690 // Check if game already exists
691 const Game* existingGame = controller_->getGame(game.id);
692 if (existingGame)
693 {
694 if (overwriteExisting_)
695 {
696 controller_->updateGame(game.id, game);
697 updated++;
698 }
699 else
700 {
701 skipped++;
702 }
703 }
704 else
705 {
706 controller_->addGame(game);
707 imported++;
708 }
709
710 int progressPercent = 20 + static_cast<int>((i + 1) * 75 / gamesArray.size());
711 emit progress(progressPercent, 100,
712 QString("Processing game %1 of %2...").arg(i + 1).arg(gamesArray.size()));
713 }
714
715 // Import collections
716 QJsonArray collectionsArray = root["collections"].toArray();
717 for (const auto& coll : collectionsArray)
718 {
719 controller_->addCollection(coll.toString().toStdString());
720 }
721
722 emit progress(100, 100, "Import complete!");
723
724 QString message = QString("Import complete:\n- New games: %1\n- Updated: %2\n- Skipped: %3")
725 .arg(imported)
726 .arg(updated)
727 .arg(skipped);
728 emit finished(true, message);
729}
730
731void LibraryExportWorker::backupDatabase()
732{
733 emit progress(0, 100, "Creating backup...");
734
735 // Get the database path
736 QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
737 QString dbPath = dataDir + "/gamelauncher/games.db";
738
739 QFileInfo dbInfo(dbPath);
740 if (!dbInfo.exists())
741 {
742 emit error("Database file not found");
743 return;
744 }
745
746 emit progress(30, 100, "Copying database...");
747
748 // Copy the database file
749 if (QFile::exists(filePath_))
750 {
751 QFile::remove(filePath_);
752 }
753
754 if (!QFile::copy(dbPath, filePath_))
755 {
756 emit error("Failed to copy database file");
757 return;
758 }
759
760 emit progress(100, 100, "Backup complete!");
761 emit finished(true, QString("Database backup created:\n%1\n\nSize: %2")
762 .arg(filePath_)
763 .arg(QLocale().formattedDataSize(dbInfo.size())));
764}
765
766void LibraryExportWorker::restoreDatabase()
767{
768 emit progress(0, 100, "Verifying backup file...");
769
770 QFileInfo backupInfo(filePath_);
771 if (!backupInfo.exists())
772 {
773 emit error("Backup file not found");
774 return;
775 }
776
777 // Verify it's a SQLite database
778 QFile backupFile(filePath_);
779 if (!backupFile.open(QIODevice::ReadOnly))
780 {
781 emit error("Cannot read backup file");
782 return;
783 }
784
785 QByteArray header = backupFile.read(16);
786 backupFile.close();
787
788 if (!header.startsWith("SQLite format 3"))
789 {
790 emit error("Invalid backup file (not a SQLite database)");
791 return;
792 }
793
794 emit progress(30, 100, "Restoring database...");
795
796 // Get the database path
797 QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
798 QString dbPath = dataDir + "/gamelauncher/games.db";
799
800 // Create backup of current database
801 QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss");
802 QString currentBackup = dbPath + ".backup_" + timestamp;
803
804 if (QFile::exists(dbPath))
805 {
806 if (!QFile::rename(dbPath, currentBackup))
807 {
808 emit error("Failed to backup current database");
809 return;
810 }
811 }
812
813 emit progress(60, 100, "Copying backup...");
814
815 // Copy the backup file
816 if (!QFile::copy(filePath_, dbPath))
817 {
818 // Try to restore original
819 QFile::rename(currentBackup, dbPath);
820 emit error("Failed to restore from backup");
821 return;
822 }
823
824 emit progress(100, 100, "Restore complete!");
825 emit finished(true,
826 QString("Database restored from backup.\n\nPrevious database saved to:\n%1\n\n"
827 "Please restart the application for changes to take effect.")
828 .arg(currentBackup));
829}
830
831// ==============================================================================
832// ExportOptionsWidget Implementation
833// ==============================================================================
834
836 : QWidget(parent), themeManager_(themeManager ? themeManager : &ThemeManager::instance())
837{
838 setupUI();
839 applyTheme();
840
841 connect(themeManager_, &ThemeManager::themeChanged, this, &ExportOptionsWidget::applyTheme);
842}
843
844void ExportOptionsWidget::setupUI()
845{
846 auto* layout = new QVBoxLayout(this);
847 layout->setContentsMargins(0, 0, 0, 0);
848 layout->setSpacing(16);
849
850 // Format selection
851 auto* formatGroup = new QGroupBox("Export Format");
852 auto* formatLayout = new QVBoxLayout(formatGroup);
853
854 formatGroup_ = new QButtonGroup(this);
855 jsonRadio_ = new QRadioButton("JSON (Full backup - can be imported later)");
856 csvRadio_ = new QRadioButton("CSV (Spreadsheet - for viewing/analysis)");
857 jsonRadio_->setChecked(true);
858
859 formatGroup_->addButton(jsonRadio_);
860 formatGroup_->addButton(csvRadio_);
861
862 formatLayout->addWidget(jsonRadio_);
863 formatLayout->addWidget(csvRadio_);
864 layout->addWidget(formatGroup);
865
866 // Scope selection
867 auto* scopeGroup = new QGroupBox("Export Scope");
868 auto* scopeLayout = new QGridLayout(scopeGroup);
869
870 scopeGroup_ = new QButtonGroup(this);
871 allGamesRadio_ = new QRadioButton("All games in library");
872 selectedRadio_ = new QRadioButton("Currently selected games");
873 byCollectionRadio_ = new QRadioButton("Games in collection:");
874 bySourceRadio_ = new QRadioButton("Games from source:");
875 allGamesRadio_->setChecked(true);
876
877 scopeGroup_->addButton(allGamesRadio_);
878 scopeGroup_->addButton(selectedRadio_);
879 scopeGroup_->addButton(byCollectionRadio_);
880 scopeGroup_->addButton(bySourceRadio_);
881
882 collectionCombo_ = new QComboBox;
883 collectionCombo_->setEnabled(false);
884 collectionCombo_->setMinimumWidth(150);
885
886 sourceCombo_ = new QComboBox;
887 sourceCombo_->setEnabled(false);
888 sourceCombo_->setMinimumWidth(150);
889 sourceCombo_->addItems({"Steam", "GOG", "Epic", "Lutris", "Local", "Itch", "Flatpak"});
890
891 scopeLayout->addWidget(allGamesRadio_, 0, 0, 1, 2);
892 scopeLayout->addWidget(selectedRadio_, 1, 0, 1, 2);
893 scopeLayout->addWidget(byCollectionRadio_, 2, 0);
894 scopeLayout->addWidget(collectionCombo_, 2, 1);
895 scopeLayout->addWidget(bySourceRadio_, 3, 0);
896 scopeLayout->addWidget(sourceCombo_, 3, 1);
897
898 layout->addWidget(scopeGroup);
899
900 // Options
901 auto* optionsGroup = new QGroupBox("Include in Export");
902 auto* optionsLayout = new QVBoxLayout(optionsGroup);
903
904 includeStatsCheck_ = new QCheckBox("Include statistics (playtime, launch count, etc.)");
905 includeConfigsCheck_ = new QCheckBox("Include runner configurations");
906 includeStatsCheck_->setChecked(true);
907 includeConfigsCheck_->setChecked(true);
908
909 optionsLayout->addWidget(includeStatsCheck_);
910 optionsLayout->addWidget(includeConfigsCheck_);
911 layout->addWidget(optionsGroup);
912
913 layout->addStretch();
914
915 // Connections
916 connect(byCollectionRadio_, &QRadioButton::toggled, this, &ExportOptionsWidget::onScopeChanged);
917 connect(bySourceRadio_, &QRadioButton::toggled, this, &ExportOptionsWidget::onScopeChanged);
918}
919
920void ExportOptionsWidget::onScopeChanged()
921{
922 collectionCombo_->setEnabled(byCollectionRadio_->isChecked());
923 sourceCombo_->setEnabled(bySourceRadio_->isChecked());
924}
925
930
932{
933 if (selectedRadio_->isChecked())
935 if (byCollectionRadio_->isChecked())
937 if (bySourceRadio_->isChecked())
940}
941
943{
944 return collectionCombo_->currentText();
945}
946
948{
949 return sourceCombo_->currentText();
950}
951
953{
954 return includeStatsCheck_->isChecked();
955}
956
958{
959 return includeConfigsCheck_->isChecked();
960}
961
962void ExportOptionsWidget::setCollections(const QStringList& collections)
963{
964 collectionCombo_->clear();
965 collectionCombo_->addItems(collections);
966}
967
968void ExportOptionsWidget::setSources(const QStringList& sources)
969{
970 sourceCombo_->clear();
971 sourceCombo_->addItems(sources);
972}
973
975{
976 const auto& c = themeManager_->colors();
977
978 QString groupBoxStyle = QString("QGroupBox { "
979 " font-weight: bold; "
980 " border: 1px solid %1; "
981 " border-radius: 6px; "
982 " margin-top: 12px; "
983 " padding-top: 8px; "
984 "} "
985 "QGroupBox::title { "
986 " subcontrol-origin: margin; "
987 " left: 10px; "
988 " padding: 0 5px; "
989 " color: %2; "
990 "}")
991 .arg(c.border.name(), c.textPrimary.name());
992
993 for (auto* groupBox : findChildren<QGroupBox*>())
994 {
995 groupBox->setStyleSheet(groupBoxStyle);
996 }
997}
998
999// ==============================================================================
1000// ImportOptionsWidget Implementation
1001// ==============================================================================
1002
1004 : QWidget(parent), themeManager_(themeManager ? themeManager : &ThemeManager::instance())
1005{
1006 setupUI();
1007 applyTheme();
1008
1009 connect(themeManager_, &ThemeManager::themeChanged, this, &ImportOptionsWidget::applyTheme);
1010}
1011
1012void ImportOptionsWidget::setupUI()
1013{
1014 auto* layout = new QVBoxLayout(this);
1015 layout->setContentsMargins(0, 0, 0, 0);
1016 layout->setSpacing(16);
1017
1018 // Conflict handling
1019 auto* conflictGroup = new QGroupBox("Conflict Handling");
1020 auto* conflictLayout = new QVBoxLayout(conflictGroup);
1021
1022 overwriteCheck_ = new QCheckBox("Overwrite existing games with same ID");
1023 overwriteCheck_->setToolTip(
1024 "If a game with the same ID already exists, replace it with the imported version");
1025
1026 warningLabel_ = new QLabel("Warning: Overwriting will replace existing game configurations!");
1027 warningLabel_->setWordWrap(true);
1028 warningLabel_->setVisible(false);
1029
1030 conflictLayout->addWidget(overwriteCheck_);
1031 conflictLayout->addWidget(warningLabel_);
1032 layout->addWidget(conflictGroup);
1033
1034 // Import options
1035 auto* optionsGroup = new QGroupBox("Import Options");
1036 auto* optionsLayout = new QVBoxLayout(optionsGroup);
1037
1038 importStatsCheck_ = new QCheckBox("Import statistics (playtime, launch count, etc.)");
1039 importConfigsCheck_ = new QCheckBox("Import runner configurations");
1040 importStatsCheck_->setChecked(true);
1041 importConfigsCheck_->setChecked(true);
1042
1043 optionsLayout->addWidget(importStatsCheck_);
1044 optionsLayout->addWidget(importConfigsCheck_);
1045 layout->addWidget(optionsGroup);
1046
1047 layout->addStretch();
1048
1049 // Connections
1050 connect(overwriteCheck_, &QCheckBox::toggled, warningLabel_, &QLabel::setVisible);
1051}
1052
1054{
1055 return overwriteCheck_->isChecked();
1056}
1057
1059{
1060 return importStatsCheck_->isChecked();
1061}
1062
1064{
1065 return importConfigsCheck_->isChecked();
1066}
1067
1069{
1070 const auto& c = themeManager_->colors();
1071
1072 QString groupBoxStyle = QString("QGroupBox { "
1073 " font-weight: bold; "
1074 " border: 1px solid %1; "
1075 " border-radius: 6px; "
1076 " margin-top: 12px; "
1077 " padding-top: 8px; "
1078 "} "
1079 "QGroupBox::title { "
1080 " subcontrol-origin: margin; "
1081 " left: 10px; "
1082 " padding: 0 5px; "
1083 " color: %2; "
1084 "}")
1085 .arg(c.border.name(), c.textPrimary.name());
1086
1087 for (auto* groupBox : findChildren<QGroupBox*>())
1088 {
1089 groupBox->setStyleSheet(groupBoxStyle);
1090 }
1091
1092 warningLabel_->setStyleSheet(QString("color: %1; font-style: italic;").arg(c.warning.name()));
1093}
1094
1095// ==============================================================================
1096// BackupOptionsWidget Implementation
1097// ==============================================================================
1098
1100 : QWidget(parent), themeManager_(themeManager ? themeManager : &ThemeManager::instance())
1101{
1102 setupUI();
1103 applyTheme();
1104
1105 connect(themeManager_, &ThemeManager::themeChanged, this, &BackupOptionsWidget::applyTheme);
1106}
1107
1108void BackupOptionsWidget::setupUI()
1109{
1110 auto* layout = new QVBoxLayout(this);
1111 layout->setContentsMargins(0, 0, 0, 0);
1112 layout->setSpacing(16);
1113
1114 // Info label
1115 auto* infoLabel =
1116 new QLabel("Database backup creates a complete copy of your game library database.\n"
1117 "This includes all games, configurations, statistics, and collections.");
1118 infoLabel->setWordWrap(true);
1119 layout->addWidget(infoLabel);
1120
1121 // Options (for future expansion)
1122 auto* optionsGroup = new QGroupBox("Backup Options");
1123 auto* optionsLayout = new QVBoxLayout(optionsGroup);
1124
1125 includeImagesCheck_ = new QCheckBox("Include cached images (larger backup)");
1126 includeImagesCheck_->setEnabled(false); // Not implemented yet
1127 includeImagesCheck_->setToolTip("Coming soon");
1128
1129 compressCheck_ = new QCheckBox("Compress backup (smaller file)");
1130 compressCheck_->setEnabled(false); // Not implemented yet
1131 compressCheck_->setToolTip("Coming soon");
1132
1133 sizeEstimateLabel_ = new QLabel("Estimated backup size: calculating...");
1134
1135 optionsLayout->addWidget(includeImagesCheck_);
1136 optionsLayout->addWidget(compressCheck_);
1137 optionsLayout->addWidget(sizeEstimateLabel_);
1138 layout->addWidget(optionsGroup);
1139
1140 layout->addStretch();
1141
1142 // Calculate estimated size
1143 QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
1144 QString dbPath = dataDir + "/gamelauncher/games.db";
1145 QFileInfo dbInfo(dbPath);
1146 if (dbInfo.exists())
1147 {
1148 sizeEstimateLabel_->setText(
1149 QString("Estimated backup size: %1").arg(QLocale().formattedDataSize(dbInfo.size())));
1150 }
1151 else
1152 {
1153 sizeEstimateLabel_->setText("Database not found");
1154 }
1155}
1156
1158{
1159 return includeImagesCheck_->isChecked();
1160}
1161
1163{
1164 return compressCheck_->isChecked();
1165}
1166
1168{
1169 const auto& c = themeManager_->colors();
1170
1171 QString groupBoxStyle = QString("QGroupBox { "
1172 " font-weight: bold; "
1173 " border: 1px solid %1; "
1174 " border-radius: 6px; "
1175 " margin-top: 12px; "
1176 " padding-top: 8px; "
1177 "} "
1178 "QGroupBox::title { "
1179 " subcontrol-origin: margin; "
1180 " left: 10px; "
1181 " padding: 0 5px; "
1182 " color: %2; "
1183 "}")
1184 .arg(c.border.name(), c.textPrimary.name());
1185
1186 for (auto* groupBox : findChildren<QGroupBox*>())
1187 {
1188 groupBox->setStyleSheet(groupBoxStyle);
1189 }
1190
1191 QPalette sizePal = sizeEstimateLabel_->palette();
1192 sizePal.setColor(QPalette::WindowText, c.textSecondary);
1193 sizeEstimateLabel_->setPalette(sizePal);
1194}
1195
1196// ==============================================================================
1197// LibraryExportDialog Implementation
1198// ==============================================================================
1199
1201 : QDialog(parent), themeManager_(themeManager ? themeManager : &ThemeManager::instance())
1202{
1203 setWindowTitle("Library Export / Backup");
1204 setMinimumSize(600, 500);
1205 resize(650, 550);
1206
1207 setupUI();
1208 applyTheme();
1209
1210 connect(themeManager_, &ThemeManager::themeChanged, this, &LibraryExportDialog::applyTheme);
1211}
1212
1214{
1215 if (workerThread_)
1216 {
1217 if (worker_)
1218 {
1219 worker_->cancel();
1220 }
1221 workerThread_->quit();
1222 workerThread_->wait(3000);
1223 // No manual delete — workerThread_ is parented to `this` (see the
1224 // `new QThread(this)` at the creation site) so Qt cleans it up with
1225 // the dialog. Manual delete here would double-free during destructor.
1226 }
1227}
1228
1230{
1231 controller_ = controller;
1232
1233 if (controller_ && exportOptions_)
1234 {
1235 // Populate collections
1236 QStringList collections;
1237 for (const auto& coll : controller_->getCollections())
1238 {
1239 collections << QString::fromStdString(coll);
1240 }
1241 exportOptions_->setCollections(collections);
1242 }
1243}
1244
1245void LibraryExportDialog::setSelectedGameIds(const std::vector<std::string>& ids)
1246{
1247 selectedGameIds_ = ids;
1248}
1249
1250void LibraryExportDialog::setupUI()
1251{
1252 auto* mainLayout = new QVBoxLayout(this);
1253 mainLayout->setSpacing(16);
1254 mainLayout->setContentsMargins(20, 20, 20, 20);
1255
1256 // Content stack (main content / progress / result)
1257 contentStack_ = new QStackedWidget;
1258
1259 // Main content widget
1260 auto* mainContent = new QWidget;
1261 auto* mainContentLayout = new QVBoxLayout(mainContent);
1262 mainContentLayout->setContentsMargins(0, 0, 0, 0);
1263
1264 // Tab widget
1265 tabWidget_ = new QTabWidget;
1266
1267 // Export tab
1268 auto* exportTab = new QWidget;
1269 setupExportTab(exportTab);
1270 tabWidget_->addTab(exportTab, "Export");
1271
1272 // Import tab
1273 auto* importTab = new QWidget;
1274 setupImportTab(importTab);
1275 tabWidget_->addTab(importTab, "Import");
1276
1277 // Backup tab
1278 auto* backupTab = new QWidget;
1279 setupBackupTab(backupTab);
1280 tabWidget_->addTab(backupTab, "Database Backup");
1281
1282 mainContentLayout->addWidget(tabWidget_);
1283
1284 // Close button
1285 auto* buttonLayout = new QHBoxLayout;
1286 buttonLayout->addStretch();
1287 closeBtn_ = new QPushButton("Close");
1288 closeBtn_->setMinimumWidth(100);
1289 connect(closeBtn_, &QPushButton::clicked, this, &QDialog::reject);
1290 buttonLayout->addWidget(closeBtn_);
1291 mainContentLayout->addLayout(buttonLayout);
1292
1293 contentStack_->addWidget(mainContent);
1294
1295 // Progress widget
1296 progressWidget_ = new QWidget;
1297 auto* progressLayout = new QVBoxLayout(progressWidget_);
1298 progressLayout->setAlignment(Qt::AlignCenter);
1299
1300 progressLabel_ = new QLabel("Processing...");
1301 progressLabel_->setAlignment(Qt::AlignCenter);
1302
1303 progressBar_ = new QProgressBar;
1304 progressBar_->setMinimum(0);
1305 progressBar_->setMaximum(100);
1306 progressBar_->setMinimumWidth(400);
1307
1308 cancelBtn_ = new QPushButton("Cancel");
1309 connect(cancelBtn_, &QPushButton::clicked, this,
1310 [this]()
1311 {
1312 if (worker_)
1313 {
1314 worker_->cancel();
1315 }
1316 });
1317
1318 progressLayout->addStretch();
1319 progressLayout->addWidget(progressLabel_);
1320 progressLayout->addWidget(progressBar_);
1321 progressLayout->addSpacing(20);
1322 progressLayout->addWidget(cancelBtn_, 0, Qt::AlignCenter);
1323 progressLayout->addStretch();
1324
1325 contentStack_->addWidget(progressWidget_);
1326
1327 // Result widget
1328 resultWidget_ = new QWidget;
1329 auto* resultLayout = new QVBoxLayout(resultWidget_);
1330 resultLayout->setAlignment(Qt::AlignCenter);
1331
1332 resultIcon_ = new QLabel;
1333 resultIcon_->setAlignment(Qt::AlignCenter);
1334
1335 resultLabel_ = new QLabel;
1336 resultLabel_->setAlignment(Qt::AlignCenter);
1337 resultLabel_->setWordWrap(true);
1338
1339 resultDetails_ = new QTextEdit;
1340 resultDetails_->setReadOnly(true);
1341 resultDetails_->setMaximumHeight(150);
1342 resultDetails_->setVisible(false);
1343
1344 doneBtn_ = new QPushButton("Done");
1345 doneBtn_->setMinimumWidth(100);
1346 connect(doneBtn_, &QPushButton::clicked, this,
1347 [this]()
1348 {
1349 contentStack_->setCurrentIndex(0);
1350 setOperationInProgress(false);
1351 });
1352
1353 resultLayout->addStretch();
1354 resultLayout->addWidget(resultIcon_);
1355 resultLayout->addWidget(resultLabel_);
1356 resultLayout->addWidget(resultDetails_);
1357 resultLayout->addSpacing(20);
1358 resultLayout->addWidget(doneBtn_, 0, Qt::AlignCenter);
1359 resultLayout->addStretch();
1360
1361 contentStack_->addWidget(resultWidget_);
1362
1363 mainLayout->addWidget(contentStack_);
1364}
1365
1366void LibraryExportDialog::setupExportTab(QWidget* tab)
1367{
1368 auto* layout = new QVBoxLayout(tab);
1369 layout->setSpacing(16);
1370
1371 exportOptions_ = new ExportOptionsWidget(this, themeManager_);
1372 layout->addWidget(exportOptions_);
1373
1374 // File path
1375 auto* pathLayout = new QHBoxLayout;
1376 auto* pathLabel = new QLabel("Export to:");
1377 exportPathEdit_ = new QLineEdit;
1378 exportPathEdit_->setPlaceholderText("Select output file...");
1379 exportBrowseBtn_ = new QPushButton("Browse...");
1380
1381 pathLayout->addWidget(pathLabel);
1382 pathLayout->addWidget(exportPathEdit_, 1);
1383 pathLayout->addWidget(exportBrowseBtn_);
1384 layout->addLayout(pathLayout);
1385
1386 // Export button
1387 auto* buttonLayout = new QHBoxLayout;
1388 buttonLayout->addStretch();
1389 exportBtn_ = new QPushButton("Export");
1390 exportBtn_->setMinimumWidth(120);
1391 buttonLayout->addWidget(exportBtn_);
1392 layout->addLayout(buttonLayout);
1393
1394 connect(exportBrowseBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onBrowseExport);
1395 connect(exportBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onExportClicked);
1396}
1397
1398void LibraryExportDialog::setupImportTab(QWidget* tab)
1399{
1400 auto* layout = new QVBoxLayout(tab);
1401 layout->setSpacing(16);
1402
1403 // File path
1404 auto* pathLayout = new QHBoxLayout;
1405 auto* pathLabel = new QLabel("Import from:");
1406 importPathEdit_ = new QLineEdit;
1407 importPathEdit_->setPlaceholderText("Select JSON file to import...");
1408 importBrowseBtn_ = new QPushButton("Browse...");
1409
1410 pathLayout->addWidget(pathLabel);
1411 pathLayout->addWidget(importPathEdit_, 1);
1412 pathLayout->addWidget(importBrowseBtn_);
1413 layout->addLayout(pathLayout);
1414
1415 // Preview
1416 auto* previewLabel = new QLabel("Preview:");
1417 importPreview_ = new QTextEdit;
1418 importPreview_->setReadOnly(true);
1419 importPreview_->setMaximumHeight(100);
1420 importPreview_->setPlaceholderText("Select a file to see preview...");
1421
1422 layout->addWidget(previewLabel);
1423 layout->addWidget(importPreview_);
1424
1425 importOptions_ = new ImportOptionsWidget(this, themeManager_);
1426 layout->addWidget(importOptions_);
1427
1428 // Import button
1429 auto* buttonLayout = new QHBoxLayout;
1430 buttonLayout->addStretch();
1431 importBtn_ = new QPushButton("Import");
1432 importBtn_->setMinimumWidth(120);
1433 buttonLayout->addWidget(importBtn_);
1434 layout->addLayout(buttonLayout);
1435
1436 connect(importBrowseBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onBrowseImport);
1437 connect(importBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onImportClicked);
1438}
1439
1440void LibraryExportDialog::setupBackupTab(QWidget* tab)
1441{
1442 auto* layout = new QVBoxLayout(tab);
1443 layout->setSpacing(16);
1444
1445 backupOptions_ = new BackupOptionsWidget(this, themeManager_);
1446 layout->addWidget(backupOptions_);
1447
1448 // Backup section
1449 auto* backupGroup = new QGroupBox("Create Backup");
1450 auto* backupLayout = new QVBoxLayout(backupGroup);
1451
1452 auto* backupPathLayout = new QHBoxLayout;
1453 auto* backupPathLabel = new QLabel("Save backup to:");
1454 backupPathEdit_ = new QLineEdit;
1455 backupPathEdit_->setPlaceholderText("Select backup location...");
1456 backupBrowseBtn_ = new QPushButton("Browse...");
1457
1458 backupPathLayout->addWidget(backupPathLabel);
1459 backupPathLayout->addWidget(backupPathEdit_, 1);
1460 backupPathLayout->addWidget(backupBrowseBtn_);
1461 backupLayout->addLayout(backupPathLayout);
1462
1463 auto* backupBtnLayout = new QHBoxLayout;
1464 backupBtnLayout->addStretch();
1465 backupBtn_ = new QPushButton("Create Backup");
1466 backupBtn_->setMinimumWidth(120);
1467 backupBtnLayout->addWidget(backupBtn_);
1468 backupLayout->addLayout(backupBtnLayout);
1469
1470 layout->addWidget(backupGroup);
1471
1472 // Restore section
1473 auto* restoreGroup = new QGroupBox("Restore from Backup");
1474 auto* restoreLayout = new QVBoxLayout(restoreGroup);
1475
1476 auto* restorePathLayout = new QHBoxLayout;
1477 auto* restorePathLabel = new QLabel("Restore from:");
1478 restorePathEdit_ = new QLineEdit;
1479 restorePathEdit_->setPlaceholderText("Select backup file...");
1480 restoreBrowseBtn_ = new QPushButton("Browse...");
1481
1482 restorePathLayout->addWidget(restorePathLabel);
1483 restorePathLayout->addWidget(restorePathEdit_, 1);
1484 restorePathLayout->addWidget(restoreBrowseBtn_);
1485 restoreLayout->addLayout(restorePathLayout);
1486
1487 auto* warningLabel =
1488 new QLabel("Warning: Restoring will replace your current database. A backup of the current "
1489 "database will be created automatically.");
1490 warningLabel->setWordWrap(true);
1491 restoreLayout->addWidget(warningLabel);
1492
1493 auto* restoreBtnLayout = new QHBoxLayout;
1494 restoreBtnLayout->addStretch();
1495 restoreBtn_ = new QPushButton("Restore Backup");
1496 restoreBtn_->setMinimumWidth(120);
1497 restoreBtnLayout->addWidget(restoreBtn_);
1498 restoreLayout->addLayout(restoreBtnLayout);
1499
1500 layout->addWidget(restoreGroup);
1501
1502 layout->addStretch();
1503
1504 connect(backupBrowseBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onBrowseBackup);
1505 connect(restoreBrowseBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onBrowseRestore);
1506 connect(backupBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onBackupClicked);
1507 connect(restoreBtn_, &QPushButton::clicked, this, &LibraryExportDialog::onRestoreClicked);
1508}
1509
1510void LibraryExportDialog::onBrowseExport()
1511{
1512 QString filter;
1513 QString defaultName;
1514 QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd");
1515
1516 if (exportOptions_->getFormat() == ExportOptionsWidget::ExportFormat::Json)
1517 {
1518 filter = "JSON Files (*.json);;All Files (*)";
1519 defaultName = QString("gamelauncher_export_%1.json").arg(timestamp);
1520 }
1521 else
1522 {
1523 filter = "CSV Files (*.csv);;All Files (*)";
1524 defaultName = QString("gamelauncher_export_%1.csv").arg(timestamp);
1525 }
1526
1527 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1528 QString path = QFileDialog::getSaveFileName(this, "Export Library",
1529 documentsPath + "/" + defaultName, filter);
1530
1531 if (!path.isEmpty())
1532 {
1533 exportPathEdit_->setText(path);
1534 }
1535}
1536
1537void LibraryExportDialog::onBrowseImport()
1538{
1539 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1540 QString path = QFileDialog::getOpenFileName(this, "Import Library", documentsPath,
1541 "JSON Files (*.json);;All Files (*)");
1542
1543 if (!path.isEmpty())
1544 {
1545 importPathEdit_->setText(path);
1546
1547 // Show preview
1548 QFile file(path);
1549 if (file.open(QIODevice::ReadOnly))
1550 {
1551 QByteArray fileData = file.read(2048);
1552 file.close();
1553
1554 QJsonParseError parseError;
1555 QJsonDocument doc = QJsonDocument::fromJson(fileData, &parseError);
1556
1557 if (parseError.error == QJsonParseError::NoError)
1558 {
1559 QJsonObject root = doc.object();
1560 int gameCount = root["gameCount"].toInt();
1561 QString exportDate = root["exportDate"].toString();
1562 int version = root["version"].toInt();
1563
1564 QString preview = QString("File version: %1\n"
1565 "Export date: %2\n"
1566 "Games in file: %3")
1567 .arg(version)
1568 .arg(exportDate)
1569 .arg(gameCount);
1570 importPreview_->setText(preview);
1571 }
1572 else
1573 {
1574 importPreview_->setText("Error parsing file: " + parseError.errorString());
1575 }
1576 }
1577 }
1578}
1579
1580void LibraryExportDialog::onBrowseBackup()
1581{
1582 QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss");
1583 QString defaultName = QString("gamelauncher_backup_%1.db").arg(timestamp);
1584 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1585
1586 QString path =
1587 QFileDialog::getSaveFileName(this, "Save Backup", documentsPath + "/" + defaultName,
1588 "Database Files (*.db);;All Files (*)");
1589
1590 if (!path.isEmpty())
1591 {
1592 backupPathEdit_->setText(path);
1593 }
1594}
1595
1596void LibraryExportDialog::onBrowseRestore()
1597{
1598 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1599 QString path = QFileDialog::getOpenFileName(this, "Select Backup", documentsPath,
1600 "Database Files (*.db);;All Files (*)");
1601
1602 if (!path.isEmpty())
1603 {
1604 restorePathEdit_->setText(path);
1605 }
1606}
1607
1608void LibraryExportDialog::onExportClicked()
1609{
1610 QString path = exportPathEdit_->text().trimmed();
1611 if (path.isEmpty())
1612 {
1613 QMessageBox::warning(this, "Export", "Please select an output file.");
1614 return;
1615 }
1616
1617 auto op = exportOptions_->getFormat() == ExportOptionsWidget::ExportFormat::Json
1620
1621 startOperation(op, path);
1622}
1623
1624void LibraryExportDialog::onImportClicked()
1625{
1626 QString path = importPathEdit_->text().trimmed();
1627 if (path.isEmpty())
1628 {
1629 QMessageBox::warning(this, "Import", "Please select a file to import.");
1630 return;
1631 }
1632
1633 if (!QFile::exists(path))
1634 {
1635 QMessageBox::warning(this, "Import", "Selected file does not exist.");
1636 return;
1637 }
1638
1639 startOperation(LibraryExportWorker::Operation::ImportJson, path);
1640}
1641
1642void LibraryExportDialog::onBackupClicked()
1643{
1644 QString path = backupPathEdit_->text().trimmed();
1645 if (path.isEmpty())
1646 {
1647 QMessageBox::warning(this, "Backup", "Please select a backup location.");
1648 return;
1649 }
1650
1652}
1653
1654void LibraryExportDialog::onRestoreClicked()
1655{
1656 QString path = restorePathEdit_->text().trimmed();
1657 if (path.isEmpty())
1658 {
1659 QMessageBox::warning(this, "Restore", "Please select a backup file.");
1660 return;
1661 }
1662
1663 if (!QFile::exists(path))
1664 {
1665 QMessageBox::warning(this, "Restore", "Selected backup file does not exist.");
1666 return;
1667 }
1668
1669 // Confirm restore
1670 auto result = QMessageBox::question(this, "Confirm Restore",
1671 "Are you sure you want to restore from this backup?\n\n"
1672 "This will replace your current database. A backup of the "
1673 "current database will be created automatically.\n\n"
1674 "You will need to restart the application after restore.",
1675 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
1676
1677 if (result == QMessageBox::Yes)
1678 {
1680 }
1681}
1682
1683void LibraryExportDialog::startOperation(LibraryExportWorker::Operation op, const QString& filePath)
1684{
1685 if (operationInProgress_)
1686 return;
1687
1688 setOperationInProgress(true);
1689
1690 // Setup worker thread
1691 workerThread_ = new QThread(this);
1692 worker_ = new LibraryExportWorker;
1693
1694 worker_->setOperation(op);
1695 worker_->setFilePath(filePath);
1696 worker_->setController(controller_);
1697
1698 // For import operations
1699 if (op == LibraryExportWorker::Operation::ImportJson && importOptions_)
1700 {
1701 worker_->setOverwriteExisting(importOptions_->overwriteExisting());
1702 }
1703
1704 // For export operations, handle scope selection
1707 {
1708 if (exportOptions_ &&
1709 exportOptions_->getScope() == ExportOptionsWidget::ExportScope::SelectedGames)
1710 {
1711 worker_->setSelectedGames(selectedGameIds_);
1712 }
1713 }
1714
1715 worker_->moveToThread(workerThread_);
1716
1717 connect(workerThread_, &QThread::started, worker_, &LibraryExportWorker::doWork);
1718 connect(worker_, &LibraryExportWorker::progress, this, &LibraryExportDialog::onProgress);
1719 connect(worker_, &LibraryExportWorker::finished, this,
1720 &LibraryExportDialog::onOperationFinished);
1721 connect(worker_, &LibraryExportWorker::error, this, &LibraryExportDialog::onError);
1722
1723 connect(worker_, &LibraryExportWorker::finished, workerThread_, &QThread::quit);
1724 connect(worker_, &LibraryExportWorker::error, workerThread_, &QThread::quit);
1725 connect(workerThread_, &QThread::finished, worker_, &QObject::deleteLater);
1726
1727 // Show progress
1728 contentStack_->setCurrentWidget(progressWidget_);
1729 progressBar_->setValue(0);
1730 progressLabel_->setText("Starting...");
1731
1732 workerThread_->start();
1733}
1734
1735void LibraryExportDialog::setOperationInProgress(bool inProgress)
1736{
1737 operationInProgress_ = inProgress;
1738 closeBtn_->setEnabled(!inProgress);
1739 exportBtn_->setEnabled(!inProgress);
1740 importBtn_->setEnabled(!inProgress);
1741 backupBtn_->setEnabled(!inProgress);
1742 restoreBtn_->setEnabled(!inProgress);
1743}
1744
1745void LibraryExportDialog::onProgress(int current, int total, const QString& status)
1746{
1747 progressBar_->setMaximum(total);
1748 progressBar_->setValue(current);
1749 progressLabel_->setText(status);
1750}
1751
1752void LibraryExportDialog::onOperationFinished(bool success, const QString& message)
1753{
1754 const auto& c = themeManager_->colors();
1755
1756 if (success)
1757 {
1758 resultIcon_->setText("\xE2\x9C\x93"); // Check mark
1759 resultIcon_->setStyleSheet(QString("font-size: 48px; color: %1;").arg(c.success.name()));
1760 }
1761 else
1762 {
1763 resultIcon_->setText("\xE2\x9C\x97"); // X mark
1764 resultIcon_->setStyleSheet(QString("font-size: 48px; color: %1;").arg(c.error.name()));
1765 }
1766
1767 resultLabel_->setText(message);
1768 resultDetails_->setVisible(false);
1769
1770 contentStack_->setCurrentWidget(resultWidget_);
1771}
1772
1773void LibraryExportDialog::onError(const QString& message)
1774{
1775 onOperationFinished(false, "Operation failed:\n" + message);
1776}
1777
1778void LibraryExportDialog::applyTheme()
1779{
1780 const auto& c = themeManager_->colors();
1781
1782 // Dialog background
1783 setStyleSheet(QString("QDialog { background-color: %1; }").arg(c.windowBackground.name()));
1784
1785 // Tab widget
1786 QString tabStyle =
1787 QString("QTabWidget::pane { "
1788 " border: 1px solid %1; "
1789 " border-radius: 6px; "
1790 " background: %2; "
1791 "} "
1792 "QTabBar::tab { "
1793 " padding: 8px 16px; "
1794 " background: %3; "
1795 " border: 1px solid %1; "
1796 " border-bottom: none; "
1797 " border-top-left-radius: 6px; "
1798 " border-top-right-radius: 6px; "
1799 " color: %4; "
1800 "} "
1801 "QTabBar::tab:selected { "
1802 " background: %2; "
1803 " color: %5; "
1804 "} "
1805 "QTabBar::tab:hover:!selected { "
1806 " background: %6; "
1807 "}")
1808 .arg(c.border.name(), c.cardBackground.name(), c.windowBackground.name(),
1809 c.textSecondary.name(), c.textPrimary.name(), c.hoverBackground.name());
1810
1811 tabWidget_->setStyleSheet(tabStyle);
1812
1813 // Line edits
1814 QString lineEditStyle =
1815 QString("QLineEdit { "
1816 " background-color: %1; "
1817 " border: 1px solid %2; "
1818 " border-radius: 4px; "
1819 " padding: 6px 10px; "
1820 " color: %3; "
1821 "} "
1822 "QLineEdit:focus { "
1823 " border-color: %4; "
1824 "}")
1825 .arg(c.inputBackground.name(), c.border.name(), c.textPrimary.name(), c.accent.name());
1826
1827 for (auto* lineEdit : findChildren<QLineEdit*>())
1828 {
1829 lineEdit->setStyleSheet(lineEditStyle);
1830 }
1831
1832 // Buttons
1833 QString buttonStyle = QString("QPushButton { "
1834 " background-color: %1; "
1835 " border: 1px solid %2; "
1836 " border-radius: 6px; "
1837 " padding: 8px 16px; "
1838 " color: %3; "
1839 " font-weight: 500; "
1840 "} "
1841 "QPushButton:hover { "
1842 " background-color: %4; "
1843 "} "
1844 "QPushButton:pressed { "
1845 " background-color: %5; "
1846 "} "
1847 "QPushButton:disabled { "
1848 " background-color: %6; "
1849 " color: %7; "
1850 "}")
1851 .arg(c.cardBackground.name(), c.border.name(), c.textPrimary.name(),
1852 c.hoverBackground.name(), c.panelBackground.name(),
1853 c.cardBackground.name(), c.textMuted.name());
1854
1855 QString primaryButtonStyle =
1856 QString("QPushButton { "
1857 " background-color: %1; "
1858 " border: none; "
1859 " border-radius: 6px; "
1860 " padding: 8px 16px; "
1861 " color: %6; "
1862 " font-weight: bold; "
1863 "} "
1864 "QPushButton:hover { "
1865 " background-color: %2; "
1866 "} "
1867 "QPushButton:pressed { "
1868 " background-color: %3; "
1869 "} "
1870 "QPushButton:disabled { "
1871 " background-color: %4; "
1872 " color: %5; "
1873 "}")
1874 .arg(c.accent.name(), c.accentHover.name(), c.accentPressed.name(),
1875 c.cardBackground.name(), c.textMuted.name(), c.textOnAccent.name());
1876
1877 for (auto* btn : findChildren<QPushButton*>())
1878 {
1879 btn->setStyleSheet(buttonStyle);
1880 }
1881
1882 // Primary buttons
1883 exportBtn_->setStyleSheet(primaryButtonStyle);
1884 importBtn_->setStyleSheet(primaryButtonStyle);
1885 backupBtn_->setStyleSheet(primaryButtonStyle);
1886 restoreBtn_->setStyleSheet(primaryButtonStyle);
1887 doneBtn_->setStyleSheet(primaryButtonStyle);
1888
1889 // Progress bar
1890 QString progressStyle = QString("QProgressBar { "
1891 " border: 1px solid %1; "
1892 " border-radius: 4px; "
1893 " background: %2; "
1894 " height: 20px; "
1895 " text-align: center; "
1896 "} "
1897 "QProgressBar::chunk { "
1898 " background: %3; "
1899 " border-radius: 3px; "
1900 "}")
1901 .arg(c.border.name(), c.inputBackground.name(), c.accent.name());
1902
1903 progressBar_->setStyleSheet(progressStyle);
1904
1905 // Text edit (preview/results)
1906 QString textEditStyle =
1907 QString("QTextEdit { "
1908 " background-color: %1; "
1909 " border: 1px solid %2; "
1910 " border-radius: 4px; "
1911 " padding: 8px; "
1912 " color: %3; "
1913 "}")
1914 .arg(c.inputBackground.name(), c.border.name(), c.textPrimary.name());
1915
1916 if (importPreview_)
1917 importPreview_->setStyleSheet(textEditStyle);
1918 if (resultDetails_)
1919 resultDetails_->setStyleSheet(textEditStyle);
1920
1921 // Labels
1922 for (auto* label : findChildren<QLabel*>())
1923 {
1924 if (label != resultIcon_ && label != resultLabel_)
1925 {
1926 label->setStyleSheet(QString("color: %1;").arg(c.textPrimary.name()));
1927 }
1928 }
1929
1930 progressLabel_->setStyleSheet(QString("color: %1; font-size: 14px;").arg(c.textPrimary.name()));
1931 resultLabel_->setStyleSheet(QString("color: %1; font-size: 14px;").arg(c.textPrimary.name()));
1932
1933 // Group boxes in backup tab
1934 QString groupBoxStyle = QString("QGroupBox { "
1935 " font-weight: bold; "
1936 " border: 1px solid %1; "
1937 " border-radius: 6px; "
1938 " margin-top: 12px; "
1939 " padding-top: 8px; "
1940 "} "
1941 "QGroupBox::title { "
1942 " subcontrol-origin: margin; "
1943 " left: 10px; "
1944 " padding: 0 5px; "
1945 " color: %2; "
1946 "}")
1947 .arg(c.border.name(), c.textPrimary.name());
1948
1949 for (auto* groupBox : findChildren<QGroupBox*>())
1950 {
1951 groupBox->setStyleSheet(groupBoxStyle);
1952 }
1953
1954 // Apply theme to sub-widgets
1955 if (exportOptions_)
1956 exportOptions_->applyTheme();
1957 if (importOptions_)
1958 importOptions_->applyTheme();
1959 if (backupOptions_)
1960 backupOptions_->applyTheme();
1961}
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
GameMetadata metadata
Descriptive information and media.
Definition game.h:785
std::string userNotes
User's personal notes about the game.
Definition game.h:813
std::vector< std::string > collections
Collections this game belongs to.
Definition game.h:804
std::string installPath
Installation directory path.
Definition game.h:819
CompletionStatus completionStatus
User's completion status.
Definition game.h:810
bool isFavorite
Is this marked as a favorite game?
Definition game.h:803
std::string name
Display name shown in UI.
Definition game.h:774
std::string id
Unique identifier (auto-generated or user-specified).
Definition game.h:773
GameStatistics statistics
Play statistics and usage tracking.
Definition game.h:786
GameRunner runner
Runner/compatibility layer to use (Native, Proton, Wine, etc.).
Definition game.h:777
GameRunnerConfig runnerConfig
How to launch and run the game.
Definition game.h:784
GameStatus status
Current installation and execution status.
Definition game.h:778
uint64_t installSizeBytes
Installation size in bytes.
Definition game.h:820
GameSource source
Where the game was acquired from (Steam, GOG, Local, etc.).
Definition game.h:775
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)
void themeChanged()
Emitted when theme or accent color changes.
GameSource
Where the game was acquired from (store/service/local).
Definition game.h:39
@ Steam
Steam store/platform.
Definition game.h:41
@ Local
Manually added game (not from a store).
Definition game.h:40
@ Itch
itch.io indie games
Definition game.h:44
@ Lutris
Lutris community scripts.
Definition game.h:45
@ GOG
GOG.com (DRM-free games).
Definition game.h:42
@ Flatpak
Flatpak package.
Definition game.h:46
@ Epic
Epic Games Store.
Definition game.h:43
GameStatus
Current installation and execution status of the game.
Definition game.h:97
GameRunner
Runner/compatibility layer for executing the game.
Definition game.h:81
@ ScummVM
ScummVM engine.
Definition game.h:86
@ Proton
Proton (Steam's Wine fork).
Definition game.h:84
@ Native
Native Linux executable (no compatibility layer).
Definition game.h:82
@ Wine
Wine compatibility layer.
Definition game.h:83
@ DOSBox
DOSBox emulator.
Definition game.h:85
CompletionStatus
User's completion/play status for tracking backlog.
Definition game.h:115
@ Played
Played but no clear completion criteria (e.g., multiplayer).
Definition game.h:122
@ Completed
100% completion (achievements, side content, etc.)
Definition game.h:119
@ Abandoned
Stopped playing, unlikely to return.
Definition game.h:121
@ Beaten
Main story/campaign completed.
Definition game.h:118
@ OnHold
Temporarily paused.
Definition game.h:120
@ Playing
Currently playing.
Definition game.h:117
@ NotPlayed
Never played (backlog).
Definition game.h:116
std::string header
Small header image (header.jpg, 460x215).
Definition game.h:500
std::string logo
Game logo with transparency (logo.png).
Definition game.h:499
std::string icon
Small square icon (icon.jpg).
Definition game.h:502
std::string verticalCover
Vertical cover art (library_600x900.jpg).
Definition game.h:497
std::string heroImage
Wide banner/hero image (library_hero.jpg).
Definition game.h:498
float userRating
User rating (0.0-5.0 scale).
Definition game.h:571
bool isSteamGame
True if imported from Steam.
Definition game.h:574
std::string coverArtPath
Path to cover art image file (DEPRECATED - use imagePaths.verticalCover).
Definition game.h:559
int steamAppId
Steam App ID (0 if not a Steam game).
Definition game.h:575
GameImagePaths imagePaths
Paths to all available image assets.
Definition game.h:562
std::string description
Game description text.
Definition game.h:565
std::string bannerPath
Path to banner/header image file (DEPRECATED - use imagePaths.heroImage).
Definition game.h:561
std::string developer
Developer/studio name.
Definition game.h:568
std::string steamLaunchOptions
Steam launch options from localconfig.vdf.
Definition game.h:577
std::vector< std::string > tags
User-defined tags for organization.
Definition game.h:567
int releaseYear
Year the game was released.
Definition game.h:570
std::string publisher
Publisher name.
Definition game.h:569
std::vector< std::string > genres
Game genres (RPG, FPS, Strategy, etc.).
Definition game.h:566
bool enableVkBasalt
Enable VkBasalt shader injection.
Definition game.h:188
std::string executablePath
Full path to game executable.
Definition game.h:141
bool useSteamDefaults
For Steam games: if true, don't sync custom env vars/wrappers to Steam's VDF files.
Definition game.h:155
int virtualDesktopWidth
Virtual desktop width in pixels.
Definition game.h:177
std::string wineDLL
DLL overrides (e.g., "d3d11=native,builtin").
Definition game.h:169
bool gamescopeFullscreen
Run in fullscreen mode.
Definition game.h:200
std::string workingDirectory
Working directory for game execution.
Definition game.h:142
bool useVirtualDesktop
Launch game in Wine virtual desktop.
Definition game.h:176
std::string arguments
Command line arguments to pass to game.
Definition game.h:143
std::vector< std::string > excludeProcesses
Processes to exclude when tracking launcher child processes These are helper processes that should no...
Definition game.h:175
int gamescopeHeight
Gamescope output height (0 = native).
Definition game.h:196
bool gamescopeEnableFSR
Enable AMD FSR upscaling.
Definition game.h:202
bool enableMangoHud
Enable MangoHud performance overlay.
Definition game.h:184
std::string winePath
Custom Wine binary path (e.g., from Lutris config).
Definition game.h:168
std::string winePrefix
WINEPREFIX path (Wine install location).
Definition game.h:167
int gamescopeFSRSharpness
FSR sharpness (0-20, 0 = max sharp).
Definition game.h:203
bool enableGamePerformance
Enable game-performance wrapper (CachyOS).
Definition game.h:187
bool enableFsync
Enable Fsync (kernel 5.16+, best performance).
Definition game.h:215
int gamescopeRefreshRate
Refresh rate limit (0 = no limit).
Definition game.h:199
bool autoDetectSync
Auto-detect best sync method (default: true).
Definition game.h:216
int gamescopeWidth
Gamescope output width (0 = native).
Definition game.h:195
bool enableDetailedLogging
Enable detailed Wine/Proton logging.
Definition game.h:222
std::string runnerVersion
Runner version: "wine-8.0", "proton-8.0-5", etc.
Definition game.h:140
std::string runnerType
Runner type: "wine", "proton", "native", etc.
Definition game.h:139
bool enableGameMode
Enable GameMode CPU governor optimization.
Definition game.h:186
int virtualDesktopHeight
Virtual desktop height in pixels.
Definition game.h:178
bool enableGamescope
Enable Gamescope compositor.
Definition game.h:194
std::string protonVersion
Proton version (e.g., "proton-cachyos-slr").
Definition game.h:170
std::map< std::string, std::string > environmentVariables
Environment variables to set before launching (KEY=VALUE pairs).
Definition game.h:146
bool gamescopeBorderless
Borderless window mode.
Definition game.h:201
time_t dateInstalled
Unix timestamp when installed.
Definition game.h:717
double totalPlayTimeSeconds
Total play time in seconds (for all sessions).
Definition game.h:714
time_t lastPlayed
Unix timestamp of last play session.
Definition game.h:715
int timesLaunched
Number of times game was launched.
Definition game.h:713
time_t dateAdded
Unix timestamp when added to library.
Definition game.h:716
int crashCount
Number of times game has crashed.
Definition game.h:728
@ Game
Game-specific fixes.