14#include <QApplication>
23#include <QJsonDocument>
27#include <QStandardPaths>
49 controller_ = controller;
54 selectedGameIds_ = gameIds;
59 overwriteExisting_ = overwrite;
91void LibraryExportWorker::exportJson()
95 emit
error(
"No library controller available");
99 emit
progress(0, 100,
"Gathering games...");
101 auto allGames = controller_->getAllGames();
104 std::vector<Game*> gamesToExport;
105 if (selectedGameIds_.empty())
107 gamesToExport = allGames;
111 for (
auto* game : allGames)
113 for (
const auto&
id : selectedGameIds_)
117 gamesToExport.push_back(game);
124 if (gamesToExport.empty())
126 emit
error(
"No games to export");
130 emit
progress(10, 100, QString(
"Exporting %1 games...").arg(gamesToExport.size()));
132 QJsonArray gamesArray;
135 for (
auto* game : gamesToExport)
139 emit
error(
"Export cancelled");
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);
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;
191 for (
const auto& [key, value] : game->runnerConfig.environmentVariables)
193 envVars[QString::fromStdString(key)] = QString::fromStdString(value);
195 runnerConfig[
"environmentVariables"] = envVars;
198 QJsonArray excludeProcs;
199 for (
const auto& proc : game->runnerConfig.excludeProcesses)
201 excludeProcs.append(QString::fromStdString(proc));
203 runnerConfig[
"excludeProcesses"] = excludeProcs;
205 gameObj[
"runnerConfig"] = runnerConfig;
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);
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;
232 for (
const auto& genre : game->metadata.genres)
234 genres.append(QString::fromStdString(genre));
236 metadata[
"genres"] = genres;
239 for (
const auto& tag : game->metadata.tags)
241 tags.append(QString::fromStdString(tag));
243 metadata[
"tags"] = tags;
245 gameObj[
"metadata"] = metadata;
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;
258 QJsonArray collections;
259 for (
const auto& coll : game->collections)
261 collections.append(QString::fromStdString(coll));
263 gameObj[
"collections"] = collections;
265 gamesArray.append(gameObj);
268 int progressPercent = 10 + (processed * 80 /
static_cast<int>(gamesToExport.size()));
270 progressPercent, 100,
271 QString(
"Exported %1 of %2 games...").arg(processed).arg(gamesToExport.size()));
274 emit
progress(90, 100,
"Writing file...");
279 root[
"exportDate"] = QDateTime::currentDateTime().toString(Qt::ISODate);
280 root[
"gameCount"] =
static_cast<int>(gamesToExport.size());
281 root[
"games"] = gamesArray;
284 QJsonArray collectionsArray;
285 for (
const auto& coll : controller_->getCollections())
287 collectionsArray.append(QString::fromStdString(coll));
289 root[
"collections"] = collectionsArray;
291 QJsonDocument doc(root);
293 QFile file(filePath_);
294 if (!file.open(QIODevice::WriteOnly))
296 emit
error(QString(
"Failed to open file for writing: %1").arg(file.errorString()));
300 file.write(doc.toJson(QJsonDocument::Indented));
303 emit
progress(100, 100,
"Export complete!");
306 QString(
"Successfully exported %1 games to:\n%2").arg(gamesToExport.size()).arg(filePath_));
309void LibraryExportWorker::exportCsv()
313 emit
error(
"No library controller available");
317 emit
progress(0, 100,
"Gathering games...");
319 auto allGames = controller_->getAllGames();
322 std::vector<Game*> gamesToExport;
323 if (selectedGameIds_.empty())
325 gamesToExport = allGames;
329 for (
auto* game : allGames)
331 for (
const auto&
id : selectedGameIds_)
335 gamesToExport.push_back(game);
342 if (gamesToExport.empty())
344 emit
error(
"No games to export");
348 emit
progress(10, 100, QString(
"Exporting %1 games to CSV...").arg(gamesToExport.size()));
350 QFile file(filePath_);
351 if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
353 emit
error(QString(
"Failed to open file for writing: %1").arg(file.errorString()));
357 QTextStream stream(&file);
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";
364 auto escapeCSV = [](
const QString& str) -> QString
366 QString escaped = str;
367 if (escaped.contains(
',') || escaped.contains(
'"') || escaped.contains(
'\n'))
369 escaped.replace(
"\"",
"\"\"");
370 return "\"" + escaped +
"\"";
375 auto sourceToString = [](
GameSource source) -> QString
398 auto runnerToString = [](
GameRunner runner) -> QString
441 for (
auto* game : gamesToExport)
446 emit
error(
"Export cancelled");
452 for (
size_t i = 0; i < game->metadata.genres.size(); ++i)
456 genres += QString::fromStdString(game->metadata.genres[i]);
461 for (
size_t i = 0; i < game->collections.size(); ++i)
465 collections += QString::fromStdString(game->collections[i]);
468 double playtimeHours = game->statistics.totalPlayTimeSeconds / 3600.0;
470 QString lastPlayedStr =
471 game->statistics.lastPlayed > 0
472 ? QDateTime::fromSecsSinceEpoch(game->statistics.lastPlayed).toString(
"yyyy-MM-dd")
474 QString dateAddedStr =
475 game->statistics.dateAdded > 0
476 ? QDateTime::fromSecsSinceEpoch(game->statistics.dateAdded).toString(
"yyyy-MM-dd")
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";
494 int progressPercent = 10 + (processed * 85 /
static_cast<int>(gamesToExport.size()));
496 progressPercent, 100,
497 QString(
"Exported %1 of %2 games...").arg(processed).arg(gamesToExport.size()));
502 emit
progress(100, 100,
"Export complete!");
503 emit
finished(
true, QString(
"Successfully exported %1 games to CSV:\n%2")
504 .arg(gamesToExport.size())
508void LibraryExportWorker::importJson()
512 emit
error(
"No library controller available");
516 emit
progress(0, 100,
"Reading file...");
518 QFile file(filePath_);
519 if (!file.open(QIODevice::ReadOnly))
521 emit
error(QString(
"Failed to open file: %1").arg(file.errorString()));
525 QByteArray data = file.readAll();
528 emit
progress(10, 100,
"Parsing JSON...");
530 QJsonParseError parseError;
531 QJsonDocument doc = QJsonDocument::fromJson(data, &parseError);
532 if (parseError.error != QJsonParseError::NoError)
534 emit
error(QString(
"JSON parse error: %1").arg(parseError.errorString()));
538 QJsonObject root = doc.object();
539 int version = root[
"version"].toInt(1);
543 emit
error(QString(
"Unsupported export format version: %1").arg(version));
547 QJsonArray gamesArray = root[
"games"].toArray();
548 if (gamesArray.isEmpty())
550 emit
error(
"No games found in import file");
554 emit
progress(20, 100, QString(
"Importing %1 games...").arg(gamesArray.size()));
560 for (
int i = 0; i < gamesArray.size(); ++i)
564 emit
error(
"Import cancelled");
568 QJsonObject gameObj = gamesArray[i].toObject();
573 game.
id = gameObj[
"id"].toString().toStdString();
574 game.
name = gameObj[
"name"].toString().toStdString();
578 game.
isFavorite = gameObj[
"isFavorite"].toBool();
579 game.
installPath = gameObj[
"installPath"].toString().toStdString();
581 static_cast<uint64_t
>(gameObj[
"installSizeBytes"].toVariant().toLongLong());
583 game.
userNotes = gameObj[
"userNotes"].toString().toStdString();
586 QJsonObject runnerConfigObj = gameObj[
"runnerConfig"].toObject();
590 runnerConfigObj[
"executablePath"].toString().toStdString();
592 runnerConfigObj[
"workingDirectory"].toString().toStdString();
601 runnerConfigObj[
"virtualDesktopHeight"].toInt(1080);
620 QJsonObject envVarsObj = runnerConfigObj[
"environmentVariables"].toObject();
621 for (
const QString& key : envVarsObj.keys())
624 envVarsObj[key].toString().toStdString();
628 QJsonArray excludeProcsArray = runnerConfigObj[
"excludeProcesses"].toArray();
629 for (
const auto& proc : excludeProcsArray)
635 QJsonObject metadataObj = gameObj[
"metadata"].toObject();
646 metadataObj[
"steamLaunchOptions"].toString().toStdString();
649 QJsonObject imagePathsObj = metadataObj[
"imagePaths"].toObject();
651 imagePathsObj[
"verticalCover"].toString().toStdString();
658 QJsonArray genresArray = metadataObj[
"genres"].toArray();
659 for (
const auto& genre : genresArray)
665 QJsonArray tagsArray = metadataObj[
"tags"].toArray();
666 for (
const auto& tag : tagsArray)
668 game.
metadata.
tags.push_back(tag.toString().toStdString());
672 QJsonObject statsObj = gameObj[
"statistics"].toObject();
676 static_cast<time_t
>(statsObj[
"lastPlayed"].toVariant().toLongLong());
678 static_cast<time_t
>(statsObj[
"dateAdded"].toVariant().toLongLong());
680 static_cast<time_t
>(statsObj[
"dateInstalled"].toVariant().toLongLong());
684 QJsonArray collectionsArray = gameObj[
"collections"].toArray();
685 for (
const auto& coll : collectionsArray)
687 game.
collections.push_back(coll.toString().toStdString());
691 const Game* existingGame = controller_->getGame(game.
id);
694 if (overwriteExisting_)
696 controller_->updateGame(game.
id, game);
706 controller_->addGame(game);
710 int progressPercent = 20 +
static_cast<int>((i + 1) * 75 / gamesArray.size());
712 QString(
"Processing game %1 of %2...").arg(i + 1).arg(gamesArray.size()));
716 QJsonArray collectionsArray = root[
"collections"].toArray();
717 for (
const auto& coll : collectionsArray)
719 controller_->addCollection(coll.toString().toStdString());
722 emit
progress(100, 100,
"Import complete!");
724 QString message = QString(
"Import complete:\n- New games: %1\n- Updated: %2\n- Skipped: %3")
731void LibraryExportWorker::backupDatabase()
733 emit
progress(0, 100,
"Creating backup...");
736 QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
737 QString dbPath = dataDir +
"/gamelauncher/games.db";
739 QFileInfo dbInfo(dbPath);
740 if (!dbInfo.exists())
742 emit
error(
"Database file not found");
746 emit
progress(30, 100,
"Copying database...");
749 if (QFile::exists(filePath_))
751 QFile::remove(filePath_);
754 if (!QFile::copy(dbPath, filePath_))
756 emit
error(
"Failed to copy database file");
760 emit
progress(100, 100,
"Backup complete!");
761 emit
finished(
true, QString(
"Database backup created:\n%1\n\nSize: %2")
763 .arg(QLocale().formattedDataSize(dbInfo.size())));
766void LibraryExportWorker::restoreDatabase()
768 emit
progress(0, 100,
"Verifying backup file...");
770 QFileInfo backupInfo(filePath_);
771 if (!backupInfo.exists())
773 emit
error(
"Backup file not found");
778 QFile backupFile(filePath_);
779 if (!backupFile.open(QIODevice::ReadOnly))
781 emit
error(
"Cannot read backup file");
785 QByteArray header = backupFile.read(16);
788 if (!header.startsWith(
"SQLite format 3"))
790 emit
error(
"Invalid backup file (not a SQLite database)");
794 emit
progress(30, 100,
"Restoring database...");
797 QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
798 QString dbPath = dataDir +
"/gamelauncher/games.db";
801 QString timestamp = QDateTime::currentDateTime().toString(
"yyyyMMdd_HHmmss");
802 QString currentBackup = dbPath +
".backup_" + timestamp;
804 if (QFile::exists(dbPath))
806 if (!QFile::rename(dbPath, currentBackup))
808 emit
error(
"Failed to backup current database");
813 emit
progress(60, 100,
"Copying backup...");
816 if (!QFile::copy(filePath_, dbPath))
819 QFile::rename(currentBackup, dbPath);
820 emit
error(
"Failed to restore from backup");
824 emit
progress(100, 100,
"Restore complete!");
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));
836 : QWidget(parent), themeManager_(themeManager ? themeManager : &
ThemeManager::instance())
844void ExportOptionsWidget::setupUI()
846 auto* layout =
new QVBoxLayout(
this);
847 layout->setContentsMargins(0, 0, 0, 0);
848 layout->setSpacing(16);
851 auto* formatGroup =
new QGroupBox(
"Export Format");
852 auto* formatLayout =
new QVBoxLayout(formatGroup);
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);
859 formatGroup_->addButton(jsonRadio_);
860 formatGroup_->addButton(csvRadio_);
862 formatLayout->addWidget(jsonRadio_);
863 formatLayout->addWidget(csvRadio_);
864 layout->addWidget(formatGroup);
867 auto* scopeGroup =
new QGroupBox(
"Export Scope");
868 auto* scopeLayout =
new QGridLayout(scopeGroup);
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);
877 scopeGroup_->addButton(allGamesRadio_);
878 scopeGroup_->addButton(selectedRadio_);
879 scopeGroup_->addButton(byCollectionRadio_);
880 scopeGroup_->addButton(bySourceRadio_);
882 collectionCombo_ =
new QComboBox;
883 collectionCombo_->setEnabled(
false);
884 collectionCombo_->setMinimumWidth(150);
886 sourceCombo_ =
new QComboBox;
887 sourceCombo_->setEnabled(
false);
888 sourceCombo_->setMinimumWidth(150);
889 sourceCombo_->addItems({
"Steam",
"GOG",
"Epic",
"Lutris",
"Local",
"Itch",
"Flatpak"});
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);
898 layout->addWidget(scopeGroup);
901 auto* optionsGroup =
new QGroupBox(
"Include in Export");
902 auto* optionsLayout =
new QVBoxLayout(optionsGroup);
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);
909 optionsLayout->addWidget(includeStatsCheck_);
910 optionsLayout->addWidget(includeConfigsCheck_);
911 layout->addWidget(optionsGroup);
913 layout->addStretch();
916 connect(byCollectionRadio_, &QRadioButton::toggled,
this, &ExportOptionsWidget::onScopeChanged);
917 connect(bySourceRadio_, &QRadioButton::toggled,
this, &ExportOptionsWidget::onScopeChanged);
920void ExportOptionsWidget::onScopeChanged()
922 collectionCombo_->setEnabled(byCollectionRadio_->isChecked());
923 sourceCombo_->setEnabled(bySourceRadio_->isChecked());
933 if (selectedRadio_->isChecked())
935 if (byCollectionRadio_->isChecked())
937 if (bySourceRadio_->isChecked())
944 return collectionCombo_->currentText();
949 return sourceCombo_->currentText();
954 return includeStatsCheck_->isChecked();
959 return includeConfigsCheck_->isChecked();
964 collectionCombo_->clear();
965 collectionCombo_->addItems(collections);
970 sourceCombo_->clear();
971 sourceCombo_->addItems(sources);
976 const auto& c = themeManager_->colors();
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; "
985 "QGroupBox::title { "
986 " subcontrol-origin: margin; "
991 .arg(c.border.name(), c.textPrimary.name());
993 for (
auto* groupBox : findChildren<QGroupBox*>())
995 groupBox->setStyleSheet(groupBoxStyle);
1004 : QWidget(parent), themeManager_(themeManager ? themeManager : &
ThemeManager::instance())
1012void ImportOptionsWidget::setupUI()
1014 auto* layout =
new QVBoxLayout(
this);
1015 layout->setContentsMargins(0, 0, 0, 0);
1016 layout->setSpacing(16);
1019 auto* conflictGroup =
new QGroupBox(
"Conflict Handling");
1020 auto* conflictLayout =
new QVBoxLayout(conflictGroup);
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");
1026 warningLabel_ =
new QLabel(
"Warning: Overwriting will replace existing game configurations!");
1027 warningLabel_->setWordWrap(
true);
1028 warningLabel_->setVisible(
false);
1030 conflictLayout->addWidget(overwriteCheck_);
1031 conflictLayout->addWidget(warningLabel_);
1032 layout->addWidget(conflictGroup);
1035 auto* optionsGroup =
new QGroupBox(
"Import Options");
1036 auto* optionsLayout =
new QVBoxLayout(optionsGroup);
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);
1043 optionsLayout->addWidget(importStatsCheck_);
1044 optionsLayout->addWidget(importConfigsCheck_);
1045 layout->addWidget(optionsGroup);
1047 layout->addStretch();
1050 connect(overwriteCheck_, &QCheckBox::toggled, warningLabel_, &QLabel::setVisible);
1055 return overwriteCheck_->isChecked();
1060 return importStatsCheck_->isChecked();
1065 return importConfigsCheck_->isChecked();
1070 const auto& c = themeManager_->colors();
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; "
1079 "QGroupBox::title { "
1080 " subcontrol-origin: margin; "
1085 .arg(c.border.name(), c.textPrimary.name());
1087 for (
auto* groupBox : findChildren<QGroupBox*>())
1089 groupBox->setStyleSheet(groupBoxStyle);
1092 warningLabel_->setStyleSheet(QString(
"color: %1; font-style: italic;").arg(c.warning.name()));
1100 : QWidget(parent), themeManager_(themeManager ? themeManager : &
ThemeManager::instance())
1108void BackupOptionsWidget::setupUI()
1110 auto* layout =
new QVBoxLayout(
this);
1111 layout->setContentsMargins(0, 0, 0, 0);
1112 layout->setSpacing(16);
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);
1122 auto* optionsGroup =
new QGroupBox(
"Backup Options");
1123 auto* optionsLayout =
new QVBoxLayout(optionsGroup);
1125 includeImagesCheck_ =
new QCheckBox(
"Include cached images (larger backup)");
1126 includeImagesCheck_->setEnabled(
false);
1127 includeImagesCheck_->setToolTip(
"Coming soon");
1129 compressCheck_ =
new QCheckBox(
"Compress backup (smaller file)");
1130 compressCheck_->setEnabled(
false);
1131 compressCheck_->setToolTip(
"Coming soon");
1133 sizeEstimateLabel_ =
new QLabel(
"Estimated backup size: calculating...");
1135 optionsLayout->addWidget(includeImagesCheck_);
1136 optionsLayout->addWidget(compressCheck_);
1137 optionsLayout->addWidget(sizeEstimateLabel_);
1138 layout->addWidget(optionsGroup);
1140 layout->addStretch();
1143 QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
1144 QString dbPath = dataDir +
"/gamelauncher/games.db";
1145 QFileInfo dbInfo(dbPath);
1146 if (dbInfo.exists())
1148 sizeEstimateLabel_->setText(
1149 QString(
"Estimated backup size: %1").arg(QLocale().formattedDataSize(dbInfo.size())));
1153 sizeEstimateLabel_->setText(
"Database not found");
1159 return includeImagesCheck_->isChecked();
1164 return compressCheck_->isChecked();
1169 const auto& c = themeManager_->colors();
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; "
1178 "QGroupBox::title { "
1179 " subcontrol-origin: margin; "
1184 .arg(c.border.name(), c.textPrimary.name());
1186 for (
auto* groupBox : findChildren<QGroupBox*>())
1188 groupBox->setStyleSheet(groupBoxStyle);
1191 QPalette sizePal = sizeEstimateLabel_->palette();
1192 sizePal.setColor(QPalette::WindowText, c.textSecondary);
1193 sizeEstimateLabel_->setPalette(sizePal);
1201 : QDialog(parent), themeManager_(themeManager ? themeManager : &
ThemeManager::instance())
1203 setWindowTitle(
"Library Export / Backup");
1204 setMinimumSize(600, 500);
1221 workerThread_->quit();
1222 workerThread_->wait(3000);
1231 controller_ = controller;
1233 if (controller_ && exportOptions_)
1236 QStringList collections;
1237 for (
const auto& coll : controller_->getCollections())
1239 collections << QString::fromStdString(coll);
1241 exportOptions_->setCollections(collections);
1247 selectedGameIds_ = ids;
1250void LibraryExportDialog::setupUI()
1252 auto* mainLayout =
new QVBoxLayout(
this);
1253 mainLayout->setSpacing(16);
1254 mainLayout->setContentsMargins(20, 20, 20, 20);
1257 contentStack_ =
new QStackedWidget;
1260 auto* mainContent =
new QWidget;
1261 auto* mainContentLayout =
new QVBoxLayout(mainContent);
1262 mainContentLayout->setContentsMargins(0, 0, 0, 0);
1265 tabWidget_ =
new QTabWidget;
1268 auto* exportTab =
new QWidget;
1269 setupExportTab(exportTab);
1270 tabWidget_->addTab(exportTab,
"Export");
1273 auto* importTab =
new QWidget;
1274 setupImportTab(importTab);
1275 tabWidget_->addTab(importTab,
"Import");
1278 auto* backupTab =
new QWidget;
1279 setupBackupTab(backupTab);
1280 tabWidget_->addTab(backupTab,
"Database Backup");
1282 mainContentLayout->addWidget(tabWidget_);
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);
1293 contentStack_->addWidget(mainContent);
1296 progressWidget_ =
new QWidget;
1297 auto* progressLayout =
new QVBoxLayout(progressWidget_);
1298 progressLayout->setAlignment(Qt::AlignCenter);
1300 progressLabel_ =
new QLabel(
"Processing...");
1301 progressLabel_->setAlignment(Qt::AlignCenter);
1303 progressBar_ =
new QProgressBar;
1304 progressBar_->setMinimum(0);
1305 progressBar_->setMaximum(100);
1306 progressBar_->setMinimumWidth(400);
1308 cancelBtn_ =
new QPushButton(
"Cancel");
1309 connect(cancelBtn_, &QPushButton::clicked,
this,
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();
1325 contentStack_->addWidget(progressWidget_);
1328 resultWidget_ =
new QWidget;
1329 auto* resultLayout =
new QVBoxLayout(resultWidget_);
1330 resultLayout->setAlignment(Qt::AlignCenter);
1332 resultIcon_ =
new QLabel;
1333 resultIcon_->setAlignment(Qt::AlignCenter);
1335 resultLabel_ =
new QLabel;
1336 resultLabel_->setAlignment(Qt::AlignCenter);
1337 resultLabel_->setWordWrap(
true);
1339 resultDetails_ =
new QTextEdit;
1340 resultDetails_->setReadOnly(
true);
1341 resultDetails_->setMaximumHeight(150);
1342 resultDetails_->setVisible(
false);
1344 doneBtn_ =
new QPushButton(
"Done");
1345 doneBtn_->setMinimumWidth(100);
1346 connect(doneBtn_, &QPushButton::clicked,
this,
1349 contentStack_->setCurrentIndex(0);
1350 setOperationInProgress(
false);
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();
1361 contentStack_->addWidget(resultWidget_);
1363 mainLayout->addWidget(contentStack_);
1366void LibraryExportDialog::setupExportTab(QWidget* tab)
1368 auto* layout =
new QVBoxLayout(tab);
1369 layout->setSpacing(16);
1371 exportOptions_ =
new ExportOptionsWidget(
this, themeManager_);
1372 layout->addWidget(exportOptions_);
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...");
1381 pathLayout->addWidget(pathLabel);
1382 pathLayout->addWidget(exportPathEdit_, 1);
1383 pathLayout->addWidget(exportBrowseBtn_);
1384 layout->addLayout(pathLayout);
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);
1394 connect(exportBrowseBtn_, &QPushButton::clicked,
this, &LibraryExportDialog::onBrowseExport);
1395 connect(exportBtn_, &QPushButton::clicked,
this, &LibraryExportDialog::onExportClicked);
1398void LibraryExportDialog::setupImportTab(QWidget* tab)
1400 auto* layout =
new QVBoxLayout(tab);
1401 layout->setSpacing(16);
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...");
1410 pathLayout->addWidget(pathLabel);
1411 pathLayout->addWidget(importPathEdit_, 1);
1412 pathLayout->addWidget(importBrowseBtn_);
1413 layout->addLayout(pathLayout);
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...");
1422 layout->addWidget(previewLabel);
1423 layout->addWidget(importPreview_);
1425 importOptions_ =
new ImportOptionsWidget(
this, themeManager_);
1426 layout->addWidget(importOptions_);
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);
1436 connect(importBrowseBtn_, &QPushButton::clicked,
this, &LibraryExportDialog::onBrowseImport);
1437 connect(importBtn_, &QPushButton::clicked,
this, &LibraryExportDialog::onImportClicked);
1440void LibraryExportDialog::setupBackupTab(QWidget* tab)
1442 auto* layout =
new QVBoxLayout(tab);
1443 layout->setSpacing(16);
1445 backupOptions_ =
new BackupOptionsWidget(
this, themeManager_);
1446 layout->addWidget(backupOptions_);
1449 auto* backupGroup =
new QGroupBox(
"Create Backup");
1450 auto* backupLayout =
new QVBoxLayout(backupGroup);
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...");
1458 backupPathLayout->addWidget(backupPathLabel);
1459 backupPathLayout->addWidget(backupPathEdit_, 1);
1460 backupPathLayout->addWidget(backupBrowseBtn_);
1461 backupLayout->addLayout(backupPathLayout);
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);
1470 layout->addWidget(backupGroup);
1473 auto* restoreGroup =
new QGroupBox(
"Restore from Backup");
1474 auto* restoreLayout =
new QVBoxLayout(restoreGroup);
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...");
1482 restorePathLayout->addWidget(restorePathLabel);
1483 restorePathLayout->addWidget(restorePathEdit_, 1);
1484 restorePathLayout->addWidget(restoreBrowseBtn_);
1485 restoreLayout->addLayout(restorePathLayout);
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);
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);
1500 layout->addWidget(restoreGroup);
1502 layout->addStretch();
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);
1510void LibraryExportDialog::onBrowseExport()
1513 QString defaultName;
1514 QString timestamp = QDateTime::currentDateTime().toString(
"yyyyMMdd");
1518 filter =
"JSON Files (*.json);;All Files (*)";
1519 defaultName = QString(
"gamelauncher_export_%1.json").arg(timestamp);
1523 filter =
"CSV Files (*.csv);;All Files (*)";
1524 defaultName = QString(
"gamelauncher_export_%1.csv").arg(timestamp);
1527 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1528 QString path = QFileDialog::getSaveFileName(
this,
"Export Library",
1529 documentsPath +
"/" + defaultName, filter);
1531 if (!path.isEmpty())
1533 exportPathEdit_->setText(path);
1537void LibraryExportDialog::onBrowseImport()
1539 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1540 QString path = QFileDialog::getOpenFileName(
this,
"Import Library", documentsPath,
1541 "JSON Files (*.json);;All Files (*)");
1543 if (!path.isEmpty())
1545 importPathEdit_->setText(path);
1549 if (file.open(QIODevice::ReadOnly))
1551 QByteArray fileData = file.read(2048);
1554 QJsonParseError parseError;
1555 QJsonDocument doc = QJsonDocument::fromJson(fileData, &parseError);
1557 if (parseError.error == QJsonParseError::NoError)
1559 QJsonObject root = doc.object();
1560 int gameCount = root[
"gameCount"].toInt();
1561 QString exportDate = root[
"exportDate"].toString();
1562 int version = root[
"version"].toInt();
1564 QString preview = QString(
"File version: %1\n"
1566 "Games in file: %3")
1570 importPreview_->setText(preview);
1574 importPreview_->setText(
"Error parsing file: " + parseError.errorString());
1580void LibraryExportDialog::onBrowseBackup()
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);
1587 QFileDialog::getSaveFileName(
this,
"Save Backup", documentsPath +
"/" + defaultName,
1588 "Database Files (*.db);;All Files (*)");
1590 if (!path.isEmpty())
1592 backupPathEdit_->setText(path);
1596void LibraryExportDialog::onBrowseRestore()
1598 QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1599 QString path = QFileDialog::getOpenFileName(
this,
"Select Backup", documentsPath,
1600 "Database Files (*.db);;All Files (*)");
1602 if (!path.isEmpty())
1604 restorePathEdit_->setText(path);
1608void LibraryExportDialog::onExportClicked()
1610 QString path = exportPathEdit_->text().trimmed();
1613 QMessageBox::warning(
this,
"Export",
"Please select an output file.");
1621 startOperation(op, path);
1624void LibraryExportDialog::onImportClicked()
1626 QString path = importPathEdit_->text().trimmed();
1629 QMessageBox::warning(
this,
"Import",
"Please select a file to import.");
1633 if (!QFile::exists(path))
1635 QMessageBox::warning(
this,
"Import",
"Selected file does not exist.");
1642void LibraryExportDialog::onBackupClicked()
1644 QString path = backupPathEdit_->text().trimmed();
1647 QMessageBox::warning(
this,
"Backup",
"Please select a backup location.");
1654void LibraryExportDialog::onRestoreClicked()
1656 QString path = restorePathEdit_->text().trimmed();
1659 QMessageBox::warning(
this,
"Restore",
"Please select a backup file.");
1663 if (!QFile::exists(path))
1665 QMessageBox::warning(
this,
"Restore",
"Selected backup file does not exist.");
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);
1677 if (result == QMessageBox::Yes)
1685 if (operationInProgress_)
1688 setOperationInProgress(
true);
1691 workerThread_ =
new QThread(
this);
1692 worker_ =
new LibraryExportWorker;
1694 worker_->setOperation(op);
1695 worker_->setFilePath(filePath);
1696 worker_->setController(controller_);
1701 worker_->setOverwriteExisting(importOptions_->overwriteExisting());
1708 if (exportOptions_ &&
1711 worker_->setSelectedGames(selectedGameIds_);
1715 worker_->moveToThread(workerThread_);
1720 &LibraryExportDialog::onOperationFinished);
1725 connect(workerThread_, &QThread::finished, worker_, &QObject::deleteLater);
1728 contentStack_->setCurrentWidget(progressWidget_);
1729 progressBar_->setValue(0);
1730 progressLabel_->setText(
"Starting...");
1732 workerThread_->start();
1735void LibraryExportDialog::setOperationInProgress(
bool inProgress)
1737 operationInProgress_ = inProgress;
1738 closeBtn_->setEnabled(!inProgress);
1739 exportBtn_->setEnabled(!inProgress);
1740 importBtn_->setEnabled(!inProgress);
1741 backupBtn_->setEnabled(!inProgress);
1742 restoreBtn_->setEnabled(!inProgress);
1745void LibraryExportDialog::onProgress(
int current,
int total,
const QString& status)
1747 progressBar_->setMaximum(total);
1748 progressBar_->setValue(current);
1749 progressLabel_->setText(status);
1752void LibraryExportDialog::onOperationFinished(
bool success,
const QString& message)
1754 const auto& c = themeManager_->colors();
1758 resultIcon_->setText(
"\xE2\x9C\x93");
1759 resultIcon_->setStyleSheet(QString(
"font-size: 48px; color: %1;").arg(c.success.name()));
1763 resultIcon_->setText(
"\xE2\x9C\x97");
1764 resultIcon_->setStyleSheet(QString(
"font-size: 48px; color: %1;").arg(c.error.name()));
1767 resultLabel_->setText(message);
1768 resultDetails_->setVisible(
false);
1770 contentStack_->setCurrentWidget(resultWidget_);
1773void LibraryExportDialog::onError(
const QString& message)
1775 onOperationFinished(
false,
"Operation failed:\n" + message);
1778void LibraryExportDialog::applyTheme()
1780 const auto& c = themeManager_->colors();
1783 setStyleSheet(QString(
"QDialog { background-color: %1; }").arg(c.windowBackground.name()));
1787 QString(
"QTabWidget::pane { "
1788 " border: 1px solid %1; "
1789 " border-radius: 6px; "
1793 " padding: 8px 16px; "
1795 " border: 1px solid %1; "
1796 " border-bottom: none; "
1797 " border-top-left-radius: 6px; "
1798 " border-top-right-radius: 6px; "
1801 "QTabBar::tab:selected { "
1805 "QTabBar::tab:hover:!selected { "
1808 .arg(c.border.name(), c.cardBackground.name(), c.windowBackground.name(),
1809 c.textSecondary.name(), c.textPrimary.name(), c.hoverBackground.name());
1811 tabWidget_->setStyleSheet(tabStyle);
1814 QString lineEditStyle =
1815 QString(
"QLineEdit { "
1816 " background-color: %1; "
1817 " border: 1px solid %2; "
1818 " border-radius: 4px; "
1819 " padding: 6px 10px; "
1822 "QLineEdit:focus { "
1823 " border-color: %4; "
1825 .arg(c.inputBackground.name(), c.border.name(), c.textPrimary.name(), c.accent.name());
1827 for (
auto* lineEdit : findChildren<QLineEdit*>())
1829 lineEdit->setStyleSheet(lineEditStyle);
1833 QString buttonStyle = QString(
"QPushButton { "
1834 " background-color: %1; "
1835 " border: 1px solid %2; "
1836 " border-radius: 6px; "
1837 " padding: 8px 16px; "
1839 " font-weight: 500; "
1841 "QPushButton:hover { "
1842 " background-color: %4; "
1844 "QPushButton:pressed { "
1845 " background-color: %5; "
1847 "QPushButton:disabled { "
1848 " background-color: %6; "
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());
1855 QString primaryButtonStyle =
1856 QString(
"QPushButton { "
1857 " background-color: %1; "
1859 " border-radius: 6px; "
1860 " padding: 8px 16px; "
1862 " font-weight: bold; "
1864 "QPushButton:hover { "
1865 " background-color: %2; "
1867 "QPushButton:pressed { "
1868 " background-color: %3; "
1870 "QPushButton:disabled { "
1871 " background-color: %4; "
1874 .arg(c.accent.name(), c.accentHover.name(), c.accentPressed.name(),
1875 c.cardBackground.name(), c.textMuted.name(), c.textOnAccent.name());
1877 for (
auto* btn : findChildren<QPushButton*>())
1879 btn->setStyleSheet(buttonStyle);
1883 exportBtn_->setStyleSheet(primaryButtonStyle);
1884 importBtn_->setStyleSheet(primaryButtonStyle);
1885 backupBtn_->setStyleSheet(primaryButtonStyle);
1886 restoreBtn_->setStyleSheet(primaryButtonStyle);
1887 doneBtn_->setStyleSheet(primaryButtonStyle);
1890 QString progressStyle = QString(
"QProgressBar { "
1891 " border: 1px solid %1; "
1892 " border-radius: 4px; "
1895 " text-align: center; "
1897 "QProgressBar::chunk { "
1899 " border-radius: 3px; "
1901 .arg(c.border.name(), c.inputBackground.name(), c.accent.name());
1903 progressBar_->setStyleSheet(progressStyle);
1906 QString textEditStyle =
1907 QString(
"QTextEdit { "
1908 " background-color: %1; "
1909 " border: 1px solid %2; "
1910 " border-radius: 4px; "
1914 .arg(c.inputBackground.name(), c.border.name(), c.textPrimary.name());
1917 importPreview_->setStyleSheet(textEditStyle);
1919 resultDetails_->setStyleSheet(textEditStyle);
1922 for (
auto* label : findChildren<QLabel*>())
1924 if (label != resultIcon_ && label != resultLabel_)
1926 label->setStyleSheet(QString(
"color: %1;").arg(c.textPrimary.name()));
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()));
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; "
1941 "QGroupBox::title { "
1942 " subcontrol-origin: margin; "
1947 .arg(c.border.name(), c.textPrimary.name());
1949 for (
auto* groupBox : findChildren<QGroupBox*>())
1951 groupBox->setStyleSheet(groupBoxStyle);
1956 exportOptions_->applyTheme();
1958 importOptions_->applyTheme();
1960 backupOptions_->applyTheme();
GameMetadata metadata
Descriptive information and media.
std::string userNotes
User's personal notes about the game.
std::vector< std::string > collections
Collections this game belongs to.
std::string installPath
Installation directory path.
CompletionStatus completionStatus
User's completion status.
bool isFavorite
Is this marked as a favorite game?
std::string name
Display name shown in UI.
std::string id
Unique identifier (auto-generated or user-specified).
GameStatistics statistics
Play statistics and usage tracking.
GameRunner runner
Runner/compatibility layer to use (Native, Proton, Wine, etc.).
GameRunnerConfig runnerConfig
How to launch and run the game.
GameStatus status
Current installation and execution status.
uint64_t installSizeBytes
Installation size in bytes.
GameSource source
Where the game was acquired from (Steam, GOG, Local, etc.).
void setController(core::GameLibraryController *controller)
void setSelectedGameIds(const std::vector< std::string > &ids)
LibraryExportDialog(QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
~LibraryExportDialog() override
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).
@ Steam
Steam store/platform.
@ Local
Manually added game (not from a store).
@ Itch
itch.io indie games
@ Lutris
Lutris community scripts.
@ GOG
GOG.com (DRM-free games).
@ Flatpak
Flatpak package.
GameStatus
Current installation and execution status of the game.
GameRunner
Runner/compatibility layer for executing the game.
@ Proton
Proton (Steam's Wine fork).
@ Native
Native Linux executable (no compatibility layer).
@ Wine
Wine compatibility layer.
CompletionStatus
User's completion/play status for tracking backlog.
@ Played
Played but no clear completion criteria (e.g., multiplayer).
@ Completed
100% completion (achievements, side content, etc.)
@ Abandoned
Stopped playing, unlikely to return.
@ Beaten
Main story/campaign completed.
@ OnHold
Temporarily paused.
@ Playing
Currently playing.
@ NotPlayed
Never played (backlog).
std::string header
Small header image (header.jpg, 460x215).
std::string logo
Game logo with transparency (logo.png).
std::string icon
Small square icon (icon.jpg).
std::string verticalCover
Vertical cover art (library_600x900.jpg).
std::string heroImage
Wide banner/hero image (library_hero.jpg).
bool enableVkBasalt
Enable VkBasalt shader injection.
std::string executablePath
Full path to game executable.
bool useSteamDefaults
For Steam games: if true, don't sync custom env vars/wrappers to Steam's VDF files.
int virtualDesktopWidth
Virtual desktop width in pixels.
std::string wineDLL
DLL overrides (e.g., "d3d11=native,builtin").
bool gamescopeFullscreen
Run in fullscreen mode.
std::string workingDirectory
Working directory for game execution.
bool useVirtualDesktop
Launch game in Wine virtual desktop.
std::string arguments
Command line arguments to pass to game.
std::vector< std::string > excludeProcesses
Processes to exclude when tracking launcher child processes These are helper processes that should no...
int gamescopeHeight
Gamescope output height (0 = native).
bool gamescopeEnableFSR
Enable AMD FSR upscaling.
bool enableMangoHud
Enable MangoHud performance overlay.
std::string winePath
Custom Wine binary path (e.g., from Lutris config).
std::string winePrefix
WINEPREFIX path (Wine install location).
int gamescopeFSRSharpness
FSR sharpness (0-20, 0 = max sharp).
bool enableGamePerformance
Enable game-performance wrapper (CachyOS).
bool enableFsync
Enable Fsync (kernel 5.16+, best performance).
int gamescopeRefreshRate
Refresh rate limit (0 = no limit).
bool autoDetectSync
Auto-detect best sync method (default: true).
int gamescopeWidth
Gamescope output width (0 = native).
bool enableDetailedLogging
Enable detailed Wine/Proton logging.
std::string runnerVersion
Runner version: "wine-8.0", "proton-8.0-5", etc.
std::string runnerType
Runner type: "wine", "proton", "native", etc.
bool enableGameMode
Enable GameMode CPU governor optimization.
int virtualDesktopHeight
Virtual desktop height in pixels.
bool enableGamescope
Enable Gamescope compositor.
std::string protonVersion
Proton version (e.g., "proton-cachyos-slr").
std::map< std::string, std::string > environmentVariables
Environment variables to set before launching (KEY=VALUE pairs).
bool gamescopeBorderless
Borderless window mode.
time_t dateInstalled
Unix timestamp when installed.
double totalPlayTimeSeconds
Total play time in seconds (for all sessions).
time_t lastPlayed
Unix timestamp of last play session.
int timesLaunched
Number of times game was launched.
time_t dateAdded
Unix timestamp when added to library.
int crashCount
Number of times game has crashed.
@ Game
Game-specific fixes.