12#include <QApplication>
34 group->setStyleSheet(QString(
"QGroupBox {"
36 " border: 1px solid %1;"
37 " border-left: 3px solid %1;"
38 " border-radius: 6px;"
40 " padding: 12px 8px 8px 8px;"
44 " subcontrol-origin: margin;"
50 "QCheckBox { color: %2; spacing: 8px; }"
51 "QRadioButton { color: %2; spacing: 8px; }"
52 "QLabel { color: %2; }")
58 group->setStyleSheet(QString(
"QGroupBox {"
59 " border: 1px solid %1;"
60 " border-left: 3px solid %2;"
61 " border-radius: 6px;"
63 " padding: 12px 8px 8px 8px;"
67 " subcontrol-origin: margin;"
73 "QCheckBox { color: %3; spacing: 8px; }"
74 "QRadioButton { color: %3; spacing: 8px; }"
75 "QLabel { color: %3; }")
103 return QString(
"steam_%1").arg(
steamGame->appId);
128 int totalSources = 0;
135 if (config_.heroicEpic)
137 if (config_.heroicGOG)
139 if (config_.legendary)
141 if (config_.nativeGames)
143 if (config_.winePrefixes)
146 int completedSources = 0;
148 auto updateProgress = [&](
const QString& source,
const QString& op)
150 int percent = totalSources > 0 ? (completedSources * 100) / totalSources : 0;
155 if (config_.steam && !cancelled_)
157 updateProgress(
"Steam",
"Scanning Steam library...");
163 if (config_.lutris && !cancelled_)
165 updateProgress(
"Lutris",
"Scanning Lutris games...");
166 size_t before = results_.size();
168 emit
sourceComplete(
"Lutris",
static_cast<int>(results_.size() - before));
172 if (config_.bottles && !cancelled_)
174 updateProgress(
"Bottles",
"Scanning Bottles...");
175 size_t before = results_.size();
177 emit
sourceComplete(
"Bottles",
static_cast<int>(results_.size() - before));
181 if ((config_.heroicEpic || config_.heroicGOG) && !cancelled_)
183 updateProgress(
"Heroic",
"Scanning Heroic Launcher...");
184 size_t before = results_.size();
186 emit
sourceComplete(
"Heroic",
static_cast<int>(results_.size() - before));
190 if (config_.legendary && !cancelled_)
192 updateProgress(
"Legendary",
"Scanning Legendary...");
193 size_t before = results_.size();
195 emit
sourceComplete(
"Legendary",
static_cast<int>(results_.size() - before));
199 if (config_.nativeGames && !cancelled_)
201 updateProgress(
"Native",
"Scanning native games...");
202 size_t before = results_.size();
204 emit
sourceComplete(
"Native",
static_cast<int>(results_.size() - before));
208 if (config_.winePrefixes && !cancelled_)
210 updateProgress(
"Wine",
"Scanning Wine prefixes...");
211 size_t before = results_.size();
213 emit
sourceComplete(
"Wine",
static_cast<int>(results_.size() - before));
220 deduplicateResults();
251 if (std::filesystem::exists(sg.
gamePath /
"toolmanifest.vdf"))
255 if (std::filesystem::exists(sg.
gamePath /
"_CommonRedist"))
262 const std::string& name = sg.
name;
265 if (name.rfind(
"Proton ", 0) == 0)
269 if (name.rfind(
"Steam Linux Runtime", 0) == 0)
273 if (name.rfind(
"Source SDK", 0) == 0)
277 if (name.find(
"Steamworks Common Redistribut") != std::string::npos)
281 if (name.find(
"EasyAntiCheat Runtime") != std::string::npos)
283 if (name.find(
"BattlEye Runtime") != std::string::npos)
287 if (name ==
"Steam Client" || name ==
"Steam Game Notes" || name ==
"Steam Screenshots")
293void GameImportWorker::scanSteam()
295 SteamLibraryScanner scanner;
301 for (
const auto& sg : steamGames)
311 game.
name = QString::fromStdString(sg.name);
315 game.
runner = sg.isProtonGame ?
"Proton" :
"Native";
316 game.
path = QString::fromStdString(sg.installDir);
319 game.
steamGame = std::make_shared<SteamGame>(sg);
328 results_.push_back(game);
332void GameImportWorker::scanLutris()
335 for (
auto& sg : games)
341 game.
name = QString::fromStdString(sg.name);
347 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
350 game.
scannedGame = std::make_shared<ScannedGame>(sg);
352 results_.push_back(game);
356void GameImportWorker::scanBottles()
359 for (
auto& sg : games)
365 game.
name = QString::fromStdString(sg.name);
371 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
374 game.
scannedGame = std::make_shared<ScannedGame>(sg);
376 results_.push_back(game);
380void GameImportWorker::scanHeroic()
384 for (
auto& sg : games)
390 game.
name = QString::fromStdString(sg.name);
394 if (!config_.heroicEpic)
402 if (!config_.heroicGOG)
414 game.
path = QString::fromStdString(sg.installDir);
417 game.
scannedGame = std::make_shared<ScannedGame>(sg);
419 results_.push_back(game);
423void GameImportWorker::scanLegendary()
426 for (
auto& sg : games)
432 game.
name = QString::fromStdString(sg.name);
437 game.
path = QString::fromStdString(sg.installDir);
440 game.
scannedGame = std::make_shared<ScannedGame>(sg);
442 results_.push_back(game);
446void GameImportWorker::scanNative()
449 for (
auto& sg : games)
455 if (sg.installDir.find(
"/Steam/") != std::string::npos ||
456 sg.installDir.find(
"/steamapps/") != std::string::npos)
462 game.
name = QString::fromStdString(sg.name);
468 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
471 game.
scannedGame = std::make_shared<ScannedGame>(sg);
473 results_.push_back(game);
477void GameImportWorker::scanWinePrefixes()
480 for (
auto& sg : games)
486 game.
name = QString::fromStdString(sg.name);
492 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
495 game.
scannedGame = std::make_shared<ScannedGame>(sg);
497 results_.push_back(game);
501void GameImportWorker::deduplicateResults()
504 std::set<uint32_t> steamAppIds;
505 std::set<QString> steamInstallPaths;
507 for (
const auto& game : results_)
511 steamAppIds.insert(game.
steamGame->appId);
514 steamInstallPaths.insert(QString::fromStdString(game.
steamGame->gamePath.string()));
520 auto it = std::remove_if(
521 results_.begin(), results_.end(),
522 [&](
const ImportableGame& game)
524 if (game.sourceType == ImportableGame::SourceType::Steam)
528 if (!game.path.isEmpty())
530 for (const auto& steamPath : steamInstallPaths)
532 if (game.path.startsWith(steamPath))
540 QString execPath = QString::fromStdString(game.scannedGame->executablePath);
541 QString installDir = QString::fromStdString(game.scannedGame->installDir);
543 for (const auto& steamPath : steamInstallPaths)
545 if ((!execPath.isEmpty() && execPath.startsWith(steamPath)) ||
546 (!installDir.isEmpty() && installDir.startsWith(steamPath)))
556 auto removed = std::distance(it, results_.end());
557 results_.erase(it, results_.end());
571 : QDialog(parent), libraryController_(libraryController),
572 themeManager_(themeManager ? themeManager : &
ThemeManager::instance())
575 setWindowTitle(
"Import Games");
585 steamStats.name =
"Steam";
586 steamStats.icon =
"\u25B6";
587 steamStats.available = steamAvailable;
588 steamStats.enabled =
true;
591 lutrisStats.name =
"Lutris";
592 lutrisStats.icon =
"\u2617";
594 lutrisStats.enabled =
true;
597 bottlesStats.name =
"Bottles";
598 bottlesStats.icon =
"\u25A3";
600 bottlesStats.enabled =
true;
603 heroicEpicStats.name =
"Epic (Heroic)";
604 heroicEpicStats.icon =
"\u25B6";
606 heroicEpicStats.enabled =
true;
609 heroicGOGStats.name =
"GOG (Heroic)";
610 heroicGOGStats.icon =
"\u25CB";
612 heroicGOGStats.enabled =
true;
615 legendaryStats.name =
"Legendary";
616 legendaryStats.icon =
"\u25B6";
618 legendaryStats.enabled =
true;
621 nativeStats.name =
"Native";
622 nativeStats.icon =
"\u25A0";
623 nativeStats.available =
true;
624 nativeStats.enabled =
true;
627 winePrefixStats.name =
"Wine Prefix";
628 winePrefixStats.icon =
"\u2617";
629 winePrefixStats.available =
true;
630 winePrefixStats.enabled =
false;
646 workerThread_->quit();
647 workerThread_->wait();
651void GameImportDialog::setupUI()
653 QVBoxLayout* mainLayout =
new QVBoxLayout(
this);
657 new QLabel(
"Import games from various sources into your library. Select which sources "
658 "to scan, then choose which games to import.",
660 descLabel->setWordWrap(
true);
661 mainLayout->addWidget(descLabel);
664 QHBoxLayout* contentLayout =
new QHBoxLayout();
668 contentLayout->addWidget(sourceGroup_);
671 QWidget* resultsWidget =
new QWidget(
this);
672 QVBoxLayout* resultsLayout =
new QVBoxLayout(resultsWidget);
673 resultsLayout->setContentsMargins(0, 0, 0, 0);
677 QHBoxLayout* progressLayout =
new QHBoxLayout();
678 statusLabel_ =
new QLabel(
"Select sources and click Scan to find games",
this);
679 progressLayout->addWidget(statusLabel_, 1);
680 progressBar_ =
new QProgressBar(
this);
681 progressBar_->setRange(0, 100);
682 progressBar_->setVisible(
false);
683 progressBar_->setMaximumWidth(200);
684 progressLayout->addWidget(progressBar_);
685 resultsLayout->addLayout(progressLayout);
688 QHBoxLayout* filterLayout =
new QHBoxLayout();
689 hideImportedCheck_ =
new QCheckBox(
"Hide already imported",
this);
690 hideImportedCheck_->setChecked(
true);
691 connect(hideImportedCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onFilterChanged);
692 filterLayout->addWidget(hideImportedCheck_);
694 showInstalledOnlyCheck_ =
new QCheckBox(
"Show installed only",
this);
695 showInstalledOnlyCheck_->setChecked(
false);
696 connect(showInstalledOnlyCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onFilterChanged);
697 filterLayout->addWidget(showInstalledOnlyCheck_);
699 filterLayout->addStretch();
700 resultsLayout->addLayout(filterLayout);
703 gameTree_ =
new QTreeWidget(
this);
704 gameTree_->setHeaderLabels({
"",
"Name",
"Source",
"Runner",
"Size",
"Path"});
705 gameTree_->setRootIsDecorated(
false);
706 gameTree_->setAlternatingRowColors(
true);
707 gameTree_->setSelectionMode(QAbstractItemView::NoSelection);
708 gameTree_->header()->setStretchLastSection(
true);
709 gameTree_->header()->setSectionResizeMode(0, QHeaderView::Fixed);
710 gameTree_->header()->setSectionResizeMode(1, QHeaderView::Stretch);
711 gameTree_->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
712 gameTree_->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
713 gameTree_->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
714 gameTree_->setColumnWidth(0, 30);
715 connect(gameTree_, &QTreeWidget::itemChanged,
this, &GameImportDialog::onItemChanged);
716 resultsLayout->addWidget(gameTree_);
719 statsLabel_ =
new QLabel(
this);
720 resultsLayout->addWidget(statsLabel_);
723 QHBoxLayout* selectionLayout =
new QHBoxLayout();
724 selectAllBtn_ =
new QPushButton(
"Select All",
this);
725 selectAllBtn_->setEnabled(
false);
726 connect(selectAllBtn_, &QPushButton::clicked,
this, &GameImportDialog::onSelectAll);
727 selectionLayout->addWidget(selectAllBtn_);
729 selectNoneBtn_ =
new QPushButton(
"Select None",
this);
730 selectNoneBtn_->setEnabled(
false);
731 connect(selectNoneBtn_, &QPushButton::clicked,
this, &GameImportDialog::onSelectNone);
732 selectionLayout->addWidget(selectNoneBtn_);
734 selectInstalledBtn_ =
new QPushButton(
"Select Installed",
this);
735 selectInstalledBtn_->setEnabled(
false);
736 connect(selectInstalledBtn_, &QPushButton::clicked,
this, &GameImportDialog::onSelectInstalled);
737 selectionLayout->addWidget(selectInstalledBtn_);
739 selectionLayout->addStretch();
740 resultsLayout->addLayout(selectionLayout);
742 contentLayout->addWidget(resultsWidget, 1);
743 mainLayout->addLayout(contentLayout, 1);
746 QHBoxLayout* buttonLayout =
new QHBoxLayout();
748 scanBtn_ =
new QPushButton(
"Scan",
this);
749 scanBtn_->setDefault(
true);
750 connect(scanBtn_, &QPushButton::clicked,
this, &GameImportDialog::onScanClicked);
751 buttonLayout->addWidget(scanBtn_);
753 buttonLayout->addStretch();
755 importBtn_ =
new QPushButton(
"Import Selected",
this);
756 importBtn_->setEnabled(
false);
757 connect(importBtn_, &QPushButton::clicked,
this, &GameImportDialog::onImportClicked);
758 buttonLayout->addWidget(importBtn_);
760 closeBtn_ =
new QPushButton(
"Close",
this);
761 connect(closeBtn_, &QPushButton::clicked,
this, &QDialog::reject);
762 buttonLayout->addWidget(closeBtn_);
764 mainLayout->addLayout(buttonLayout);
767void GameImportDialog::setupSourcePanel()
769 const auto& c = themeManager_->colors();
770 sourceGroup_ =
new QGroupBox(
"Sources",
this);
771 sourceGroup_->setMaximumWidth(250);
773 QGridLayout* layout =
new QGridLayout(sourceGroup_);
778 steamCheck_ =
new QCheckBox(
"Steam", sourceGroup_);
779 steamCheck_->setChecked(
true);
780 connect(steamCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
781 layout->addWidget(steamCheck_, row, 0);
782 steamStats_ =
new QLabel(
"", sourceGroup_);
783 steamStats_->setStyleSheet(
784 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
785 layout->addWidget(steamStats_, row, 1);
789 lutrisCheck_ =
new QCheckBox(
"Lutris", sourceGroup_);
790 lutrisCheck_->setChecked(
true);
791 connect(lutrisCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
792 layout->addWidget(lutrisCheck_, row, 0);
793 lutrisStats_ =
new QLabel(
"", sourceGroup_);
794 lutrisStats_->setStyleSheet(
795 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
796 layout->addWidget(lutrisStats_, row, 1);
800 bottlesCheck_ =
new QCheckBox(
"Bottles", sourceGroup_);
801 bottlesCheck_->setChecked(
true);
802 connect(bottlesCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
803 layout->addWidget(bottlesCheck_, row, 0);
804 bottlesStats_ =
new QLabel(
"", sourceGroup_);
805 bottlesStats_->setStyleSheet(
806 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
807 layout->addWidget(bottlesStats_, row, 1);
811 heroicEpicCheck_ =
new QCheckBox(
"Epic (Heroic)", sourceGroup_);
812 heroicEpicCheck_->setChecked(
true);
813 connect(heroicEpicCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
814 layout->addWidget(heroicEpicCheck_, row, 0);
815 heroicEpicStats_ =
new QLabel(
"", sourceGroup_);
816 heroicEpicStats_->setStyleSheet(
817 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
818 layout->addWidget(heroicEpicStats_, row, 1);
822 heroicGOGCheck_ =
new QCheckBox(
"GOG (Heroic)", sourceGroup_);
823 heroicGOGCheck_->setChecked(
true);
824 connect(heroicGOGCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
825 layout->addWidget(heroicGOGCheck_, row, 0);
826 heroicGOGStats_ =
new QLabel(
"", sourceGroup_);
827 heroicGOGStats_->setStyleSheet(
828 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
829 layout->addWidget(heroicGOGStats_, row, 1);
833 legendaryCheck_ =
new QCheckBox(
"Legendary", sourceGroup_);
834 legendaryCheck_->setChecked(
true);
835 connect(legendaryCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
836 layout->addWidget(legendaryCheck_, row, 0);
837 legendaryStats_ =
new QLabel(
"", sourceGroup_);
838 legendaryStats_->setStyleSheet(
839 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
840 layout->addWidget(legendaryStats_, row, 1);
844 nativeCheck_ =
new QCheckBox(
"Native Games", sourceGroup_);
845 nativeCheck_->setChecked(
true);
846 connect(nativeCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
847 layout->addWidget(nativeCheck_, row, 0);
848 nativeStats_ =
new QLabel(
"", sourceGroup_);
849 nativeStats_->setStyleSheet(
850 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
851 layout->addWidget(nativeStats_, row, 1);
855 winePrefixCheck_ =
new QCheckBox(
"Wine Prefixes", sourceGroup_);
856 winePrefixCheck_->setChecked(
false);
857 connect(winePrefixCheck_, &QCheckBox::toggled,
this, &GameImportDialog::onSourceToggled);
858 layout->addWidget(winePrefixCheck_, row, 0);
859 winePrefixStats_ =
new QLabel(
"", sourceGroup_);
860 winePrefixStats_->setStyleSheet(
861 QString(
"color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
862 layout->addWidget(winePrefixStats_, row, 1);
865 layout->setRowStretch(row, 1);
868void GameImportDialog::setupResultsPanel()
873void GameImportDialog::updateSourceStats()
875 const auto& c = themeManager_->colors();
876 auto updateLabel = [&c](QLabel* label, QCheckBox* check,
const ImportSourceStats& stats)
878 if (!stats.available)
880 label->setText(
"✗ not found");
881 label->setStyleSheet(QString(
"color: %1; font-size: 11px;").arg(c.error.name()));
882 check->setEnabled(
false);
883 check->setChecked(
false);
885 else if (stats.gamesFound > 0)
887 int newCount = stats.gamesNew;
888 QString text = QString(
"✓ %1 found").arg(stats.gamesFound);
889 if (newCount > 0 && newCount < stats.gamesFound)
890 text += QString(
" (%1 new)").arg(newCount);
891 label->setText(text);
892 label->setStyleSheet(QString(
"color: %1; font-size: 11px;").arg(c.success.name()));
896 label->setText(
"✓ ready");
897 label->setStyleSheet(
898 QString(
"color: %1; font-size: 11px;").arg(c.textSecondary.name()));
905 updateLabel(heroicEpicStats_, heroicEpicCheck_,
907 updateLabel(heroicGOGStats_, heroicGOGCheck_,
909 updateLabel(legendaryStats_, legendaryCheck_,
912 updateLabel(winePrefixStats_, winePrefixCheck_,
916void GameImportDialog::onSourceToggled()
918 sourceConfig_.steam = steamCheck_->isChecked();
919 sourceConfig_.lutris = lutrisCheck_->isChecked();
920 sourceConfig_.bottles = bottlesCheck_->isChecked();
921 sourceConfig_.heroicEpic = heroicEpicCheck_->isChecked();
922 sourceConfig_.heroicGOG = heroicGOGCheck_->isChecked();
923 sourceConfig_.legendary = legendaryCheck_->isChecked();
924 sourceConfig_.nativeGames = nativeCheck_->isChecked();
925 sourceConfig_.winePrefixes = winePrefixCheck_->isChecked();
928void GameImportDialog::onScanClicked()
934 scanBtn_->setEnabled(
false);
935 selectAllBtn_->setEnabled(
false);
936 selectNoneBtn_->setEnabled(
false);
937 selectInstalledBtn_->setEnabled(
false);
938 importBtn_->setEnabled(
false);
940 importableGames_.clear();
942 progressBar_->setVisible(
true);
943 progressBar_->setValue(0);
944 statusLabel_->setText(
"Starting scan...");
947 for (
auto& [type, stats] : sourceStats_)
949 stats.gamesFound = 0;
957 workerThread_ =
new QThread(
this);
958 worker_ =
new GameImportWorker();
959 worker_->setSourceConfig(sourceConfig_);
960 worker_->moveToThread(workerThread_);
968 connect(workerThread_, &QThread::finished, worker_, &QObject::deleteLater);
970 workerThread_->start();
973void GameImportDialog::onProgressUpdate(
const QString& source,
const QString& operation,
976 statusLabel_->setText(QString(
"%1: %2").arg(source, operation));
977 progressBar_->setValue(percent);
980void GameImportDialog::onSourceComplete(
const QString& source,
int gamesFound)
984 if (source ==
"Steam")
986 else if (source ==
"Lutris")
988 else if (source ==
"Bottles")
990 else if (source ==
"Native")
992 else if (source ==
"Wine")
998void GameImportDialog::onScanComplete(
const std::vector<ImportableGame>& games)
1001 importableGames_ = games;
1004 markAlreadyImported();
1006 progressBar_->setVisible(
false);
1007 statusLabel_->setText(QString(
"Found %1 game(s)").arg(games.size()));
1010 scanBtn_->setEnabled(
true);
1011 selectAllBtn_->setEnabled(
true);
1012 selectNoneBtn_->setEnabled(
true);
1013 selectInstalledBtn_->setEnabled(
true);
1016 for (
auto& [type, stats] : sourceStats_)
1018 stats.gamesFound = 0;
1021 for (
const auto& game : importableGames_)
1029 updateSourceStats();
1034void GameImportDialog::onScanError(
const QString& error)
1037 progressBar_->setVisible(
false);
1038 statusLabel_->setText(error);
1039 scanBtn_->setEnabled(
true);
1041 QMessageBox::warning(
this,
"Scan Error", error);
1044void GameImportDialog::markAlreadyImported()
1046 if (!libraryController_)
1049 auto libraryPtrs = libraryController_->getAllGames();
1052 std::set<std::string> knownPaths;
1053 std::set<int> knownSteamAppIds;
1055 for (
const auto* gamePtr : libraryPtrs)
1060 if (!gamePtr->runnerConfig.executablePath.empty())
1062 knownPaths.insert(gamePtr->runnerConfig.executablePath);
1064 if (!gamePtr->installPath.empty())
1066 knownPaths.insert(gamePtr->installPath);
1068 if (gamePtr->metadata.steamAppId > 0)
1070 knownSteamAppIds.insert(gamePtr->metadata.steamAppId);
1075 for (
auto& game : importableGames_)
1077 if (game.
steamGame && knownSteamAppIds.count(
static_cast<int>(game.
steamGame->appId)))
1083 if (knownPaths.count(game.
scannedGame->executablePath) ||
1092void GameImportDialog::populateGameList()
1094 gameTree_->blockSignals(
true);
1097 bool hideImported = hideImportedCheck_->isChecked();
1098 bool installedOnly = showInstalledOnlyCheck_->isChecked();
1100 for (
size_t i = 0; i < importableGames_.size(); ++i)
1102 const auto& game = importableGames_[i];
1110 QTreeWidgetItem* item =
new QTreeWidgetItem();
1111 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
1112 item->setCheckState(0, game.
alreadyImported ? Qt::Unchecked : Qt::Checked);
1113 item->setData(0, Qt::UserRole,
static_cast<int>(i));
1115 item->setText(1, game.
name);
1117 item->setText(3, game.
runner);
1119 item->setText(5, game.
path);
1124 for (
int col = 0; col < 6; ++col)
1126 item->setForeground(col, Qt::gray);
1128 item->setToolTip(1,
"Already in library");
1134 item->setForeground(1, themeManager_->colors().textMuted);
1135 item->setText(3,
"(not installed)");
1138 gameTree_->addTopLevelItem(item);
1141 gameTree_->blockSignals(
false);
1145void GameImportDialog::updateStats()
1147 int total = gameTree_->topLevelItemCount();
1150 for (
int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1152 if (gameTree_->topLevelItem(i)->checkState(0) == Qt::Checked)
1158 statsLabel_->setText(QString(
"Showing %1 game(s), %2 selected").arg(total).arg(selected));
1159 importBtn_->setEnabled(selected > 0);
1162void GameImportDialog::onFilterChanged()
1167void GameImportDialog::onItemChanged(QTreeWidgetItem* ,
int column)
1175void GameImportDialog::onSelectAll()
1177 gameTree_->blockSignals(
true);
1178 for (
int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1180 gameTree_->topLevelItem(i)->setCheckState(0, Qt::Checked);
1182 gameTree_->blockSignals(
false);
1186void GameImportDialog::onSelectNone()
1188 gameTree_->blockSignals(
true);
1189 for (
int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1191 gameTree_->topLevelItem(i)->setCheckState(0, Qt::Unchecked);
1193 gameTree_->blockSignals(
false);
1197void GameImportDialog::onSelectInstalled()
1199 gameTree_->blockSignals(
true);
1200 for (
int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1202 QTreeWidgetItem* item = gameTree_->topLevelItem(i);
1203 int idx = item->data(0, Qt::UserRole).toInt();
1204 if (idx >= 0 && idx <
static_cast<int>(importableGames_.size()))
1206 bool installed = importableGames_[
static_cast<size_t>(idx)].isInstalled;
1207 item->setCheckState(0, installed ? Qt::Checked : Qt::Unchecked);
1210 gameTree_->blockSignals(
false);
1214void GameImportDialog::onImportClicked()
1216 if (!libraryController_)
1223 for (
int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1225 QTreeWidgetItem* item = gameTree_->topLevelItem(i);
1226 if (item->checkState(0) != Qt::Checked)
1229 int idx = item->data(0, Qt::UserRole).toInt();
1230 if (idx < 0 || idx >=
static_cast<int>(importableGames_.size()))
1233 const auto& importGame = importableGames_[
static_cast<size_t>(idx)];
1238 std::string
id = libraryController_->addGame(game);
1242 errors.append(QString(
"Failed to add: %1").arg(importGame.name));
1248 item->setCheckState(0, Qt::Unchecked);
1249 for (
int col = 0; col < 6; ++col)
1251 item->setForeground(col, Qt::gray);
1254 catch (
const std::exception& e)
1257 errors.append(QString(
"%1: %2").arg(importGame.name, e.what()));
1262 QString message = QString(
"Imported %1 game(s)").arg(imported);
1265 message += QString(
"\nFailed to import %1 game(s)").arg(failed);
1268 if (failed > 0 && !errors.isEmpty())
1270 QMessageBox::warning(
this,
"Import Complete",
1271 message +
"\n\nErrors:\n" + errors.join(
"\n"));
1275 QMessageBox::information(
this,
"Import Complete", message);
1281 markAlreadyImported();
1298 return "Epic (Heroic)";
1300 return "GOG (Heroic)";
1306 return "Wine Prefix";
1337QString GameImportDialog::getRunnerDisplayName(
const QString& runner)
const
1339 if (runner ==
"Native")
1341 if (runner ==
"Wine")
1343 if (runner ==
"Proton")
1348QString GameImportDialog::formatSize(uint64_t bytes)
const
1353 const char* units[] = {
"B",
"KB",
"MB",
"GB",
"TB"};
1355 double size =
static_cast<double>(bytes);
1357 while (size >= 1024.0 && unitIndex < 4)
1365 return QString(
"%1 B").arg(
static_cast<int>(size));
1367 return QString(
"%1 %2").arg(size, 0,
'f', 1).arg(units[unitIndex]);
1374void GameImportDialog::applyTheme()
1376 const auto& c = themeManager_->colors();
1387 progressBar_->setStyleSheet(
1388 QString(
"QProgressBar {"
1389 " border: 1px solid %1;"
1390 " border-radius: 4px;"
1392 " text-align: center;"
1394 "QProgressBar::chunk {"
1396 " border-radius: 3px;"
1398 .arg(c.border.name(), c.inputBackground.name(), c.accent.name()));
1404 QColor accentFaded = c.accent;
1405 accentFaded.setAlpha(40);
1407 gameTree_->setStyleSheet(QString(
"QTreeWidget {"
1409 " alternate-background-color: %2;"
1411 "QTreeWidget::item {"
1412 " padding: 5px 8px;"
1414 "QTreeWidget::item:selected {"
1418 "QTreeWidget::item:hover {"
1421 .arg(c.cardBackground.name(), c.panelBackground.name(),
1422 accentFaded.name(QColor::HexArgb), c.textPrimary.name(),
1423 c.hoverBackground.name()));
1425 gameTree_->setAlternatingRowColors(
true);
1431 scanBtn_->setStyleSheet(QString(
"QPushButton {"
1432 " background-color: %1;"
1435 " border-radius: 6px;"
1436 " padding: 8px 24px;"
1437 " font-weight: bold;"
1439 "QPushButton:hover { background-color: %3; }"
1440 "QPushButton:pressed { background-color: %4; }"
1441 "QPushButton:disabled { background-color: %5; color: %6; }")
1442 .arg(c.accent.name(), c.textOnAccent.name(),
1443 c.accentHover.name(), c.accentPressed.name(),
1444 c.inputBackground.name(), c.textMuted.name()));
1450 importBtn_->setStyleSheet(
1451 QString(
"QPushButton {"
1452 " background-color: %1;"
1455 " border-radius: 6px;"
1456 " padding: 8px 24px;"
1457 " font-weight: bold;"
1459 "QPushButton:hover { background-color: %3; }"
1460 "QPushButton:pressed { background-color: %4; }"
1461 "QPushButton:disabled { background-color: %5; color: %6; }")
1462 .arg(c.success.name(), c.textOnAccent.name(),
1465 c.textMuted.name()));
1469 auto styleSecondaryButton = [&c](QPushButton* btn)
1474 QString(
"QPushButton {"
1475 " background-color: %1;"
1477 " border: 1px solid %3;"
1478 " border-radius: 6px;"
1479 " padding: 7px 14px;"
1481 "QPushButton:hover { background-color: %4; border-color: %5; }"
1482 "QPushButton:disabled { background-color: %6; color: %7; border-color: %6; }")
1483 .arg(c.cardBackground.name(), c.textPrimary.name(), c.border.name(),
1484 c.hoverBackground.name(), c.accent.name(), c.inputBackground.name(),
1485 c.textMuted.name()));
1488 styleSecondaryButton(selectAllBtn_);
1489 styleSecondaryButton(selectNoneBtn_);
1490 styleSecondaryButton(selectInstalledBtn_);
1491 styleSecondaryButton(closeBtn_);
1494 auto styleStatLabel = [&c](QLabel* label)
1498 label->setStyleSheet(QString(
"color: %1; font-size: 11px;").arg(c.textMuted.name()));
1501 styleStatLabel(steamStats_);
1502 styleStatLabel(lutrisStats_);
1503 styleStatLabel(bottlesStats_);
1504 styleStatLabel(heroicEpicStats_);
1505 styleStatLabel(heroicGOGStats_);
1506 styleStatLabel(legendaryStats_);
1507 styleStatLabel(nativeStats_);
1508 styleStatLabel(winePrefixStats_);
1513 QPalette p = statusLabel_->palette();
1514 p.setColor(QPalette::WindowText, c.textSecondary);
1515 statusLabel_->setPalette(p);
1521 statsLabel_->setStyleSheet(
1522 QString(
"color: %1; font-size: 11px;").arg(c.textSecondary.name()));
GameImportDialog(core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
~GameImportDialog() override
void sourceComplete(const QString &source, int gamesFound)
void scanComplete(const std::vector< ImportableGame > &games)
void progressUpdate(const QString &source, const QString &operation, int percent)
void scanError(const QString &error)
void setSourceConfig(const ImportSourceConfig &config)
GameImportWorker(QObject *parent=nullptr)
static bool isHeroicInstalled()
Check if Heroic Launcher is installed.
static std::vector< ScannedGame > scanLegendary()
Scan Legendary (Epic Games CLI) for installed games.
static bool isLegendaryInstalled()
Check if Legendary is installed.
static std::vector< ScannedGame > scanWinePrefixes()
Scan generic Wine prefixes for games.
static std::vector< ScannedGame > scanBottles()
Scan Bottles for installed games.
static bool isLutrisInstalled()
Check if Lutris is installed.
static bool isBottlesInstalled()
Check if Bottles is installed.
static std::vector< ScannedGame > scanNativeGames()
Scan for native Linux games.
static std::vector< ScannedGame > scanLutris()
Scan Lutris for installed games.
static std::vector< ScannedGame > scanHeroic()
Scan Heroic Launcher for Epic and GOG games.
Complete representation of a game in the library.
Scans Steam installations to discover games.
bool isSteamInstalled() const
Check if Steam is installed on this system.
std::vector< SteamGame > scanAllOwnedGames()
Scan for all owned Steam games (installed and not installed).
static void populateDirectLaunchInfo(SteamGame &game)
Populate a SteamGame with direct-launch information.
static QColor darkenColor(const QColor &color, int amount)
Darken a color by decreasing its lightness.
void themeChanged()
Emitted when theme or accent color changes.
static QColor lightenColor(const QColor &color, int amount)
Lighten a color by increasing its lightness.
@ GOG
GOG.com (DRM-free games).
@ Wine
Wine compatibility layer.
static bool isSteamToolOrRuntime(const SteamGame &sg)
static void applyGroupStyle(QGroupBox *group, const ThemeColors &c, bool highlight=false)
Configuration for which sources to scan.
QString getUniqueId() const
std::shared_ptr< SteamGame > steamGame
std::shared_ptr< ScannedGame > scannedGame
Metadata for a Steam game parsed from appmanifest ACF file.
std::string name
Game name.
bool isInstalled
True if game is installed (has appmanifest), false if owned but not installed.
std::filesystem::path gamePath
Full path to game directory.
@ Game
Game-specific fixes.