game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
gameimportdialog.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/gameimportdialog.cpp
4// ==============================================================================
5// Unified game import dialog implementation
6// ==============================================================================
7
10#include "theme_manager.h"
11
12#include <QApplication>
13#include <QGridLayout>
14#include <QHBoxLayout>
15#include <QHeaderView>
16#include <QMessageBox>
17#include <QVBoxLayout>
18
19#include <algorithm>
20#include <set>
21
22// ==============================================================================
23// Styling Helper - Consistent Group Box Visual Treatment
24// ==============================================================================
25
26static void applyGroupStyle(QGroupBox* group, const ThemeColors& c, bool highlight = false)
27{
28 // Uses the global QGroupBox style by default (accent left border).
29 // Only override when highlight is requested for special emphasis.
30 // IMPORTANT: Local stylesheets on a parent widget create a CSS scope barrier
31 // in Qt, so we must include text color rules for child widgets too.
32 if (highlight)
33 {
34 group->setStyleSheet(QString("QGroupBox {"
35 " font-weight: bold;"
36 " border: 1px solid %1;"
37 " border-left: 3px solid %1;"
38 " border-radius: 6px;"
39 " margin-top: 16px;"
40 " padding: 12px 8px 8px 8px;"
41 " color: %2;"
42 "}"
43 "QGroupBox::title {"
44 " subcontrol-origin: margin;"
45 " left: 12px;"
46 " padding: 0 6px;"
47 " color: %1;"
48 " font-weight: bold;"
49 "}"
50 "QCheckBox { color: %2; spacing: 8px; }"
51 "QRadioButton { color: %2; spacing: 8px; }"
52 "QLabel { color: %2; }")
53 .arg(c.accent.name(), c.textPrimary.name()));
54 }
55 else
56 {
57 // Non-highlighted groups: explicit title color for readability
58 group->setStyleSheet(QString("QGroupBox {"
59 " border: 1px solid %1;"
60 " border-left: 3px solid %2;"
61 " border-radius: 6px;"
62 " margin-top: 16px;"
63 " padding: 12px 8px 8px 8px;"
64 " color: %3;"
65 "}"
66 "QGroupBox::title {"
67 " subcontrol-origin: margin;"
68 " left: 12px;"
69 " padding: 0 6px;"
70 " color: %4;"
71 " font-weight: 600;"
72 "}"
73 "QCheckBox { color: %3; spacing: 8px; }"
74 "QRadioButton { color: %3; spacing: 8px; }"
75 "QLabel { color: %3; }")
76 .arg(c.borderLight.name(), c.textSecondary.name(),
77 c.textPrimary.name(), c.textPrimary.name()));
78 }
79}
80
81// ==============================================================================
82// ImportableGame Implementation
83// ==============================================================================
84
86{
87 if (steamGame)
88 {
89 return steamGame->toGame();
90 }
91 else if (scannedGame)
92 {
93 return scannedGame->toGame();
94 }
95 return Game();
96}
97
99{
100 // Create unique ID based on source and path
101 if (steamGame)
102 {
103 return QString("steam_%1").arg(steamGame->appId);
104 }
105 else if (scannedGame)
106 {
107 return QString::fromStdString(scannedGame->id);
108 }
109 return QString();
110}
111
112// ==============================================================================
113// GameImportWorker Implementation
114// ==============================================================================
115
116GameImportWorker::GameImportWorker(QObject* parent) : QObject(parent) {}
117
119{
120 config_ = config;
121}
122
124{
125 cancelled_ = false;
126 results_.clear();
127
128 int totalSources = 0;
129 if (config_.steam)
130 totalSources++;
131 if (config_.lutris)
132 totalSources++;
133 if (config_.bottles)
134 totalSources++;
135 if (config_.heroicEpic)
136 totalSources++;
137 if (config_.heroicGOG)
138 totalSources++;
139 if (config_.legendary)
140 totalSources++;
141 if (config_.nativeGames)
142 totalSources++;
143 if (config_.winePrefixes)
144 totalSources++;
145
146 int completedSources = 0;
147
148 auto updateProgress = [&](const QString& source, const QString& op)
149 {
150 int percent = totalSources > 0 ? (completedSources * 100) / totalSources : 0;
151 emit progressUpdate(source, op, percent);
152 };
153
154 // Scan each enabled source
155 if (config_.steam && !cancelled_)
156 {
157 updateProgress("Steam", "Scanning Steam library...");
158 scanSteam();
159 completedSources++;
160 emit sourceComplete("Steam", static_cast<int>(results_.size()));
161 }
162
163 if (config_.lutris && !cancelled_)
164 {
165 updateProgress("Lutris", "Scanning Lutris games...");
166 size_t before = results_.size();
167 scanLutris();
168 emit sourceComplete("Lutris", static_cast<int>(results_.size() - before));
169 completedSources++;
170 }
171
172 if (config_.bottles && !cancelled_)
173 {
174 updateProgress("Bottles", "Scanning Bottles...");
175 size_t before = results_.size();
176 scanBottles();
177 emit sourceComplete("Bottles", static_cast<int>(results_.size() - before));
178 completedSources++;
179 }
180
181 if ((config_.heroicEpic || config_.heroicGOG) && !cancelled_)
182 {
183 updateProgress("Heroic", "Scanning Heroic Launcher...");
184 size_t before = results_.size();
185 scanHeroic();
186 emit sourceComplete("Heroic", static_cast<int>(results_.size() - before));
187 completedSources++;
188 }
189
190 if (config_.legendary && !cancelled_)
191 {
192 updateProgress("Legendary", "Scanning Legendary...");
193 size_t before = results_.size();
194 scanLegendary();
195 emit sourceComplete("Legendary", static_cast<int>(results_.size() - before));
196 completedSources++;
197 }
198
199 if (config_.nativeGames && !cancelled_)
200 {
201 updateProgress("Native", "Scanning native games...");
202 size_t before = results_.size();
203 scanNative();
204 emit sourceComplete("Native", static_cast<int>(results_.size() - before));
205 completedSources++;
206 }
207
208 if (config_.winePrefixes && !cancelled_)
209 {
210 updateProgress("Wine", "Scanning Wine prefixes...");
211 size_t before = results_.size();
212 scanWinePrefixes();
213 emit sourceComplete("Wine", static_cast<int>(results_.size() - before));
214 completedSources++;
215 }
216
217 if (!cancelled_)
218 {
219 // Deduplicate across sources — prefer Steam entries over Native/Local
220 deduplicateResults();
221 emit progressUpdate("Complete", "Scan complete", 100);
222 emit scanComplete(results_);
223 }
224}
225
227{
228 cancelled_ = true;
229}
230
231// ---------------------------------------------------------------------------
232// Classify Steam apps as tools/runtimes/redistributables (not actual games).
233//
234// Strategy (layered, most-reliable first):
235// 1. Filesystem check: Steam marks every tool with a "toolmanifest.vdf"
236// inside its install directory. This catches all Proton versions,
237// Steam Linux Runtimes, anti-cheat runtimes, etc. — even future ones
238// we've never seen before.
239// 2. Redistributable marker: the "_CommonRedist" directory inside the
240// install folder is the hallmark of Steamworks Common Redistributables.
241// 3. Name-pattern heuristics: catch uninstalled (owned-only) entries that
242// have no install directory to inspect, plus known Steam internal apps
243// that don't appear on disk at all.
244// ---------------------------------------------------------------------------
245static bool isSteamToolOrRuntime(const SteamGame& sg)
246{
247 // --- Layer 1: Filesystem markers (installed apps) -----------------------
248 if (sg.isInstalled && !sg.gamePath.empty())
249 {
250 // Steam's own marker: every compatibility tool ships a toolmanifest.vdf
251 if (std::filesystem::exists(sg.gamePath / "toolmanifest.vdf"))
252 return true;
253
254 // Steamworks Common Redistributables contain _CommonRedist/
255 if (std::filesystem::exists(sg.gamePath / "_CommonRedist"))
256 return true;
257 }
258
259 // --- Layer 2: Name-pattern heuristics -----------------------------------
260 // Needed for owned-but-not-installed entries (no install dir to inspect)
261 // and as a safety net for any edge cases the filesystem check misses.
262 const std::string& name = sg.name;
263
264 // Proton versions: "Proton 10.0", "Proton Experimental", "Proton Hotfix", etc.
265 if (name.rfind("Proton ", 0) == 0)
266 return true;
267
268 // Steam Linux Runtime variants: "Steam Linux Runtime 1.0 (scout)", etc.
269 if (name.rfind("Steam Linux Runtime", 0) == 0)
270 return true;
271
272 // Source SDK: "Source SDK Base 2007", "Source SDK Base 2013 Multiplayer", etc.
273 if (name.rfind("Source SDK", 0) == 0)
274 return true;
275
276 // Steamworks redistributables (covers any name variation)
277 if (name.find("Steamworks Common Redistribut") != std::string::npos)
278 return true;
279
280 // Anti-cheat / DRM runtimes that ship as separate apps
281 if (name.find("EasyAntiCheat Runtime") != std::string::npos)
282 return true;
283 if (name.find("BattlEye Runtime") != std::string::npos)
284 return true;
285
286 // Steam internal pseudo-apps (no install dir, not launchable)
287 if (name == "Steam Client" || name == "Steam Game Notes" || name == "Steam Screenshots")
288 return true;
289
290 return false;
291}
292
293void GameImportWorker::scanSteam()
294{
295 SteamLibraryScanner scanner;
296 if (!scanner.isSteamInstalled())
297 return;
298
299 auto steamGames = scanner.scanAllOwnedGames();
300
301 for (const auto& sg : steamGames)
302 {
303 if (cancelled_)
304 break;
305
306 // Skip Steam tools, runtimes, and redistributables
307 if (isSteamToolOrRuntime(sg))
308 continue;
309
310 ImportableGame game;
311 game.name = QString::fromStdString(sg.name);
313 game.sourceName = "Steam";
314 game.sourceIcon = "\u25B6"; // Game controller emoji
315 game.runner = sg.isProtonGame ? "Proton" : "Native";
316 game.path = QString::fromStdString(sg.installDir);
317 game.sizeBytes = sg.sizeOnDisk;
318 game.isInstalled = sg.isInstalled;
319 game.steamGame = std::make_shared<SteamGame>(sg);
320
321 // Populate direct-launch info (executable path, Proton version)
322 // so toGame() can set up direct Proton launch instead of steam -applaunch
323 if (game.isInstalled)
324 {
326 }
327
328 results_.push_back(game);
329 }
330}
331
332void GameImportWorker::scanLutris()
333{
334 auto games = GameScannerService::scanLutris();
335 for (auto& sg : games)
336 {
337 if (cancelled_)
338 break;
339
340 ImportableGame game;
341 game.name = QString::fromStdString(sg.name);
343 game.sourceName = "Lutris";
344 game.sourceIcon = "\u2617"; // Grapes emoji (Lutris icon is grapes)
345 game.runner = sg.runner == GameRunner::Wine ? "Wine" : "Native";
346 game.path =
347 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
348 game.sizeBytes = sg.sizeOnDisk;
349 game.isInstalled = true;
350 game.scannedGame = std::make_shared<ScannedGame>(sg);
351
352 results_.push_back(game);
353 }
354}
355
356void GameImportWorker::scanBottles()
357{
358 auto games = GameScannerService::scanBottles();
359 for (auto& sg : games)
360 {
361 if (cancelled_)
362 break;
363
364 ImportableGame game;
365 game.name = QString::fromStdString(sg.name);
367 game.sourceName = "Bottles";
368 game.sourceIcon = "\u25A3"; // Bottle emoji
369 game.runner = "Wine";
370 game.path =
371 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
372 game.sizeBytes = sg.sizeOnDisk;
373 game.isInstalled = true;
374 game.scannedGame = std::make_shared<ScannedGame>(sg);
375
376 results_.push_back(game);
377 }
378}
379
380void GameImportWorker::scanHeroic()
381{
382 // Heroic handles both Epic and GOG
383 auto games = GameScannerService::scanHeroic();
384 for (auto& sg : games)
385 {
386 if (cancelled_)
387 break;
388
389 ImportableGame game;
390 game.name = QString::fromStdString(sg.name);
391
392 if (sg.source == GameSource::Epic)
393 {
394 if (!config_.heroicEpic)
395 continue;
397 game.sourceName = "Epic (Heroic)";
398 game.sourceIcon = "\u25B6"; // Game controller
399 }
400 else if (sg.source == GameSource::GOG)
401 {
402 if (!config_.heroicGOG)
403 continue;
405 game.sourceName = "GOG (Heroic)";
406 game.sourceIcon = "\u25CB"; // Die emoji
407 }
408 else
409 {
410 continue;
411 }
412
413 game.runner = sg.runner == GameRunner::Wine ? "Wine" : "Native";
414 game.path = QString::fromStdString(sg.installDir);
415 game.sizeBytes = sg.sizeOnDisk;
416 game.isInstalled = true;
417 game.scannedGame = std::make_shared<ScannedGame>(sg);
418
419 results_.push_back(game);
420 }
421}
422
423void GameImportWorker::scanLegendary()
424{
426 for (auto& sg : games)
427 {
428 if (cancelled_)
429 break;
430
431 ImportableGame game;
432 game.name = QString::fromStdString(sg.name);
434 game.sourceName = "Legendary";
435 game.sourceIcon = "\u25B6"; // Game controller
436 game.runner = sg.runner == GameRunner::Wine ? "Wine" : "Native";
437 game.path = QString::fromStdString(sg.installDir);
438 game.sizeBytes = sg.sizeOnDisk;
439 game.isInstalled = true;
440 game.scannedGame = std::make_shared<ScannedGame>(sg);
441
442 results_.push_back(game);
443 }
444}
445
446void GameImportWorker::scanNative()
447{
449 for (auto& sg : games)
450 {
451 if (cancelled_)
452 break;
453
454 // Skip Steam games that might be detected as native
455 if (sg.installDir.find("/Steam/") != std::string::npos ||
456 sg.installDir.find("/steamapps/") != std::string::npos)
457 {
458 continue;
459 }
460
461 ImportableGame game;
462 game.name = QString::fromStdString(sg.name);
464 game.sourceName = "Native";
465 game.sourceIcon = "\u25A0"; // Penguin emoji
466 game.runner = "Native";
467 game.path =
468 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
469 game.sizeBytes = sg.sizeOnDisk;
470 game.isInstalled = true;
471 game.scannedGame = std::make_shared<ScannedGame>(sg);
472
473 results_.push_back(game);
474 }
475}
476
477void GameImportWorker::scanWinePrefixes()
478{
480 for (auto& sg : games)
481 {
482 if (cancelled_)
483 break;
484
485 ImportableGame game;
486 game.name = QString::fromStdString(sg.name);
488 game.sourceName = "Wine Prefix";
489 game.sourceIcon = "\u2617"; // Wine glass
490 game.runner = "Wine";
491 game.path =
492 QString::fromStdString(sg.executablePath.empty() ? sg.installDir : sg.executablePath);
493 game.sizeBytes = sg.sizeOnDisk;
494 game.isInstalled = true;
495 game.scannedGame = std::make_shared<ScannedGame>(sg);
496
497 results_.push_back(game);
498 }
499}
500
501void GameImportWorker::deduplicateResults()
502{
503 // Build a set of Steam app IDs and Steam install paths for cross-source dedup
504 std::set<uint32_t> steamAppIds;
505 std::set<QString> steamInstallPaths;
506
507 for (const auto& game : results_)
508 {
510 {
511 steamAppIds.insert(game.steamGame->appId);
512 if (!game.steamGame->gamePath.empty())
513 {
514 steamInstallPaths.insert(QString::fromStdString(game.steamGame->gamePath.string()));
515 }
516 }
517 }
518
519 // Remove non-Steam entries that match a Steam game
520 auto it = std::remove_if(
521 results_.begin(), results_.end(),
522 [&](const ImportableGame& game)
523 {
524 if (game.sourceType == ImportableGame::SourceType::Steam)
525 return false; // Keep all Steam entries
526
527 // Check if this game's path is inside a Steam install path
528 if (!game.path.isEmpty())
529 {
530 for (const auto& steamPath : steamInstallPaths)
531 {
532 if (game.path.startsWith(steamPath))
533 return true;
534 }
535 }
536
537 // Check if scanned game's exec or install dir is in a Steam location
538 if (game.scannedGame)
539 {
540 QString execPath = QString::fromStdString(game.scannedGame->executablePath);
541 QString installDir = QString::fromStdString(game.scannedGame->installDir);
542
543 for (const auto& steamPath : steamInstallPaths)
544 {
545 if ((!execPath.isEmpty() && execPath.startsWith(steamPath)) ||
546 (!installDir.isEmpty() && installDir.startsWith(steamPath)))
547 {
548 return true;
549 }
550 }
551 }
552
553 return false;
554 });
555
556 auto removed = std::distance(it, results_.end());
557 results_.erase(it, results_.end());
558
559 if (removed > 0)
560 {
561 // Log the dedup count (can't use Logger from Qt thread easily, so just silently remove)
562 }
563}
564
565// ==============================================================================
566// GameImportDialog Implementation
567// ==============================================================================
568
570 ThemeManager* themeManager)
571 : QDialog(parent), libraryController_(libraryController),
572 themeManager_(themeManager ? themeManager : &ThemeManager::instance())
573{
574 setupUI();
575 setWindowTitle("Import Games");
576 resize(900, 700);
577 setModal(true);
578
579 // Initialize source stats
580 // Check Steam availability
581 SteamLibraryScanner steamScanner;
582 bool steamAvailable = steamScanner.isSteamInstalled();
583
584 auto& steamStats = sourceStats_[ImportableGame::SourceType::Steam];
585 steamStats.name = "Steam";
586 steamStats.icon = "\u25B6";
587 steamStats.available = steamAvailable;
588 steamStats.enabled = true;
589
590 auto& lutrisStats = sourceStats_[ImportableGame::SourceType::Lutris];
591 lutrisStats.name = "Lutris";
592 lutrisStats.icon = "\u2617";
593 lutrisStats.available = GameScannerService::isLutrisInstalled();
594 lutrisStats.enabled = true;
595
596 auto& bottlesStats = sourceStats_[ImportableGame::SourceType::Bottles];
597 bottlesStats.name = "Bottles";
598 bottlesStats.icon = "\u25A3";
599 bottlesStats.available = GameScannerService::isBottlesInstalled();
600 bottlesStats.enabled = true;
601
602 auto& heroicEpicStats = sourceStats_[ImportableGame::SourceType::HeroicEpic];
603 heroicEpicStats.name = "Epic (Heroic)";
604 heroicEpicStats.icon = "\u25B6";
605 heroicEpicStats.available = GameScannerService::isHeroicInstalled();
606 heroicEpicStats.enabled = true;
607
608 auto& heroicGOGStats = sourceStats_[ImportableGame::SourceType::HeroicGOG];
609 heroicGOGStats.name = "GOG (Heroic)";
610 heroicGOGStats.icon = "\u25CB";
611 heroicGOGStats.available = GameScannerService::isHeroicInstalled();
612 heroicGOGStats.enabled = true;
613
614 auto& legendaryStats = sourceStats_[ImportableGame::SourceType::Legendary];
615 legendaryStats.name = "Legendary";
616 legendaryStats.icon = "\u25B6";
617 legendaryStats.available = GameScannerService::isLegendaryInstalled();
618 legendaryStats.enabled = true;
619
620 auto& nativeStats = sourceStats_[ImportableGame::SourceType::Native];
621 nativeStats.name = "Native";
622 nativeStats.icon = "\u25A0";
623 nativeStats.available = true;
624 nativeStats.enabled = true;
625
626 auto& winePrefixStats = sourceStats_[ImportableGame::SourceType::WinePrefix];
627 winePrefixStats.name = "Wine Prefix";
628 winePrefixStats.icon = "\u2617";
629 winePrefixStats.available = true;
630 winePrefixStats.enabled = false;
631
632 updateSourceStats();
633 applyTheme();
634
635 connect(themeManager_, &ThemeManager::themeChanged, this, &GameImportDialog::applyTheme);
636}
637
639{
640 if (workerThread_)
641 {
642 if (scanning_)
643 {
644 worker_->cancel();
645 }
646 workerThread_->quit();
647 workerThread_->wait();
648 }
649}
650
651void GameImportDialog::setupUI()
652{
653 QVBoxLayout* mainLayout = new QVBoxLayout(this);
654
655 // Description
656 QLabel* descLabel =
657 new QLabel("Import games from various sources into your library. Select which sources "
658 "to scan, then choose which games to import.",
659 this);
660 descLabel->setWordWrap(true);
661 mainLayout->addWidget(descLabel);
662
663 // Main content area with source panel and results
664 QHBoxLayout* contentLayout = new QHBoxLayout();
665
666 // Left panel: Source selection
667 setupSourcePanel();
668 contentLayout->addWidget(sourceGroup_);
669
670 // Right panel: Results
671 QWidget* resultsWidget = new QWidget(this);
672 QVBoxLayout* resultsLayout = new QVBoxLayout(resultsWidget);
673 resultsLayout->setContentsMargins(0, 0, 0, 0);
674 setupResultsPanel();
675
676 // Progress area
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);
686
687 // Filter options
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_);
693
694 showInstalledOnlyCheck_ = new QCheckBox("Show installed only", this);
695 showInstalledOnlyCheck_->setChecked(false);
696 connect(showInstalledOnlyCheck_, &QCheckBox::toggled, this, &GameImportDialog::onFilterChanged);
697 filterLayout->addWidget(showInstalledOnlyCheck_);
698
699 filterLayout->addStretch();
700 resultsLayout->addLayout(filterLayout);
701
702 // Game tree
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_);
717
718 // Stats label
719 statsLabel_ = new QLabel(this);
720 resultsLayout->addWidget(statsLabel_);
721
722 // Selection buttons
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_);
728
729 selectNoneBtn_ = new QPushButton("Select None", this);
730 selectNoneBtn_->setEnabled(false);
731 connect(selectNoneBtn_, &QPushButton::clicked, this, &GameImportDialog::onSelectNone);
732 selectionLayout->addWidget(selectNoneBtn_);
733
734 selectInstalledBtn_ = new QPushButton("Select Installed", this);
735 selectInstalledBtn_->setEnabled(false);
736 connect(selectInstalledBtn_, &QPushButton::clicked, this, &GameImportDialog::onSelectInstalled);
737 selectionLayout->addWidget(selectInstalledBtn_);
738
739 selectionLayout->addStretch();
740 resultsLayout->addLayout(selectionLayout);
741
742 contentLayout->addWidget(resultsWidget, 1);
743 mainLayout->addLayout(contentLayout, 1);
744
745 // Bottom buttons
746 QHBoxLayout* buttonLayout = new QHBoxLayout();
747
748 scanBtn_ = new QPushButton("Scan", this);
749 scanBtn_->setDefault(true);
750 connect(scanBtn_, &QPushButton::clicked, this, &GameImportDialog::onScanClicked);
751 buttonLayout->addWidget(scanBtn_);
752
753 buttonLayout->addStretch();
754
755 importBtn_ = new QPushButton("Import Selected", this);
756 importBtn_->setEnabled(false);
757 connect(importBtn_, &QPushButton::clicked, this, &GameImportDialog::onImportClicked);
758 buttonLayout->addWidget(importBtn_);
759
760 closeBtn_ = new QPushButton("Close", this);
761 connect(closeBtn_, &QPushButton::clicked, this, &QDialog::reject);
762 buttonLayout->addWidget(closeBtn_);
763
764 mainLayout->addLayout(buttonLayout);
765}
766
767void GameImportDialog::setupSourcePanel()
768{
769 const auto& c = themeManager_->colors();
770 sourceGroup_ = new QGroupBox("Sources", this);
771 sourceGroup_->setMaximumWidth(250);
772 applyGroupStyle(sourceGroup_, c, true);
773 QGridLayout* layout = new QGridLayout(sourceGroup_);
774
775 int row = 0;
776
777 // Steam
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);
786 row++;
787
788 // Lutris
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);
797 row++;
798
799 // Bottles
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);
808 row++;
809
810 // Heroic Epic
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);
819 row++;
820
821 // Heroic GOG
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);
830 row++;
831
832 // Legendary
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);
841 row++;
842
843 // Native games
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);
852 row++;
853
854 // Wine prefixes (off by default)
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);
863 row++;
864
865 layout->setRowStretch(row, 1);
866}
867
868void GameImportDialog::setupResultsPanel()
869{
870 // Results panel is set up in setupUI
871}
872
873void GameImportDialog::updateSourceStats()
874{
875 const auto& c = themeManager_->colors();
876 auto updateLabel = [&c](QLabel* label, QCheckBox* check, const ImportSourceStats& stats)
877 {
878 if (!stats.available)
879 {
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);
884 }
885 else if (stats.gamesFound > 0)
886 {
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()));
893 }
894 else
895 {
896 label->setText("✓ ready");
897 label->setStyleSheet(
898 QString("color: %1; font-size: 11px;").arg(c.textSecondary.name()));
899 }
900 };
901
902 updateLabel(steamStats_, steamCheck_, sourceStats_[ImportableGame::SourceType::Steam]);
903 updateLabel(lutrisStats_, lutrisCheck_, sourceStats_[ImportableGame::SourceType::Lutris]);
904 updateLabel(bottlesStats_, bottlesCheck_, sourceStats_[ImportableGame::SourceType::Bottles]);
905 updateLabel(heroicEpicStats_, heroicEpicCheck_,
907 updateLabel(heroicGOGStats_, heroicGOGCheck_,
909 updateLabel(legendaryStats_, legendaryCheck_,
911 updateLabel(nativeStats_, nativeCheck_, sourceStats_[ImportableGame::SourceType::Native]);
912 updateLabel(winePrefixStats_, winePrefixCheck_,
914}
915
916void GameImportDialog::onSourceToggled()
917{
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();
926}
927
928void GameImportDialog::onScanClicked()
929{
930 if (scanning_)
931 return;
932
933 scanning_ = true;
934 scanBtn_->setEnabled(false);
935 selectAllBtn_->setEnabled(false);
936 selectNoneBtn_->setEnabled(false);
937 selectInstalledBtn_->setEnabled(false);
938 importBtn_->setEnabled(false);
939 gameTree_->clear();
940 importableGames_.clear();
941
942 progressBar_->setVisible(true);
943 progressBar_->setValue(0);
944 statusLabel_->setText("Starting scan...");
945
946 // Reset source stats
947 for (auto& [type, stats] : sourceStats_)
948 {
949 stats.gamesFound = 0;
950 stats.gamesNew = 0;
951 }
952
953 // Update config from checkboxes
954 onSourceToggled();
955
956 // Create worker thread
957 workerThread_ = new QThread(this);
958 worker_ = new GameImportWorker();
959 worker_->setSourceConfig(sourceConfig_);
960 worker_->moveToThread(workerThread_);
961
962 connect(workerThread_, &QThread::started, worker_, &GameImportWorker::doScan);
963 connect(worker_, &GameImportWorker::progressUpdate, this, &GameImportDialog::onProgressUpdate);
964 connect(worker_, &GameImportWorker::sourceComplete, this, &GameImportDialog::onSourceComplete);
965 connect(worker_, &GameImportWorker::scanComplete, this, &GameImportDialog::onScanComplete);
966 connect(worker_, &GameImportWorker::scanError, this, &GameImportDialog::onScanError);
967 connect(worker_, &GameImportWorker::scanComplete, workerThread_, &QThread::quit);
968 connect(workerThread_, &QThread::finished, worker_, &QObject::deleteLater);
969
970 workerThread_->start();
971}
972
973void GameImportDialog::onProgressUpdate(const QString& source, const QString& operation,
974 int percent)
975{
976 statusLabel_->setText(QString("%1: %2").arg(source, operation));
977 progressBar_->setValue(percent);
978}
979
980void GameImportDialog::onSourceComplete(const QString& source, int gamesFound)
981{
982 // Update stats for the completed source
983 // Note: This is a simplified mapping - could be improved
984 if (source == "Steam")
985 sourceStats_[ImportableGame::SourceType::Steam].gamesFound = gamesFound;
986 else if (source == "Lutris")
987 sourceStats_[ImportableGame::SourceType::Lutris].gamesFound = gamesFound;
988 else if (source == "Bottles")
989 sourceStats_[ImportableGame::SourceType::Bottles].gamesFound = gamesFound;
990 else if (source == "Native")
991 sourceStats_[ImportableGame::SourceType::Native].gamesFound = gamesFound;
992 else if (source == "Wine")
993 sourceStats_[ImportableGame::SourceType::WinePrefix].gamesFound = gamesFound;
994
995 updateSourceStats();
996}
997
998void GameImportDialog::onScanComplete(const std::vector<ImportableGame>& games)
999{
1000 scanning_ = false;
1001 importableGames_ = games;
1002
1003 // Mark already imported games
1004 markAlreadyImported();
1005
1006 progressBar_->setVisible(false);
1007 statusLabel_->setText(QString("Found %1 game(s)").arg(games.size()));
1008
1009 // Enable controls
1010 scanBtn_->setEnabled(true);
1011 selectAllBtn_->setEnabled(true);
1012 selectNoneBtn_->setEnabled(true);
1013 selectInstalledBtn_->setEnabled(true);
1014
1015 // Update source stats with proper counts per type
1016 for (auto& [type, stats] : sourceStats_)
1017 {
1018 stats.gamesFound = 0;
1019 stats.gamesNew = 0;
1020 }
1021 for (const auto& game : importableGames_)
1022 {
1023 sourceStats_[game.sourceType].gamesFound++;
1024 if (!game.alreadyImported)
1025 {
1026 sourceStats_[game.sourceType].gamesNew++;
1027 }
1028 }
1029 updateSourceStats();
1030
1031 populateGameList();
1032}
1033
1034void GameImportDialog::onScanError(const QString& error)
1035{
1036 scanning_ = false;
1037 progressBar_->setVisible(false);
1038 statusLabel_->setText(error);
1039 scanBtn_->setEnabled(true);
1040
1041 QMessageBox::warning(this, "Scan Error", error);
1042}
1043
1044void GameImportDialog::markAlreadyImported()
1045{
1046 if (!libraryController_)
1047 return;
1048
1049 auto libraryPtrs = libraryController_->getAllGames();
1050
1051 // Build a set of known paths and app IDs
1052 std::set<std::string> knownPaths;
1053 std::set<int> knownSteamAppIds;
1054
1055 for (const auto* gamePtr : libraryPtrs)
1056 {
1057 if (!gamePtr)
1058 continue;
1059
1060 if (!gamePtr->runnerConfig.executablePath.empty())
1061 {
1062 knownPaths.insert(gamePtr->runnerConfig.executablePath);
1063 }
1064 if (!gamePtr->installPath.empty())
1065 {
1066 knownPaths.insert(gamePtr->installPath);
1067 }
1068 if (gamePtr->metadata.steamAppId > 0)
1069 {
1070 knownSteamAppIds.insert(gamePtr->metadata.steamAppId);
1071 }
1072 }
1073
1074 // Mark importable games
1075 for (auto& game : importableGames_)
1076 {
1077 if (game.steamGame && knownSteamAppIds.count(static_cast<int>(game.steamGame->appId)))
1078 {
1079 game.alreadyImported = true;
1080 }
1081 else if (game.scannedGame)
1082 {
1083 if (knownPaths.count(game.scannedGame->executablePath) ||
1084 knownPaths.count(game.scannedGame->installDir))
1085 {
1086 game.alreadyImported = true;
1087 }
1088 }
1089 }
1090}
1091
1092void GameImportDialog::populateGameList()
1093{
1094 gameTree_->blockSignals(true);
1095 gameTree_->clear();
1096
1097 bool hideImported = hideImportedCheck_->isChecked();
1098 bool installedOnly = showInstalledOnlyCheck_->isChecked();
1099
1100 for (size_t i = 0; i < importableGames_.size(); ++i)
1101 {
1102 const auto& game = importableGames_[i];
1103
1104 // Apply filters
1105 if (hideImported && game.alreadyImported)
1106 continue;
1107 if (installedOnly && !game.isInstalled)
1108 continue;
1109
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)); // Store index
1114
1115 item->setText(1, game.name);
1116 item->setText(2, game.sourceIcon + " " + game.sourceName);
1117 item->setText(3, game.runner);
1118 item->setText(4, game.sizeBytes > 0 ? formatSize(game.sizeBytes) : "");
1119 item->setText(5, game.path);
1120
1121 // Gray out already imported
1122 if (game.alreadyImported)
1123 {
1124 for (int col = 0; col < 6; ++col)
1125 {
1126 item->setForeground(col, Qt::gray);
1127 }
1128 item->setToolTip(1, "Already in library");
1129 }
1130
1131 // Indicate not installed (for Steam)
1132 if (!game.isInstalled)
1133 {
1134 item->setForeground(1, themeManager_->colors().textMuted);
1135 item->setText(3, "(not installed)");
1136 }
1137
1138 gameTree_->addTopLevelItem(item);
1139 }
1140
1141 gameTree_->blockSignals(false);
1142 updateStats();
1143}
1144
1145void GameImportDialog::updateStats()
1146{
1147 int total = gameTree_->topLevelItemCount();
1148 int selected = 0;
1149
1150 for (int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1151 {
1152 if (gameTree_->topLevelItem(i)->checkState(0) == Qt::Checked)
1153 {
1154 selected++;
1155 }
1156 }
1157
1158 statsLabel_->setText(QString("Showing %1 game(s), %2 selected").arg(total).arg(selected));
1159 importBtn_->setEnabled(selected > 0);
1160}
1161
1162void GameImportDialog::onFilterChanged()
1163{
1164 populateGameList();
1165}
1166
1167void GameImportDialog::onItemChanged(QTreeWidgetItem* /*item*/, int column)
1168{
1169 if (column == 0)
1170 {
1171 updateStats();
1172 }
1173}
1174
1175void GameImportDialog::onSelectAll()
1176{
1177 gameTree_->blockSignals(true);
1178 for (int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1179 {
1180 gameTree_->topLevelItem(i)->setCheckState(0, Qt::Checked);
1181 }
1182 gameTree_->blockSignals(false);
1183 updateStats();
1184}
1185
1186void GameImportDialog::onSelectNone()
1187{
1188 gameTree_->blockSignals(true);
1189 for (int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1190 {
1191 gameTree_->topLevelItem(i)->setCheckState(0, Qt::Unchecked);
1192 }
1193 gameTree_->blockSignals(false);
1194 updateStats();
1195}
1196
1197void GameImportDialog::onSelectInstalled()
1198{
1199 gameTree_->blockSignals(true);
1200 for (int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1201 {
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()))
1205 {
1206 bool installed = importableGames_[static_cast<size_t>(idx)].isInstalled;
1207 item->setCheckState(0, installed ? Qt::Checked : Qt::Unchecked);
1208 }
1209 }
1210 gameTree_->blockSignals(false);
1211 updateStats();
1212}
1213
1214void GameImportDialog::onImportClicked()
1215{
1216 if (!libraryController_)
1217 return;
1218
1219 int imported = 0;
1220 int failed = 0;
1221 QStringList errors;
1222
1223 for (int i = 0; i < gameTree_->topLevelItemCount(); ++i)
1224 {
1225 QTreeWidgetItem* item = gameTree_->topLevelItem(i);
1226 if (item->checkState(0) != Qt::Checked)
1227 continue;
1228
1229 int idx = item->data(0, Qt::UserRole).toInt();
1230 if (idx < 0 || idx >= static_cast<int>(importableGames_.size()))
1231 continue;
1232
1233 const auto& importGame = importableGames_[static_cast<size_t>(idx)];
1234
1235 try
1236 {
1237 Game game = importGame.toGame();
1238 std::string id = libraryController_->addGame(game);
1239 if (id.empty())
1240 {
1241 failed++;
1242 errors.append(QString("Failed to add: %1").arg(importGame.name));
1243 continue;
1244 }
1245 imported++;
1246
1247 // Gray out the item
1248 item->setCheckState(0, Qt::Unchecked);
1249 for (int col = 0; col < 6; ++col)
1250 {
1251 item->setForeground(col, Qt::gray);
1252 }
1253 }
1254 catch (const std::exception& e)
1255 {
1256 failed++;
1257 errors.append(QString("%1: %2").arg(importGame.name, e.what()));
1258 }
1259 }
1260
1261 // Show result
1262 QString message = QString("Imported %1 game(s)").arg(imported);
1263 if (failed > 0)
1264 {
1265 message += QString("\nFailed to import %1 game(s)").arg(failed);
1266 }
1267
1268 if (failed > 0 && !errors.isEmpty())
1269 {
1270 QMessageBox::warning(this, "Import Complete",
1271 message + "\n\nErrors:\n" + errors.join("\n"));
1272 }
1273 else
1274 {
1275 QMessageBox::information(this, "Import Complete", message);
1276 }
1277
1278 if (imported > 0)
1279 {
1280 // Mark as imported and refresh
1281 markAlreadyImported();
1282 populateGameList();
1283 accept();
1284 }
1285}
1286
1287QString GameImportDialog::getSourceDisplayName(ImportableGame::SourceType type) const
1288{
1289 switch (type)
1290 {
1292 return "Steam";
1294 return "Lutris";
1296 return "Bottles";
1298 return "Epic (Heroic)";
1300 return "GOG (Heroic)";
1302 return "Legendary";
1304 return "Native";
1306 return "Wine Prefix";
1307 default:
1308 return "Unknown";
1309 }
1310}
1311
1312QString GameImportDialog::getSourceIcon(ImportableGame::SourceType type) const
1313{
1314 switch (type)
1315 {
1317 return "\u25B6";
1319 return "\u2617";
1321 return "\u25A3";
1323 return "\u25B6";
1325 return "\u25CB";
1327 return "\u25B6";
1329 return "\u25A0";
1331 return "\u2617";
1332 default:
1333 return "";
1334 }
1335}
1336
1337QString GameImportDialog::getRunnerDisplayName(const QString& runner) const
1338{
1339 if (runner == "Native")
1340 return "Native";
1341 if (runner == "Wine")
1342 return "Wine";
1343 if (runner == "Proton")
1344 return "Proton";
1345 return runner;
1346}
1347
1348QString GameImportDialog::formatSize(uint64_t bytes) const
1349{
1350 if (bytes == 0)
1351 return "";
1352
1353 const char* units[] = {"B", "KB", "MB", "GB", "TB"};
1354 int unitIndex = 0;
1355 double size = static_cast<double>(bytes);
1356
1357 while (size >= 1024.0 && unitIndex < 4)
1358 {
1359 size /= 1024.0;
1360 unitIndex++;
1361 }
1362
1363 if (unitIndex == 0)
1364 {
1365 return QString("%1 B").arg(static_cast<int>(size));
1366 }
1367 return QString("%1 %2").arg(size, 0, 'f', 1).arg(units[unitIndex]);
1368}
1369
1370// ==============================================================================
1371// Theme Support
1372// ==============================================================================
1373
1374void GameImportDialog::applyTheme()
1375{
1376 const auto& c = themeManager_->colors();
1377
1378 // Style source group box
1379 if (sourceGroup_)
1380 {
1381 applyGroupStyle(sourceGroup_, c, true); // Highlighted - primary section
1382 }
1383
1384 // Style progress bar
1385 if (progressBar_)
1386 {
1387 progressBar_->setStyleSheet(
1388 QString("QProgressBar {"
1389 " border: 1px solid %1;"
1390 " border-radius: 4px;"
1391 " background: %2;"
1392 " text-align: center;"
1393 "}"
1394 "QProgressBar::chunk {"
1395 " background: %3;"
1396 " border-radius: 3px;"
1397 "}")
1398 .arg(c.border.name(), c.inputBackground.name(), c.accent.name()));
1399 }
1400
1401 // Style tree widget — uses global styling, just override specifics
1402 if (gameTree_)
1403 {
1404 QColor accentFaded = c.accent;
1405 accentFaded.setAlpha(40);
1406
1407 gameTree_->setStyleSheet(QString("QTreeWidget {"
1408 " background: %1;"
1409 " alternate-background-color: %2;"
1410 "}"
1411 "QTreeWidget::item {"
1412 " padding: 5px 8px;"
1413 "}"
1414 "QTreeWidget::item:selected {"
1415 " background: %3;"
1416 " color: %4;"
1417 "}"
1418 "QTreeWidget::item:hover {"
1419 " background: %5;"
1420 "}")
1421 .arg(c.cardBackground.name(), c.panelBackground.name(),
1422 accentFaded.name(QColor::HexArgb), c.textPrimary.name(),
1423 c.hoverBackground.name()));
1424
1425 gameTree_->setAlternatingRowColors(true);
1426 }
1427
1428 // Style scan button (primary action)
1429 if (scanBtn_)
1430 {
1431 scanBtn_->setStyleSheet(QString("QPushButton {"
1432 " background-color: %1;"
1433 " color: %2;"
1434 " border: none;"
1435 " border-radius: 6px;"
1436 " padding: 8px 24px;"
1437 " font-weight: bold;"
1438 "}"
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()));
1445 }
1446
1447 // Style import button (success action)
1448 if (importBtn_)
1449 {
1450 importBtn_->setStyleSheet(
1451 QString("QPushButton {"
1452 " background-color: %1;"
1453 " color: %2;"
1454 " border: none;"
1455 " border-radius: 6px;"
1456 " padding: 8px 24px;"
1457 " font-weight: bold;"
1458 "}"
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(),
1463 ThemeManager::lightenColor(c.success, 15).name(),
1464 ThemeManager::darkenColor(c.success, 15).name(), c.inputBackground.name(),
1465 c.textMuted.name()));
1466 }
1467
1468 // Style secondary buttons
1469 auto styleSecondaryButton = [&c](QPushButton* btn)
1470 {
1471 if (!btn)
1472 return;
1473 btn->setStyleSheet(
1474 QString("QPushButton {"
1475 " background-color: %1;"
1476 " color: %2;"
1477 " border: 1px solid %3;"
1478 " border-radius: 6px;"
1479 " padding: 7px 14px;"
1480 "}"
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()));
1486 };
1487
1488 styleSecondaryButton(selectAllBtn_);
1489 styleSecondaryButton(selectNoneBtn_);
1490 styleSecondaryButton(selectInstalledBtn_);
1491 styleSecondaryButton(closeBtn_);
1492
1493 // Style source stat labels with proper colors
1494 auto styleStatLabel = [&c](QLabel* label)
1495 {
1496 if (!label)
1497 return;
1498 label->setStyleSheet(QString("color: %1; font-size: 11px;").arg(c.textMuted.name()));
1499 };
1500
1501 styleStatLabel(steamStats_);
1502 styleStatLabel(lutrisStats_);
1503 styleStatLabel(bottlesStats_);
1504 styleStatLabel(heroicEpicStats_);
1505 styleStatLabel(heroicGOGStats_);
1506 styleStatLabel(legendaryStats_);
1507 styleStatLabel(nativeStats_);
1508 styleStatLabel(winePrefixStats_);
1509
1510 // Style status label via QPalette so it composes with the dialog's stylesheet.
1511 if (statusLabel_)
1512 {
1513 QPalette p = statusLabel_->palette();
1514 p.setColor(QPalette::WindowText, c.textSecondary);
1515 statusLabel_->setPalette(p);
1516 }
1517
1518 // Style stats label
1519 if (statsLabel_)
1520 {
1521 statsLabel_->setStyleSheet(
1522 QString("color: %1; font-size: 11px;").arg(c.textSecondary.name()));
1523 }
1524}
static void applyGroupStyle(QGroupBox *group, const ThemeColors &c, bool highlight=false)
GameImportDialog(core::GameLibraryController *libraryController, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
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.
Definition game.h:767
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).
Definition game.h:42
@ Epic
Epic Games Store.
Definition game.h:43
@ Wine
Wine compatibility layer.
Definition game.h:83
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
Game toGame() const
std::shared_ptr< SteamGame > steamGame
std::shared_ptr< ScannedGame > scannedGame
SourceType sourceType
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.
QColor borderLight
QColor textSecondary
QColor textPrimary
@ Game
Game-specific fixes.