game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
gameconfigdialog.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/gameconfigdialog.cpp
4// ==============================================================================
5// Advanced game configuration dialog implementation
6// ==============================================================================
7
12#include "env_var_mapping.h"
18#include "theme_manager.h"
19#include "util/logger.h"
21
22#include <QDesktopServices>
23#include <QDialogButtonBox>
24#include <QDir>
25#include <QFile>
26#include <QFileDialog>
27#include <QFont>
28#include <QFormLayout>
29#include <QHBoxLayout>
30#include <QHeaderView>
31#include <QIcon>
32#include <QInputDialog>
33#include <QMessageBox>
34#include <QProcess>
35#include <QScrollArea>
36#include <QSplitter>
37#include <QStringList>
38#include <QTabWidget>
39#include <QTextStream>
40#include <QTimer>
41#include <QUrl>
42#include <QVBoxLayout>
43
44#include <algorithm>
45
46// ==============================================================================
47// Helper: Create styled group box with accent-colored header
48// ==============================================================================
49
50static void applyAccentGroupStyle(QGroupBox* group, const ThemeColors& c, bool highlight = false)
51{
52 if (highlight)
53 {
54 group->setStyleSheet(QString("QGroupBox {"
55 " font-weight: bold;"
56 " border: 1px solid %1;"
57 " border-left: 3px solid %1;"
58 " border-radius: 6px;"
59 " margin-top: 16px;"
60 " padding: 12px 8px 8px 8px;"
61 " color: %2;"
62 "}"
63 "QGroupBox::title {"
64 " subcontrol-origin: margin;"
65 " left: 12px;"
66 " padding: 0 6px;"
67 " color: %1;"
68 " font-weight: bold;"
69 "}"
70 "QCheckBox { color: %2; spacing: 8px; }"
71 "QRadioButton { color: %2; spacing: 8px; }"
72 "QLabel { color: %2; }")
73 .arg(c.accent.name(), c.textPrimary.name()));
74 }
75 else
76 {
77 group->setStyleSheet("");
78 }
79}
80
81// ==============================================================================
82// GameConfigDialog Implementation
83// ==============================================================================
84
86{
87 delete profileService_;
88}
89
90GameConfigDialog::GameConfigDialog(Game* game, QWidget* parent, ThemeManager* themeManager)
91 : QDialog(parent), game_(game),
92 themeManager_(themeManager ? themeManager : &ThemeManager::instance())
93{
94 setupUI();
95 loadFromGame();
96 updateLaunchPreview();
97 setWindowTitle(QString("Configure: %1").arg(QString::fromStdString(game->name)));
98
99 // Calculate optimal size based on content
100 adjustSize();
101 QSize hint = sizeHint();
102
103 // Ensure minimum width to fit all tabs without scrolling
104 int minWidth = qMax(hint.width(), 780);
105 // Ensure height accommodates the splitter content (tabs + launch preview)
106 int minHeight = qMax(hint.height(), 720);
107
108 // Set reasonable bounds
109 setMinimumSize(minWidth, minHeight);
110 resize(minWidth, minHeight);
111}
112
113void GameConfigDialog::setupUI()
114{
115 const auto& c = themeManager_->colors();
116 QVBoxLayout* mainLayout = new QVBoxLayout(this);
117 mainLayout->setSpacing(12);
118
119 // Configuration Templates row (at the top)
120 QGroupBox* templateGroup = new QGroupBox("Configuration Template");
121 applyAccentGroupStyle(templateGroup, c, false);
122 QHBoxLayout* templateLayout = new QHBoxLayout(templateGroup);
123
124 templateCombo_ = new QComboBox();
125 templateCombo_->setMinimumWidth(200);
126 templateCombo_->setToolTip(
127 "Switch between saved configuration templates.\n"
128 "Templates allow you to keep multiple configurations per game\n"
129 "(e.g., Performance, Quality, Compatibility) and switch between them.");
130 connect(templateCombo_, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
131 &GameConfigDialog::onTemplateChanged);
132 templateLayout->addWidget(new QLabel("Active:"));
133 templateLayout->addWidget(templateCombo_);
134
135 saveTemplateBtn_ = new QPushButton("Save As...");
136 saveTemplateBtn_->setToolTip("Save current settings as a new template");
137 connect(saveTemplateBtn_, &QPushButton::clicked, this, &GameConfigDialog::onSaveTemplate);
138 templateLayout->addWidget(saveTemplateBtn_);
139
140 deleteTemplateBtn_ = new QPushButton("Delete");
141 deleteTemplateBtn_->setToolTip("Delete the currently selected template");
142 connect(deleteTemplateBtn_, &QPushButton::clicked, this, &GameConfigDialog::onDeleteTemplate);
143 templateLayout->addWidget(deleteTemplateBtn_);
144
145 templateLayout->addStretch();
146 mainLayout->addWidget(templateGroup);
147
148 // Create splitter for tabs and launch preview
149 QSplitter* splitter = new QSplitter(Qt::Vertical, this);
150
151 // Tab widget - 6 focused tabs for better organization
152 tabWidget_ = new QTabWidget(this);
153
154 // Let global stylesheet handle tab styling — flat underline indicator
155 // Just override pane background for consistency
156 tabWidget_->setStyleSheet(QString("QTabWidget::pane {"
157 " border: 1px solid %1;"
158 " border-top: none;"
159 " background: %2;"
160 "}")
161 .arg(c.borderLight.name(), c.panelBackground.name()));
162
163 QWidget* gameTab = new QWidget();
164 QWidget* perfTab = new QWidget();
165 QWidget* envTab = new QWidget();
166
167 setupGameTab(gameTab);
168 setupPerformanceTab(perfTab);
169 setupEnvironmentTab(envTab);
170
171 tabWidget_->addTab(gameTab, "Game");
172 tabWidget_->addTab(perfTab, "Performance & Graphics");
173 tabWidget_->addTab(envTab, "Environment");
174
175 splitter->addWidget(tabWidget_);
176
177 // Launch preview panel
178 setupLaunchPreviewPanel();
179 splitter->addWidget(launchPreviewGroup_);
180
181 // Set initial splitter sizes (70% tabs, 30% preview)
182 splitter->setSizes({500, 200});
183
184 mainLayout->addWidget(splitter);
185
186 // Button box
187 QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
188 buttonBox->addButton(QDialogButtonBox::Ok);
189 buttonBox->addButton(QDialogButtonBox::Cancel);
190 buttonBox->addButton(QDialogButtonBox::Apply);
191
192 // Style primary action buttons with accent color
193 auto styleAccentBtn = [&c](QPushButton* btn)
194 {
195 if (!btn)
196 return;
197 btn->setStyleSheet(QString("QPushButton { background-color: %1; color: %2; border: none; "
198 "border-radius: 6px; padding: 7px 20px; font-weight: bold; }"
199 "QPushButton:hover { background-color: %3; }"
200 "QPushButton:pressed { background-color: %4; }")
201 .arg(c.accent.name(), c.textOnAccent.name(), c.accentHover.name(),
202 c.accentPressed.name()));
203 };
204 styleAccentBtn(buttonBox->button(QDialogButtonBox::Ok));
205 styleAccentBtn(buttonBox->button(QDialogButtonBox::Apply));
206
207 connect(buttonBox, &QDialogButtonBox::accepted, this, &GameConfigDialog::onAccept);
208 connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
209 connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
210 &GameConfigDialog::onApply);
211
212 mainLayout->addWidget(buttonBox);
213}
214
215void GameConfigDialog::setupGameTab(QWidget* tab)
216{
217 const auto& c = themeManager_->colors();
218
219 QScrollArea* scrollArea = new QScrollArea();
220 scrollArea->setWidgetResizable(true);
221 scrollArea->setFrameShape(QFrame::NoFrame);
222
223 QWidget* scrollContent = new QWidget();
224 QVBoxLayout* layout = new QVBoxLayout(scrollContent);
225 layout->setSpacing(12);
226 layout->setContentsMargins(8, 8, 8, 8);
227
228 // --- Game Information ---
229 QGroupBox* infoGroup = new QGroupBox("Game Information");
230 applyAccentGroupStyle(infoGroup, c, false);
231 QFormLayout* infoLayout = new QFormLayout(infoGroup);
232
233 nameEdit_ = new QLineEdit();
234 infoLayout->addRow("Name:", nameEdit_);
235
236 sourceCombo_ = new QComboBox();
237 sourceCombo_->addItem("Local", static_cast<int>(GameSource::Local));
238 sourceCombo_->addItem("Steam", static_cast<int>(GameSource::Steam));
239 sourceCombo_->addItem("GOG", static_cast<int>(GameSource::GOG));
240 sourceCombo_->addItem("Epic", static_cast<int>(GameSource::Epic));
241 sourceCombo_->addItem("Itch.io", static_cast<int>(GameSource::Itch));
242 sourceCombo_->addItem("Lutris", static_cast<int>(GameSource::Lutris));
243 infoLayout->addRow("Source:", sourceCombo_);
244
245 layout->addWidget(infoGroup);
246
247 // --- Execution ---
248 QGroupBox* execGroup = new QGroupBox("Execution");
249 applyAccentGroupStyle(execGroup, c, true);
250 QFormLayout* execLayout = new QFormLayout(execGroup);
251
252 QHBoxLayout* exeLayout = new QHBoxLayout();
253 executableEdit_ = new QLineEdit();
254 QPushButton* browseExeBtn = new QPushButton("Browse...");
255 connect(browseExeBtn, &QPushButton::clicked, this, &GameConfigDialog::onBrowseExecutable);
256 exeLayout->addWidget(executableEdit_);
257 exeLayout->addWidget(browseExeBtn);
258 execLayout->addRow("Executable:", exeLayout);
259
260 QHBoxLayout* wdLayout = new QHBoxLayout();
261 workingDirEdit_ = new QLineEdit();
262 QPushButton* browseWdBtn = new QPushButton("Browse...");
263 connect(browseWdBtn, &QPushButton::clicked, this, &GameConfigDialog::onBrowseWorkingDir);
264 wdLayout->addWidget(workingDirEdit_);
265 wdLayout->addWidget(browseWdBtn);
266 execLayout->addRow("Working Directory:", wdLayout);
267
268 argumentsEdit_ = new QLineEdit();
269 argumentsEdit_->setPlaceholderText("-dx11 -fullscreen");
270 execLayout->addRow("Arguments:", argumentsEdit_);
271
272 layout->addWidget(execGroup);
273
274 // --- Runner Selection ---
275 QGroupBox* runnerGroup = new QGroupBox("Runner");
276 applyAccentGroupStyle(runnerGroup, c, true);
277 QFormLayout* runnerLayout = new QFormLayout(runnerGroup);
278
279 runnerTypeCombo_ = new QComboBox();
280 runnerTypeCombo_->addItem("Native Linux", "native");
281 runnerTypeCombo_->addItem("Wine", "wine");
282 runnerTypeCombo_->addItem("Proton", "proton");
283 connect(runnerTypeCombo_, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
284 &GameConfigDialog::onRunnerTypeChanged);
285 runnerLayout->addRow("Runner Type:", runnerTypeCombo_);
286
287 runnerVersionCombo_ = new QComboBox();
288 runnerVersionCombo_->setEditable(true);
289 runnerVersionCombo_->addItem("(System Default)");
290
291 const auto& runners = SystemInfoService::instance().getCapabilities().runners;
292 for (const auto& runner : runners)
293 {
294 runnerVersionCombo_->addItem(QString::fromStdString(runner.name),
295 QString::fromStdString(runner.path));
296 }
297 if (runners.empty())
298 {
299 runnerVersionCombo_->addItem("proton-cachyos");
300 runnerVersionCombo_->addItem("GE-Proton");
301 runnerVersionCombo_->addItem("Proton Experimental");
302 runnerVersionCombo_->addItem("wine-staging");
303 }
304 runnerVersionCombo_->setCurrentIndex(0);
305 runnerVersionCombo_->setToolTip(
306 QString("Detected %1 runner(s) on your system. You can also type a custom runner name.")
307 .arg(runners.size()));
308 runnerLayout->addRow("Runner Version:", runnerVersionCombo_);
309
310 layout->addWidget(runnerGroup);
311
312 // --- Wine/Proton Settings ---
313 QGroupBox* wineGroup = new QGroupBox("Wine/Proton Settings");
314 applyAccentGroupStyle(wineGroup, c, false);
315 QFormLayout* wineLayout = new QFormLayout(wineGroup);
316
317 QHBoxLayout* prefixLayout = new QHBoxLayout();
318 winePrefixEdit_ = new QLineEdit();
319 winePrefixEdit_->setPlaceholderText("~/.wine or leave empty for default");
320 QPushButton* browsePrefixBtn = new QPushButton("Browse...");
321 connect(browsePrefixBtn, &QPushButton::clicked, this, &GameConfigDialog::onBrowseWinePrefix);
322 prefixLayout->addWidget(winePrefixEdit_);
323 prefixLayout->addWidget(browsePrefixBtn);
324 wineLayout->addRow("Wine Prefix:", prefixLayout);
325
326 winePathEdit_ = new QLineEdit();
327 winePathEdit_->setPlaceholderText("Leave empty for default Wine binary");
328 wineLayout->addRow("Wine Binary Path:", winePathEdit_);
329
330 wineDllEdit_ = new QLineEdit();
331 wineDllEdit_->setPlaceholderText("e.g., d3d11=native,builtin;dxgi=native");
332 wineLayout->addRow("DLL Overrides:", wineDllEdit_);
333
334 // Prefix management buttons
335 QHBoxLayout* prefixActionsLayout = new QHBoxLayout();
336 prefixActionsLayout->setSpacing(8);
337
338 QPushButton* dependenciesBtn = new QPushButton("Install Dependencies...");
339 dependenciesBtn->setToolTip("Install Windows dependencies using winetricks");
340 connect(dependenciesBtn, &QPushButton::clicked, this,
341 [this]()
342 {
343 QString prefix = winePrefixEdit_->text();
344 if (prefix.isEmpty())
345 {
346 QMessageBox::information(this, "Wine Prefix Required",
347 "Please specify a Wine prefix path first.");
348 return;
349 }
350 WineDependencyDialog dialog(this);
351 dialog.setWinePrefix(prefix);
352 if (game_ && game_->metadata.steamAppId > 0)
353 dialog.setSteamAppId(static_cast<uint32_t>(game_->metadata.steamAppId));
354 dialog.exec();
355 });
356 prefixActionsLayout->addWidget(dependenciesBtn);
357
358 QPushButton* snapshotsBtn = new QPushButton("Prefix Snapshots...");
359 snapshotsBtn->setToolTip("Create and restore snapshots of the Wine prefix");
360 connect(snapshotsBtn, &QPushButton::clicked, this,
361 [this]()
362 {
363 QString prefix = winePrefixEdit_->text();
364 if (prefix.isEmpty())
365 {
366 QMessageBox::information(this, "Wine Prefix Required",
367 "Please specify a Wine prefix path first.");
368 return;
369 }
370 PrefixSnapshotDialog dialog(this);
371 QString gameName = game_ ? QString::fromStdString(game_->name) : "Unknown";
372 dialog.setWinePrefix(prefix, gameName);
373 dialog.exec();
374 });
375 prefixActionsLayout->addWidget(snapshotsBtn);
376 prefixActionsLayout->addStretch();
377 wineLayout->addRow("", prefixActionsLayout);
378
379 layout->addWidget(wineGroup);
380
381 // --- Virtual Desktop ---
382 QGroupBox* desktopGroup = new QGroupBox("Virtual Desktop");
383 applyAccentGroupStyle(desktopGroup, c, false);
384 QVBoxLayout* desktopLayout = new QVBoxLayout(desktopGroup);
385
386 virtualDesktopCheck_ = new QCheckBox("Enable Wine virtual desktop");
387 virtualDesktopCheck_->setToolTip("Run the game in a virtual desktop window.");
388 desktopLayout->addWidget(virtualDesktopCheck_);
389
390 QHBoxLayout* resLayout = new QHBoxLayout();
391 resLayout->addWidget(new QLabel("Resolution:"));
392 desktopWidthSpin_ = new QSpinBox();
393 desktopWidthSpin_->setRange(640, 7680);
394 desktopWidthSpin_->setValue(1920);
395 resLayout->addWidget(desktopWidthSpin_);
396 resLayout->addWidget(new QLabel("x"));
397 desktopHeightSpin_ = new QSpinBox();
398 desktopHeightSpin_->setRange(480, 4320);
399 desktopHeightSpin_->setValue(1080);
400 resLayout->addWidget(desktopHeightSpin_);
401 resLayout->addStretch();
402 desktopLayout->addLayout(resLayout);
403
404 connect(virtualDesktopCheck_, &QCheckBox::toggled, desktopWidthSpin_, &QWidget::setEnabled);
405 connect(virtualDesktopCheck_, &QCheckBox::toggled, desktopHeightSpin_, &QWidget::setEnabled);
406
407 layout->addWidget(desktopGroup);
408
409 // --- Steam Integration (visible only for Steam games) ---
410 steamGroup_ = new QGroupBox("Steam Integration");
411 applyAccentGroupStyle(steamGroup_, c, false);
412 QVBoxLayout* steamLayout = new QVBoxLayout(steamGroup_);
413
414 QHBoxLayout* appIdRow = new QHBoxLayout();
415 appIdRow->addWidget(new QLabel("Steam App ID:"));
416 steamAppIdLabel_ = new QLabel("-");
417 steamAppIdLabel_->setStyleSheet("font-weight: bold;");
418 appIdRow->addWidget(steamAppIdLabel_);
419 appIdRow->addStretch();
420 steamLayout->addLayout(appIdRow);
421
422 steamLaunchOptionsEdit_ = new QLineEdit();
423 steamLaunchOptionsEdit_->setPlaceholderText("PROTON_USE_NTSYNC=1 %command%");
424 steamLaunchOptionsEdit_->setToolTip(
425 "Launch options currently set in Steam.\n"
426 "Use 'Fetch' to get the current value, or 'Write' to save changes.");
427 steamLayout->addWidget(new QLabel("Steam Launch Options:"));
428 steamLayout->addWidget(steamLaunchOptionsEdit_);
429
430 steamSyncLaunchOptionsCheck_ = new QCheckBox("Auto-sync environment variables to Steam");
431 steamSyncLaunchOptionsCheck_->setToolTip(
432 "When enabled, saving will also update Steam's launch options.");
433 steamLayout->addWidget(steamSyncLaunchOptionsCheck_);
434
435 QHBoxLayout* steamBtnRow = new QHBoxLayout();
436 steamFetchOptionsBtn_ = new QPushButton("Fetch from Steam");
437 connect(steamFetchOptionsBtn_, &QPushButton::clicked, this,
438 &GameConfigDialog::onFetchSteamOptions);
439 steamBtnRow->addWidget(steamFetchOptionsBtn_);
440
441 steamWriteOptionsBtn_ = new QPushButton("Write to Steam");
442 connect(steamWriteOptionsBtn_, &QPushButton::clicked, this,
443 &GameConfigDialog::onWriteSteamOptions);
444 steamBtnRow->addWidget(steamWriteOptionsBtn_);
445 steamBtnRow->addStretch();
446 steamLayout->addLayout(steamBtnRow);
447
448 layout->addWidget(steamGroup_);
449
450 // --- Exclude Processes (collapsed by default) ---
451 QGroupBox* excludeGroup = new QGroupBox("Exclude Processes");
452 applyAccentGroupStyle(excludeGroup, c, false);
453 excludeGroup->setCheckable(true);
454 excludeGroup->setChecked(false);
455 QVBoxLayout* excludeLayout = new QVBoxLayout(excludeGroup);
456
457 QLabel* excludeLabel =
458 new QLabel("Processes to exclude when tracking game session (one per line).");
459 excludeLabel->setWordWrap(true);
460 excludeLayout->addWidget(excludeLabel);
461
462 excludeProcessesEdit_ = new QTextEdit();
463 excludeProcessesEdit_->setMaximumHeight(80);
464 excludeProcessesEdit_->setPlaceholderText("Agent.exe\nBattle.net Helper.exe");
465 excludeLayout->addWidget(excludeProcessesEdit_);
466
467 layout->addWidget(excludeGroup);
468
469 layout->addStretch();
470 scrollArea->setWidget(scrollContent);
471
472 QVBoxLayout* tabLayout = new QVBoxLayout(tab);
473 tabLayout->setContentsMargins(0, 0, 0, 0);
474 tabLayout->addWidget(scrollArea);
475}
476
477void GameConfigDialog::updateSteamGroup()
478{
479 // Show/hide Steam group based on game source
480 bool isSteamGame =
481 game_ && game_->source == GameSource::Steam && game_->metadata.steamAppId > 0;
482 steamGroup_->setVisible(isSteamGame);
483
484 if (isSteamGame)
485 {
486 steamAppIdLabel_->setText(QString::number(game_->metadata.steamAppId));
487 }
488}
489
490void GameConfigDialog::onFetchSteamOptions()
491{
492 if (!game_ || game_->metadata.steamAppId <= 0)
493 return;
494
495 // Get current Steam launch options
497 static_cast<uint32_t>(game_->metadata.steamAppId));
498
499 steamLaunchOptionsEdit_->setText(QString::fromStdString(options));
500
501 if (options.empty())
502 {
503 QMessageBox::information(
504 this, "Steam Launch Options",
505 "No custom launch options are currently set for this game in Steam.");
506 }
507}
508
509void GameConfigDialog::onWriteSteamOptions()
510{
511 if (!game_ || game_->metadata.steamAppId <= 0)
512 return;
513
514 QString options = steamLaunchOptionsEdit_->text().trimmed();
515
516 // Confirm with user
517 QMessageBox::StandardButton reply =
518 QMessageBox::question(this, "Write Steam Launch Options",
519 QString("This will update Steam's localconfig.vdf with:\n\n\"%1\"\n\n"
520 "Continue?")
521 .arg(options.isEmpty() ? "(clear launch options)" : options),
522 QMessageBox::Yes | QMessageBox::No);
523
524 if (reply != QMessageBox::Yes)
525 return;
526
528 static_cast<uint32_t>(game_->metadata.steamAppId), options.toStdString());
529
530 if (success)
531 {
532 QMessageBox::information(this, "Success",
533 "Steam launch options have been updated.\n"
534 "Changes will sync automatically when you launch the game.");
535 }
536 else
537 {
538 QMessageBox::warning(this, "Error",
539 "Failed to write launch options to Steam.\n"
540 "Make sure Steam is not running or check file permissions.");
541 }
542}
543
544void GameConfigDialog::updateTemplateCombo()
545{
546 // Block signals while updating
547 templateCombo_->blockSignals(true);
548 templateCombo_->clear();
549
550 // Add "Current" option (the live runnerConfig)
551 templateCombo_->addItem("Current (unsaved)", QVariant());
552
553 // Add saved templates
554 for (const auto& [name, config] : game_->configTemplates)
555 {
556 templateCombo_->addItem(QString::fromStdString(name), QString::fromStdString(name));
557 }
558
559 // Select active template
560 if (game_->activeTemplateName.empty())
561 {
562 templateCombo_->setCurrentIndex(0);
563 }
564 else
565 {
566 int idx = templateCombo_->findData(QString::fromStdString(game_->activeTemplateName));
567 if (idx >= 0)
568 templateCombo_->setCurrentIndex(idx);
569 else
570 templateCombo_->setCurrentIndex(0);
571 }
572
573 // Enable/disable delete button (can't delete "Current")
574 deleteTemplateBtn_->setEnabled(templateCombo_->currentIndex() > 0);
575
576 templateCombo_->blockSignals(false);
577}
578
579void GameConfigDialog::onTemplateChanged(int index)
580{
581 if (index < 0)
582 return;
583
584 QVariant itemData = templateCombo_->itemData(index);
585 QString templateName = itemData.toString();
586
587 if (templateName.isEmpty())
588 {
589 // "Current" selected - nothing to load, already using runnerConfig
590 game_->activeTemplateName.clear();
591 deleteTemplateBtn_->setEnabled(false);
592 }
593 else
594 {
595 // Load template into runnerConfig
596 auto it = game_->configTemplates.find(templateName.toStdString());
597 if (it != game_->configTemplates.end())
598 {
599 game_->runnerConfig = it->second;
600 game_->activeTemplateName = templateName.toStdString();
601 loadFromGame(); // Refresh UI with template values
602 updateLaunchPreview();
603 }
604 deleteTemplateBtn_->setEnabled(true);
605 }
606}
607
608void GameConfigDialog::onSaveTemplate()
609{
610 // Get template name from user
611 bool ok;
612 QString name = QInputDialog::getText(
613 this, "Save Template", "Enter a name for this configuration template:", QLineEdit::Normal,
614 "", &ok);
615
616 if (!ok || name.trimmed().isEmpty())
617 return;
618
619 name = name.trimmed();
620
621 // Check if template already exists
622 if (game_->configTemplates.find(name.toStdString()) != game_->configTemplates.end())
623 {
624 QMessageBox::StandardButton reply = QMessageBox::question(
625 this, "Template Exists",
626 QString("A template named '%1' already exists. Overwrite?").arg(name),
627 QMessageBox::Yes | QMessageBox::No);
628
629 if (reply != QMessageBox::Yes)
630 return;
631 }
632
633 // Save current UI state to game first
634 saveToGame();
635
636 // Save runnerConfig to templates
637 game_->configTemplates[name.toStdString()] = game_->runnerConfig;
638 game_->activeTemplateName = name.toStdString();
639
640 // Update combo box
641 updateTemplateCombo();
642
643 QMessageBox::information(this, "Template Saved",
644 QString("Configuration saved as '%1'.").arg(name));
645}
646
647void GameConfigDialog::onDeleteTemplate()
648{
649 QString templateName = templateCombo_->currentData().toString();
650 if (templateName.isEmpty())
651 return;
652
653 QMessageBox::StandardButton reply = QMessageBox::question(
654 this, "Delete Template",
655 QString("Delete the template '%1'? This cannot be undone.").arg(templateName),
656 QMessageBox::Yes | QMessageBox::No);
657
658 if (reply != QMessageBox::Yes)
659 return;
660
661 // Remove template
662 game_->configTemplates.erase(templateName.toStdString());
663
664 // Clear active template name if this was the active one
665 if (game_->activeTemplateName == templateName.toStdString())
666 {
667 game_->activeTemplateName.clear();
668 }
669
670 // Update combo and select "Current"
671 updateTemplateCombo();
672 templateCombo_->setCurrentIndex(0);
673}
674
675void GameConfigDialog::setupPerformanceTab(QWidget* tab)
676{
677 const ThemeColors& c = themeManager_->colors();
678
679 QScrollArea* scrollArea = new QScrollArea();
680 scrollArea->setWidgetResizable(true);
681 scrollArea->setFrameShape(QFrame::NoFrame);
682
683 QWidget* scrollContent = new QWidget();
684 QVBoxLayout* layout = new QVBoxLayout(scrollContent);
685 layout->setSpacing(12);
686 layout->setContentsMargins(8, 8, 8, 8);
687
688 // --- Recommendations & Profiles ---
689 QGroupBox* recProfileGroup = new QGroupBox("Recommendations && Profiles");
690 applyAccentGroupStyle(recProfileGroup, c, true);
691 QVBoxLayout* recProfileLayout = new QVBoxLayout(recProfileGroup);
692 recProfileLayout->setSpacing(10);
693
694 // --- Recommendations Widget (full, not just a banner) ---
695 recommendationsWidget_ = new RecommendationsWidget();
696 recommendationsWidget_->setMinimumHeight(140);
697 connect(recommendationsWidget_, &RecommendationsWidget::applyRequested, this,
698 &GameConfigDialog::onApplyRecommendations);
699 connect(recommendationsWidget_, &RecommendationsWidget::loadingComplete, this,
700 [this](bool success)
701 {
702 updateRecommendationsBanner();
703 // Auto-populate preview when recommendations load successfully
704 if (success && recommendationsWidget_->hasRecommendations())
705 {
706 showRecommendationPreview(recommendationsWidget_->getCurrentSuggestions());
707 }
708 });
709 recProfileLayout->addWidget(recommendationsWidget_);
710
711 // Load recommendations if we have a Steam App ID
712 if (game_ && game_->metadata.steamAppId > 0)
713 {
714 recommendationsWidget_->loadRecommendations(game_->metadata.steamAppId,
715 QString::fromStdString(game_->name));
716 }
717
718 // Separator
719 QFrame* separator = new QFrame();
720 separator->setFrameShape(QFrame::HLine);
721 separator->setStyleSheet(QString("background-color: %1; margin: 4px 0;").arg(c.border.name()));
722 separator->setFixedHeight(1);
723 recProfileLayout->addWidget(separator);
724
725 // --- Saved Profiles Section ---
726 QLabel* profileLabel = new QLabel("<b>Saved Profiles</b>");
727 profileLabel->setStyleSheet(QString("color: %1;").arg(c.textPrimary.name()));
728 recProfileLayout->addWidget(profileLabel);
729
730 profileList_ = new QListWidget();
731 profileList_->setMaximumHeight(100);
732 profileList_->setMinimumHeight(60);
733 profileList_->setStyleSheet(QString("QListWidget {"
734 " background-color: %1;"
735 " border: 1px solid %2;"
736 " border-radius: 4px;"
737 "}"
738 "QListWidget::item {"
739 " padding: 5px 8px;"
740 " border-bottom: 1px solid %3;"
741 "}"
742 "QListWidget::item:selected {"
743 " background-color: %4;"
744 " color: %5;"
745 "}"
746 "QListWidget::item:hover:!selected {"
747 " background-color: %6;"
748 "}")
749 .arg(c.inputBackground.name(), c.border.name(),
750 c.borderLight.name(), c.accent.name(),
751 c.textOnAccent.name(), c.hoverBackground.name()));
752 connect(profileList_, &QListWidget::currentItemChanged, this,
753 &GameConfigDialog::onProfileSelected);
754 recProfileLayout->addWidget(profileList_);
755
756 QHBoxLayout* profileBtnRow = new QHBoxLayout();
757 profileBtnRow->setSpacing(6);
758
759 applyProfileBtn_ = new QPushButton("Apply");
760 applyProfileBtn_->setEnabled(false);
761 applyProfileBtn_->setFixedWidth(80);
762 applyProfileBtn_->setStyleSheet(
763 QString("QPushButton {"
764 " background-color: %1;"
765 " color: %2;"
766 " border: none;"
767 " border-radius: 4px;"
768 " padding: 6px 16px;"
769 " font-weight: bold;"
770 "}"
771 "QPushButton:hover { background-color: %3; }"
772 "QPushButton:disabled { background-color: %4; color: %5; }")
773 .arg(c.accent.name(), c.textOnAccent.name(), c.accentHover.name(), c.border.name(),
774 c.textMuted.name()));
775 connect(applyProfileBtn_, &QPushButton::clicked, this, &GameConfigDialog::onApplyProfile);
776 profileBtnRow->addWidget(applyProfileBtn_);
777
778 saveAsProfileBtn_ = new QPushButton("Save Current...");
779 saveAsProfileBtn_->setToolTip("Save current settings as a new performance profile");
780 connect(saveAsProfileBtn_, &QPushButton::clicked, this, &GameConfigDialog::onSaveAsProfile);
781 profileBtnRow->addWidget(saveAsProfileBtn_);
782
783 manageProfilesBtn_ = new QPushButton("Manage...");
784 manageProfilesBtn_->setToolTip("Open Performance Profile manager");
785 connect(manageProfilesBtn_, &QPushButton::clicked, this, &GameConfigDialog::onManageProfiles);
786 profileBtnRow->addWidget(manageProfilesBtn_);
787
788 profileBtnRow->addStretch();
789 recProfileLayout->addLayout(profileBtnRow);
790
791 layout->addWidget(recProfileGroup);
792
793 // --- Quick Preset Selector ---
794 QGroupBox* presetGroup = new QGroupBox("Quick Preset");
795 applyAccentGroupStyle(presetGroup, c, false);
796 QVBoxLayout* presetLayout = new QVBoxLayout(presetGroup);
797
798 QHBoxLayout* presetRow = new QHBoxLayout();
799 presetRow->addWidget(new QLabel("Preset:"));
800 presetCombo_ = new QComboBox();
801 presetCombo_->addItem("Balanced (Recommended)", static_cast<int>(ConfigPreset::Balanced));
802 presetCombo_->addItem("Maximum Performance", static_cast<int>(ConfigPreset::MaxPerformance));
803 presetCombo_->addItem("Maximum Quality", static_cast<int>(ConfigPreset::MaxQuality));
804 presetCombo_->addItem("Compatibility", static_cast<int>(ConfigPreset::Compatibility));
805 presetCombo_->addItem("Custom", static_cast<int>(ConfigPreset::Custom));
806 connect(presetCombo_, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
807 &GameConfigDialog::onPresetChanged);
808 presetRow->addWidget(presetCombo_);
809 presetRow->addStretch();
810 presetLayout->addLayout(presetRow);
811
812 presetDescLabel_ = new QLabel();
813 presetDescLabel_->setWordWrap(true);
814 presetDescLabel_->setStyleSheet(
815 QString("color: %1; font-style: italic;").arg(c.textMuted.name()));
816 presetLayout->addWidget(presetDescLabel_);
817
818 layout->addWidget(presetGroup);
819
820 // --- Synchronization Group ---
821 QGroupBox* syncGroup = new QGroupBox("Synchronization");
822 applyAccentGroupStyle(syncGroup, c, false);
823 QVBoxLayout* syncLayout = new QVBoxLayout(syncGroup);
824
825 auto& sysInfo = SystemInfoService::instance();
826 const auto& kernel = sysInfo.getKernelInfo();
827
828 syncCapabilitiesLabel_ = new QLabel();
829 syncCapabilitiesLabel_->setWordWrap(true);
830
831 QString capText = "<b>System Capabilities:</b> ";
832 QString recommended =
833 QString::fromStdString(sysInfo.getCapabilities().getRecommendedSyncMethod());
834
835 // Use theme colors for capability indicators
836 QString supportedColor = c.success.name();
837 QString warningColor = c.warning.name();
838 QString unavailableColor = c.textMuted.name();
839
840 if (kernel.supportsNTSync)
841 capText += QString("<span style='color: %1;'>NTSync</span>").arg(supportedColor);
842 else if (kernel.ntsyncStatus == "module_not_loaded")
843 capText +=
844 QString("<span style='color: %1;'>NTSync (module not loaded)</span>").arg(warningColor);
845 else
846 capText += QString("<span style='color: %1;'>NTSync (kernel &lt;6.2)</span>")
847 .arg(unavailableColor);
848
849 capText += " | ";
850 capText += kernel.supportsFsync
851 ? QString("<span style='color: %1;'>Fsync</span>").arg(supportedColor)
852 : QString("<span style='color: %1;'>Fsync (kernel &lt;5.16)</span>")
853 .arg(unavailableColor);
854 capText += QString(" | <span style='color: %1;'>Esync</span>").arg(supportedColor);
855 capText += QString("<br><i>Recommended: <b>%1</b></i>").arg(recommended.toUpper());
856
857 syncCapabilitiesLabel_->setText(capText);
858 syncCapabilitiesLabel_->setStyleSheet(
859 QString("padding: 6px; background-color: %1; border-radius: 4px; font-size: 11px;")
860 .arg(c.cardBackground.name()));
861 syncLayout->addWidget(syncCapabilitiesLabel_);
862
863 ntSyncCheck_ =
864 new EnvVarCheckBox("NTSync (faster than Esync/Fsync)", "PROTON_USE_NTSYNC=1",
865 "Use NTSync for thread synchronization.\nRequires kernel 6.14+ with "
866 "NTSync support.\nGE-Proton enables this automatically.");
867 connect(ntSyncCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
868 if (!kernel.supportsNTSync)
869 {
870 ntSyncCheck_->setEnabled(false);
871 ntSyncCheck_->setToolTip(QString("NTSync not available. Status: %1")
872 .arg(QString::fromStdString(kernel.ntsyncStatus)));
873 }
874 syncLayout->addWidget(ntSyncCheck_);
875
876 fsyncCheck_ =
877 new EnvVarCheckBox("Fsync (fallback if NTSync unavailable)", "WINEFSYNC=1",
878 "Use Fsync for thread synchronization.\nRequires kernel 5.16+.");
879 connect(fsyncCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
880 if (!kernel.supportsFsync)
881 {
882 fsyncCheck_->setEnabled(false);
883 fsyncCheck_->setToolTip(QString("Fsync not available. Status: %1")
884 .arg(QString::fromStdString(kernel.fsyncStatus)));
885 }
886 syncLayout->addWidget(fsyncCheck_);
887
888 layout->addWidget(syncGroup);
889
890 // --- Shader Compilation Group ---
891 QGroupBox* shaderGroup = new QGroupBox("Shader Compilation");
892 applyAccentGroupStyle(shaderGroup, c, false);
893 QVBoxLayout* shaderLayout = new QVBoxLayout(shaderGroup);
894
895 localShaderCacheCheck_ =
896 new EnvVarCheckBox("NVIDIA shader disk cache", "__GL_SHADER_DISK_CACHE=1",
897 "Enable NVIDIA's on-disk shader cache for faster loading.");
898 connect(localShaderCacheCheck_, &EnvVarCheckBox::toggled, this,
899 &GameConfigDialog::onAnySettingChanged);
900 shaderLayout->addWidget(localShaderCacheCheck_);
901
902 skipShaderCleanupCheck_ = new EnvVarCheckBox(
903 "Skip shader cache cleanup (NVIDIA)", "__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1",
904 "Prevent NVIDIA driver from cleaning up shader cache.");
905 connect(skipShaderCleanupCheck_, &EnvVarCheckBox::toggled, this,
906 &GameConfigDialog::onAnySettingChanged);
907 shaderLayout->addWidget(skipShaderCleanupCheck_);
908
909 dxvkAsyncCheck_ = new EnvVarCheckBox("DXVK async compilation (reduce stutter)", "DXVK_ASYNC=1",
910 "Compile shaders asynchronously to reduce stuttering.");
911 connect(dxvkAsyncCheck_, &EnvVarCheckBox::toggled, this,
912 &GameConfigDialog::onAnySettingChanged);
913 shaderLayout->addWidget(dxvkAsyncCheck_);
914
915 layout->addWidget(shaderGroup);
916
917 // --- Performance Wrappers ---
918 QGroupBox* wrappersGroup = new QGroupBox("Performance Wrappers");
919 applyAccentGroupStyle(wrappersGroup, c, false);
920 QVBoxLayout* wrappersLayout = new QVBoxLayout(wrappersGroup);
921
922 mangoHudCheck_ = new EnvVarCheckBox("MangoHud (performance overlay)", "MANGOHUD=1",
923 "Display FPS, frame times, CPU/GPU usage overlay.");
924 connect(mangoHudCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
925 wrappersLayout->addWidget(mangoHudCheck_);
926
927 gameModeCheck_ = new EnvVarCheckBox("GameMode (CPU governor optimization)", "gamemoderun",
928 "Use Feral GameMode to optimize CPU governor.");
929 connect(gameModeCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
930 wrappersLayout->addWidget(gameModeCheck_);
931
932 gamePerformanceCheck_ =
933 new EnvVarCheckBox("game-performance wrapper (CachyOS)", "game-performance",
934 "CachyOS-specific performance wrapper.");
935 connect(gamePerformanceCheck_, &EnvVarCheckBox::toggled, this,
936 &GameConfigDialog::onAnySettingChanged);
937 wrappersLayout->addWidget(gamePerformanceCheck_);
938
939 vkBasaltCheck_ = new EnvVarCheckBox("VkBasalt (shader injection)", "ENABLE_VKBASALT=1",
940 "Post-processing shader injection for Vulkan games.");
941 connect(vkBasaltCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
942 wrappersLayout->addWidget(vkBasaltCheck_);
943
944 // Warning label for GameMode + game-performance conflict
945 perfWrapperWarning_ = new QLabel();
946 perfWrapperWarning_->setWordWrap(true);
947 perfWrapperWarning_->setStyleSheet(
948 QString("QLabel { color: %1; background-color: %2; padding: 8px; "
949 "border: 1px solid %1; border-radius: 4px; margin-top: 4px; }")
950 .arg(c.warning.name(), ThemeManager::lightenColor(c.warning, 85).name()));
951 perfWrapperWarning_->setText(
952 "⚠ Both GameMode and game-performance are enabled. These tools perform similar "
953 "CPU governor optimizations and may conflict. On CachyOS, game-performance is "
954 "recommended as it's optimized for the CachyOS scheduler. Choose one for best results.");
955 perfWrapperWarning_->setVisible(false);
956 wrappersLayout->addWidget(perfWrapperWarning_);
957
958 // Connect checkboxes to update the conflict warning
959 connect(gameModeCheck_, &EnvVarCheckBox::toggled, this,
960 &GameConfigDialog::updatePerfWrapperWarning);
961 connect(gamePerformanceCheck_, &EnvVarCheckBox::toggled, this,
962 &GameConfigDialog::updatePerfWrapperWarning);
963
964 layout->addWidget(wrappersGroup);
965
966 // === GRAPHICS SECTION (merged from former Graphics tab) ===
967
968 // --- GPU Detection ---
969 QString gpuVendor = getGpuVendor();
970 bool isNvidia = gpuVendor.contains("NVIDIA", Qt::CaseInsensitive);
971 bool isAmd = gpuVendor.contains("AMD", Qt::CaseInsensitive) ||
972 gpuVendor.contains("Radeon", Qt::CaseInsensitive);
973 bool isIntel = gpuVendor.contains("Intel", Qt::CaseInsensitive);
974
975 gpuInfoLabel_ = new QLabel(QString("Detected GPU: <b>%1</b>").arg(gpuVendor));
976 gpuInfoLabel_->setStyleSheet(
977 QString("padding: 8px; background-color: %1; border-radius: 4px; color: %2;")
978 .arg(c.cardBackground.name())
979 .arg(c.textPrimary.name()));
980 layout->addWidget(gpuInfoLabel_);
981
982 // --- NVIDIA Options ---
983 if (isNvidia)
984 {
985 nvidiaGroup_ = new QGroupBox("NVIDIA Upscaling & Features");
986 applyAccentGroupStyle(nvidiaGroup_, c, true);
987 QVBoxLayout* nvidiaLayout = new QVBoxLayout(nvidiaGroup_);
988
989 dlssUpgradeCheck_ = new EnvVarCheckBox("Auto-upgrade DLSS", "PROTON_DLSS_UPGRADE=1",
990 "Automatically upgrade DLSS to the latest version.");
991 connect(dlssUpgradeCheck_, &EnvVarCheckBox::toggled, this,
992 &GameConfigDialog::onAnySettingChanged);
993 nvidiaLayout->addWidget(dlssUpgradeCheck_);
994
995 dlssIndicatorCheck_ = new EnvVarCheckBox("Show DLSS indicator", "PROTON_DLSS_INDICATOR=1",
996 "Display indicator when DLSS is active.");
997 connect(dlssIndicatorCheck_, &EnvVarCheckBox::toggled, this,
998 &GameConfigDialog::onAnySettingChanged);
999 nvidiaLayout->addWidget(dlssIndicatorCheck_);
1000
1001 nvidiaLibsCheck_ =
1002 new EnvVarCheckBox("NVIDIA proprietary libs (PhysX, CUDA)", "PROTON_NVIDIA_LIBS=1",
1003 "Enable NVIDIA proprietary libraries for PhysX, CUDA, etc.");
1004 connect(nvidiaLibsCheck_, &EnvVarCheckBox::toggled, this,
1005 &GameConfigDialog::onAnySettingChanged);
1006 nvidiaLayout->addWidget(nvidiaLibsCheck_);
1007
1008 nvidia4000FixCheck_ =
1009 new EnvVarCheckBox("RTX 4000+ fix (64-bit libs only)", "PROTON_NVIDIA_LIBS_NO_32BIT=1",
1010 "Fixes performance issues on RTX 4000 series GPUs.");
1011 connect(nvidia4000FixCheck_, &EnvVarCheckBox::toggled, this,
1012 &GameConfigDialog::onAnySettingChanged);
1013 nvidiaLayout->addWidget(nvidia4000FixCheck_);
1014
1015 layout->addWidget(nvidiaGroup_);
1016 }
1017 else
1018 {
1019 nvidiaGroup_ = nullptr;
1020 dlssUpgradeCheck_ = nullptr;
1021 dlssIndicatorCheck_ = nullptr;
1022 nvidiaLibsCheck_ = nullptr;
1023 nvidia4000FixCheck_ = nullptr;
1024 }
1025
1026 // --- AMD Options ---
1027 if (isAmd)
1028 {
1029 amdGroup_ = new QGroupBox("AMD Upscaling & Features");
1030 applyAccentGroupStyle(amdGroup_, c, true);
1031 QVBoxLayout* amdLayout = new QVBoxLayout(amdGroup_);
1032
1033 const auto& gpuInfo = SystemInfoService::instance().getGPUInfo();
1034 if (gpuInfo.generation == GPUGeneration::AMD_RDNA3)
1035 {
1036 QLabel* rdna3Hint = new QLabel();
1037 rdna3Hint->setWordWrap(true);
1038 rdna3Hint->setText(QString("✓ <b>%1</b> detected - RDNA3 optimizations available")
1039 .arg(QString::fromStdString(gpuInfo.model)));
1040 rdna3Hint->setStyleSheet(
1041 QString("QLabel { color: %1; background-color: %2; padding: 6px; "
1042 "border-radius: 4px; font-size: 11px; }")
1043 .arg(c.success.name(), ThemeManager::lightenColor(c.success, 85).name()));
1044 amdLayout->addWidget(rdna3Hint);
1045 }
1046
1047 fsr4UpgradeCheck_ =
1048 new EnvVarCheckBox("Auto-upgrade FSR4 (GE-Proton only)", "PROTON_FSR4_UPGRADE=1",
1049 "Automatically upgrade FSR to version 4.\nRequires GE-Proton — has "
1050 "no effect with Valve Proton.");
1051 connect(fsr4UpgradeCheck_, &EnvVarCheckBox::toggled, this,
1052 &GameConfigDialog::onAnySettingChanged);
1053 amdLayout->addWidget(fsr4UpgradeCheck_);
1054
1055 fsr4Rdna3Check_ = new EnvVarCheckBox(
1056 "FSR4 RDNA3 optimized (GE-Proton only)", "PROTON_FSR4_RDNA3_UPGRADE=1",
1057 "Use RDNA3-optimized FSR4 implementation (RX 7000 series).\nRequires GE-Proton — has "
1058 "no effect with Valve Proton.");
1059 connect(fsr4Rdna3Check_, &EnvVarCheckBox::toggled, this,
1060 &GameConfigDialog::onAnySettingChanged);
1061 amdLayout->addWidget(fsr4Rdna3Check_);
1062
1063 fsrCheck_ = new EnvVarCheckBox("FSR fullscreen upscaling", "WINE_FULLSCREEN_FSR=1",
1064 "Enable FSR for all fullscreen games.");
1065 connect(fsrCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
1066 amdLayout->addWidget(fsrCheck_);
1067
1068 layout->addWidget(amdGroup_);
1069 }
1070 else
1071 {
1072 amdGroup_ = nullptr;
1073 fsr4UpgradeCheck_ = nullptr;
1074 fsr4Rdna3Check_ = nullptr;
1075 fsrCheck_ = nullptr;
1076 }
1077
1078 // --- Intel Options ---
1079 if (isIntel)
1080 {
1081 intelGroup_ = new QGroupBox("Intel Upscaling & Features");
1082 applyAccentGroupStyle(intelGroup_, c, true);
1083 QVBoxLayout* intelLayout = new QVBoxLayout(intelGroup_);
1084
1085 xessUpgradeCheck_ = new EnvVarCheckBox("Auto-upgrade XeSS", "PROTON_XESS_UPGRADE=1",
1086 "Automatically upgrade XeSS to the latest version.");
1087 connect(xessUpgradeCheck_, &EnvVarCheckBox::toggled, this,
1088 &GameConfigDialog::onAnySettingChanged);
1089 intelLayout->addWidget(xessUpgradeCheck_);
1090
1091 layout->addWidget(intelGroup_);
1092 }
1093 else
1094 {
1095 intelGroup_ = nullptr;
1096 xessUpgradeCheck_ = nullptr;
1097 }
1098
1099 // --- Display & Compositor ---
1100 QGroupBox* displayGroup = new QGroupBox("Display && Compositor");
1101 applyAccentGroupStyle(displayGroup, c, false);
1102 QVBoxLayout* displayLayout = new QVBoxLayout(displayGroup);
1103
1104 hdrCheck_ = new EnvVarCheckBox(
1105 "HDR support", "PROTON_ENABLE_HDR=1",
1106 "Enable High Dynamic Range output.\nRequires Gamescope or Wayland + HDR monitor.");
1107 connect(hdrCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
1108 displayLayout->addWidget(hdrCheck_);
1109
1110 dxvkHdrCheck_ = new EnvVarCheckBox("DXVK HDR", "DXVK_HDR=1",
1111 "Enable HDR support in DXVK for DirectX games.");
1112 connect(dxvkHdrCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
1113 displayLayout->addWidget(dxvkHdrCheck_);
1114
1115 gamescopeCheck_ = new EnvVarCheckBox("Gamescope compositor", "gamescope",
1116 "Run game through Gamescope microcompositor.");
1117 connect(gamescopeCheck_, &EnvVarCheckBox::toggled, this,
1118 &GameConfigDialog::onAnySettingChanged);
1119 displayLayout->addWidget(gamescopeCheck_);
1120
1121 waylandCheck_ =
1122 new EnvVarCheckBox("Native Wayland support (experimental)", "PROTON_ENABLE_WAYLAND=1",
1123 "Enable native Wayland support in Proton. May break overlays.");
1124 connect(waylandCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
1125 displayLayout->addWidget(waylandCheck_);
1126
1127 layout->addWidget(displayGroup);
1128
1129 // --- Debugging & Monitoring ---
1130 QGroupBox* debugGroup = new QGroupBox("Debugging & Monitoring");
1131 applyAccentGroupStyle(debugGroup, c, false);
1132 QVBoxLayout* debugLayout = new QVBoxLayout(debugGroup);
1133
1134 protonLogCheck_ = new EnvVarCheckBox("Proton logging", "PROTON_LOG=1",
1135 "Enable verbose Proton/Wine logging to ~/proton_*.log");
1136 connect(protonLogCheck_, &EnvVarCheckBox::toggled, this,
1137 &GameConfigDialog::onAnySettingChanged);
1138 debugLayout->addWidget(protonLogCheck_);
1139
1140 dxvkHudCheck_ = new EnvVarCheckBox("DXVK HUD (shader compilation status)", "DXVK_HUD=compiler",
1141 "Show DXVK shader compilation status.");
1142 connect(dxvkHudCheck_, &EnvVarCheckBox::toggled, this, &GameConfigDialog::onAnySettingChanged);
1143 debugLayout->addWidget(dxvkHudCheck_);
1144
1145 layout->addWidget(debugGroup);
1146
1147 layout->addStretch();
1148 scrollArea->setWidget(scrollContent);
1149
1150 // Initialize preview panel pointers to null (removed — launch preview at bottom is sufficient)
1151 settingsPreviewPanel_ = nullptr;
1152 previewTitleLabel_ = nullptr;
1153 previewComparisonLabel_ = nullptr;
1154 previewSettingsText_ = nullptr;
1155
1156 QVBoxLayout* tabLayout = new QVBoxLayout(tab);
1157 tabLayout->setContentsMargins(0, 0, 0, 0);
1158 tabLayout->addWidget(scrollArea);
1159}
1160
1161void GameConfigDialog::setupGraphicsTab(QWidget* tab)
1162{
1163 // Graphics options are now integrated into the Performance & Graphics tab.
1164 // This method is retained for API compatibility but creates no UI.
1165 Q_UNUSED(tab)
1166}
1167
1168void GameConfigDialog::setupEnvironmentTab(QWidget* tab)
1169{
1170 const ThemeColors& c = themeManager_->colors();
1171 QVBoxLayout* layout = new QVBoxLayout(tab);
1172 layout->setSpacing(16);
1173
1174 // Header info
1175 QLabel* infoLabel =
1176 new QLabel("Custom environment variables for game execution. "
1177 "These are applied in addition to the settings from other tabs.");
1178 infoLabel->setWordWrap(true);
1179 infoLabel->setStyleSheet(QString("color: %1; padding: 8px; background: %2; border-radius: 6px;")
1180 .arg(c.textSecondary.name(), c.cardBackground.name()));
1181 layout->addWidget(infoLabel);
1182
1183 // Quick-insert buttons for variables not covered by Performance/Graphics checkboxes
1184 QGroupBox* quickInsertGroup = new QGroupBox("Quick Insert");
1185 applyAccentGroupStyle(quickInsertGroup, c, false);
1186 QHBoxLayout* quickLayout = new QHBoxLayout(quickInsertGroup);
1187
1188 auto addQuickBtn =
1189 [this, &quickLayout](const QString& var, const QString& value, const QString& tooltip)
1190 {
1191 QPushButton* btn = new QPushButton(var);
1192 btn->setToolTip(tooltip);
1193 btn->setMaximumWidth(200);
1194 connect(btn, &QPushButton::clicked, this,
1195 [this, var, value]()
1196 {
1197 int row = envVarTable_->rowCount();
1198 envVarTable_->insertRow(row);
1199 envVarTable_->setItem(row, 0, new QTableWidgetItem(var));
1200 envVarTable_->setItem(row, 1, new QTableWidgetItem(value));
1201 });
1202 quickLayout->addWidget(btn);
1203 };
1204
1205 addQuickBtn("WINEDEBUG", "-all", "Disable Wine debug output");
1206 addQuickBtn("mesa_glthread", "true", "Enable Mesa GL threading");
1207 addQuickBtn("RADV_PERFTEST", "gpl", "AMD GPU pipeline caching");
1208 addQuickBtn("VKD3D_CONFIG", "dxr", "VKD3D ray tracing config");
1209 quickLayout->addStretch();
1210
1211 layout->addWidget(quickInsertGroup);
1212
1213 // Known variables reference (collapsible)
1214 QGroupBox* refGroup = new QGroupBox("Environment Variable Reference");
1215 applyAccentGroupStyle(refGroup, c, false);
1216 refGroup->setCheckable(true);
1217 refGroup->setChecked(false);
1218 QVBoxLayout* refLayout = new QVBoxLayout(refGroup);
1219
1220 QTextEdit* refText = new QTextEdit();
1221 refText->setReadOnly(true);
1222 refText->setMaximumHeight(150);
1223 refText->setStyleSheet(
1224 QString("background-color: %1; font-size: 10px;").arg(c.panelBackground.name()));
1225 refText->setHtml(
1226 "<b>Proton/Wine:</b> PROTON_USE_NTSYNC, WINEFSYNC, WINEESYNC, PROTON_NO_ESYNC, "
1227 "PROTON_NO_FSYNC, PROTON_LOG, "
1228 "PROTON_DUMP_DEBUG_COMMANDS, PROTON_OLD_GL_STRING, PROTON_USE_WINED3D, "
1229 "WINEDEBUG, WINEDLLOVERRIDES<br><br>"
1230 "<b>DXVK:</b> DXVK_HUD, DXVK_ASYNC, DXVK_STATE_CACHE, DXVK_STATE_CACHE_PATH, "
1231 "DXVK_LOG_LEVEL, "
1232 "DXVK_LOG_PATH, DXVK_CONFIG_FILE, DXVK_FRAME_RATE, DXVK_HDR<br><br>"
1233 "<b>AMD:</b> PROTON_FSR4_UPGRADE, PROTON_ENABLE_AMD_AGS, RADV_PERFTEST, AMD_VULKAN_ICD, "
1234 "VKD3D_FEATURE_LEVEL, WINE_FULLSCREEN_FSR, PROTON_FSR4_RDNA3_UPGRADE<br><br>"
1235 "<b>NVIDIA:</b> PROTON_DLSS_UPGRADE, PROTON_DLSS_INDICATOR, PROTON_NVIDIA_LIBS, "
1236 "__GL_SHADER_DISK_CACHE, __GL_SHADER_DISK_CACHE_PATH, __GL_SHADER_DISK_CACHE_SIZE, "
1237 "__GL_SHADER_DISK_CACHE_SKIP_CLEANUP, __GL_THREADED_OPTIMIZATIONS, "
1238 "PROTON_FORCE_NVAPI<br><br>"
1239 "<b>Intel:</b> PROTON_XESS_UPGRADE, INTEL_DEBUG<br><br>"
1240 "<b>Mesa/Vulkan:</b> mesa_glthread, MESA_LOADER_DRIVER_OVERRIDE, VK_ICD_FILENAMES, "
1241 "RADV_DEBUG, ANV_DEBUG<br><br>"
1242 "<b>Performance:</b> MANGOHUD, MANGOHUD_CONFIG, ENABLE_VKBASALT, VKBASALT_CONFIG_FILE, "
1243 "GAMEMODE_AUTO, LD_PRELOAD");
1244 refLayout->addWidget(refText);
1245 layout->addWidget(refGroup);
1246
1247 envVarTable_ = new QTableWidget(0, 2);
1248 envVarTable_->setHorizontalHeaderLabels({"Variable", "Value"});
1249 envVarTable_->horizontalHeader()->setStretchLastSection(true);
1250 envVarTable_->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
1251 envVarTable_->setSelectionBehavior(QAbstractItemView::SelectRows);
1252 layout->addWidget(envVarTable_);
1253
1254 QHBoxLayout* buttonLayout = new QHBoxLayout();
1255 QPushButton* addBtn = new QPushButton("Add Variable");
1256 QPushButton* removeBtn = new QPushButton("Remove Selected");
1257 connect(addBtn, &QPushButton::clicked, this, &GameConfigDialog::onAddEnvVar);
1258 connect(removeBtn, &QPushButton::clicked, this, &GameConfigDialog::onRemoveEnvVar);
1259 buttonLayout->addWidget(addBtn);
1260 buttonLayout->addWidget(removeBtn);
1261 buttonLayout->addStretch();
1262 layout->addLayout(buttonLayout);
1263
1264 // Steam defaults checkbox
1265 useSteamDefaultsCheck_ =
1266 new QCheckBox("Use Steam defaults only (ignore optimizations for Steam games)");
1267 useSteamDefaultsCheck_->setToolTip(
1268 "When enabled, Steam games will use Steam's own launch options\n"
1269 "instead of the environment variables configured here.");
1270 layout->addWidget(useSteamDefaultsCheck_);
1271
1272 // Steam launch fallback checkbox
1273 useSteamLaunchCheck_ =
1274 new QCheckBox("Launch via Steam client (Steam overlay, DRM, cloud saves)");
1275 useSteamLaunchCheck_->setToolTip(
1276 "When checked: Launches via 'steam -applaunch' — Steam manages Proton,\n"
1277 "provides Steam overlay, handles DRM, and cloud saves work normally.\n"
1278 "Custom env vars and wrappers must be set in Steam's launch options.\n\n"
1279 "When unchecked: Launches Proton directly — full control over env vars,\n"
1280 "wrappers (game-performance, MangoHud, GameMode), and process tracking.\n"
1281 "Steam overlay may not work. Best for optimizing performance.");
1282 layout->addWidget(useSteamLaunchCheck_);
1283}
1284
1285void GameConfigDialog::setupLaunchPreviewPanel()
1286{
1287 const ThemeColors& c = themeManager_->colors();
1288
1289 launchPreviewGroup_ = new QGroupBox("Launch Preview (what will actually run)");
1290 QVBoxLayout* layout = new QVBoxLayout(launchPreviewGroup_);
1291
1292 QLabel* envLabel = new QLabel("Environment Variables:");
1293 layout->addWidget(envLabel);
1294
1295 envVarsPreview_ = new QTextEdit();
1296 envVarsPreview_->setReadOnly(true);
1297 envVarsPreview_->setMaximumHeight(80);
1298 QFont monoFont("monospace", 9);
1299 envVarsPreview_->setFont(monoFont);
1300 envVarsPreview_->setStyleSheet(QString("background-color: %1; color: %2;")
1301 .arg(c.panelBackground.name())
1302 .arg(c.textPrimary.name()));
1303 layout->addWidget(envVarsPreview_);
1304
1305 QLabel* cmdLabel = new QLabel("Command:");
1306 layout->addWidget(cmdLabel);
1307
1308 commandPreview_ = new QTextEdit();
1309 commandPreview_->setReadOnly(true);
1310 commandPreview_->setMaximumHeight(60);
1311 commandPreview_->setFont(monoFont);
1312 commandPreview_->setStyleSheet(QString("background-color: %1; color: %2;")
1313 .arg(c.panelBackground.name())
1314 .arg(c.textPrimary.name()));
1315 layout->addWidget(commandPreview_);
1316}
1317
1318void GameConfigDialog::loadFromGame()
1319{
1320 updatingPreset_ = true;
1321
1322 // General tab
1323 nameEdit_->setText(QString::fromStdString(game_->name));
1324
1325 int sourceIndex = sourceCombo_->findData(static_cast<int>(game_->source));
1326 if (sourceIndex >= 0)
1327 sourceCombo_->setCurrentIndex(sourceIndex);
1328
1329 executableEdit_->setText(QString::fromStdString(game_->runnerConfig.executablePath));
1330 workingDirEdit_->setText(QString::fromStdString(game_->runnerConfig.workingDirectory));
1331 argumentsEdit_->setText(QString::fromStdString(game_->runnerConfig.arguments));
1332
1333 // Exclude processes
1334 QString excludeText;
1335 for (const auto& proc : game_->runnerConfig.excludeProcesses)
1336 {
1337 if (!excludeText.isEmpty())
1338 excludeText += "\n";
1339 excludeText += QString::fromStdString(proc);
1340 }
1341 excludeProcessesEdit_->setPlainText(excludeText);
1342
1343 // Runner tab
1344 QString runnerType = QString::fromStdString(game_->runnerConfig.runnerType);
1345 int runnerIndex = runnerTypeCombo_->findData(runnerType);
1346 if (runnerIndex >= 0)
1347 runnerTypeCombo_->setCurrentIndex(runnerIndex);
1348
1349 runnerVersionCombo_->setCurrentText(QString::fromStdString(game_->runnerConfig.runnerVersion));
1350 winePrefixEdit_->setText(QString::fromStdString(game_->runnerConfig.winePrefix));
1351 winePathEdit_->setText(QString::fromStdString(game_->runnerConfig.winePath));
1352 wineDllEdit_->setText(QString::fromStdString(game_->runnerConfig.wineDLL));
1353 virtualDesktopCheck_->setChecked(game_->runnerConfig.useVirtualDesktop);
1354 desktopWidthSpin_->setValue(game_->runnerConfig.virtualDesktopWidth);
1355 desktopHeightSpin_->setValue(game_->runnerConfig.virtualDesktopHeight);
1356
1357 // Performance tab - Load from environment variables stored in game
1358 const auto& envVars = game_->runnerConfig.environmentVariables;
1359
1360 auto hasEnvVar = [&envVars](const std::string& key)
1361 { return envVars.find(key) != envVars.end() && envVars.at(key) == "1"; };
1362
1363 ntSyncCheck_->setChecked(hasEnvVar("PROTON_USE_NTSYNC"));
1364 fsyncCheck_->setChecked(game_->runnerConfig.enableFsync || hasEnvVar("WINEFSYNC"));
1365 localShaderCacheCheck_->setChecked(hasEnvVar("__GL_SHADER_DISK_CACHE"));
1366 skipShaderCleanupCheck_->setChecked(hasEnvVar("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP"));
1367 dxvkAsyncCheck_->setChecked(hasEnvVar("DXVK_ASYNC"));
1368
1369 mangoHudCheck_->setChecked(game_->runnerConfig.enableMangoHud || hasEnvVar("MANGOHUD"));
1370 gameModeCheck_->setChecked(game_->runnerConfig.enableGameMode);
1371 gamePerformanceCheck_->setChecked(game_->runnerConfig.enableGamePerformance);
1372 vkBasaltCheck_->setChecked(game_->runnerConfig.enableVkBasalt || hasEnvVar("ENABLE_VKBASALT"));
1373
1374 protonLogCheck_->setChecked(hasEnvVar("PROTON_LOG"));
1375 dxvkHudCheck_->setChecked(envVars.find("DXVK_HUD") != envVars.end());
1376
1377 // Graphics tab - GPU-specific options (may be nullptr if not applicable)
1378 if (dlssUpgradeCheck_)
1379 dlssUpgradeCheck_->setChecked(hasEnvVar("PROTON_DLSS_UPGRADE"));
1380 if (dlssIndicatorCheck_)
1381 dlssIndicatorCheck_->setChecked(hasEnvVar("PROTON_DLSS_INDICATOR"));
1382 if (nvidiaLibsCheck_)
1383 nvidiaLibsCheck_->setChecked(hasEnvVar("PROTON_NVIDIA_LIBS"));
1384 if (nvidia4000FixCheck_)
1385 nvidia4000FixCheck_->setChecked(hasEnvVar("PROTON_NVIDIA_LIBS_NO_32BIT"));
1386
1387 if (fsr4UpgradeCheck_)
1388 fsr4UpgradeCheck_->setChecked(hasEnvVar("PROTON_FSR4_UPGRADE"));
1389 if (fsr4Rdna3Check_)
1390 fsr4Rdna3Check_->setChecked(hasEnvVar("PROTON_FSR4_RDNA3_UPGRADE"));
1391 if (fsrCheck_)
1392 fsrCheck_->setChecked(hasEnvVar("WINE_FULLSCREEN_FSR"));
1393
1394 if (xessUpgradeCheck_)
1395 xessUpgradeCheck_->setChecked(hasEnvVar("PROTON_XESS_UPGRADE"));
1396
1397 hdrCheck_->setChecked(hasEnvVar("PROTON_ENABLE_HDR"));
1398 dxvkHdrCheck_->setChecked(hasEnvVar("DXVK_HDR"));
1399 gamescopeCheck_->setChecked(game_->runnerConfig.enableGamescope);
1400 waylandCheck_->setChecked(hasEnvVar("PROTON_ENABLE_WAYLAND"));
1401
1402 // Environment tab - Load custom vars (excluding ones we handle explicitly)
1403 envVarTable_->setRowCount(0);
1404 for (const auto& [key, value] : game_->runnerConfig.environmentVariables)
1405 {
1406 // Skip env vars that have dedicated checkboxes
1408 {
1409 int row = envVarTable_->rowCount();
1410 envVarTable_->insertRow(row);
1411 envVarTable_->setItem(row, 0, new QTableWidgetItem(QString::fromStdString(key)));
1412 envVarTable_->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(value)));
1413 }
1414 }
1415 useSteamDefaultsCheck_->setChecked(game_->runnerConfig.useSteamDefaults);
1416 useSteamLaunchCheck_->setChecked(game_->runnerConfig.useSteamLaunch);
1417
1418 updatingPreset_ = false;
1419
1420 // Detect and set current preset
1421 ConfigPreset detected = detectCurrentPreset();
1422 updatePresetComboSilently(detected);
1423
1424 // Update Steam group visibility
1425 updateSteamGroup();
1426
1427 // Update template combo
1428 updateTemplateCombo();
1429
1430 // Update performance wrapper conflict warning
1431 updatePerfWrapperWarning();
1432
1433 // Refresh performance profiles list
1434 refreshProfileList();
1435}
1436
1437void GameConfigDialog::saveToGame()
1438{
1439 // General tab
1440 game_->name = nameEdit_->text().toStdString();
1441 game_->source = static_cast<GameSource>(sourceCombo_->currentData().toInt());
1442 game_->runnerConfig.executablePath = executableEdit_->text().toStdString();
1443 game_->runnerConfig.workingDirectory = workingDirEdit_->text().toStdString();
1444 game_->runnerConfig.arguments = argumentsEdit_->text().toStdString();
1445
1446 // Exclude processes
1447 game_->runnerConfig.excludeProcesses.clear();
1448 QString excludeText = excludeProcessesEdit_->toPlainText();
1449 QStringList lines = excludeText.split('\n', Qt::SkipEmptyParts);
1450 for (const QString& line : lines)
1451 {
1452 QString trimmed = line.trimmed();
1453 if (!trimmed.isEmpty())
1454 {
1455 game_->runnerConfig.excludeProcesses.push_back(trimmed.toStdString());
1456 }
1457 }
1458
1459 // Runner tab
1460 game_->runnerConfig.runnerType = runnerTypeCombo_->currentData().toString().toStdString();
1461 game_->runnerConfig.runnerVersion = runnerVersionCombo_->currentText().toStdString();
1462 game_->runnerConfig.winePrefix = winePrefixEdit_->text().toStdString();
1463 game_->runnerConfig.winePath = winePathEdit_->text().toStdString();
1464 game_->runnerConfig.wineDLL = wineDllEdit_->text().toStdString();
1465 game_->runnerConfig.useVirtualDesktop = virtualDesktopCheck_->isChecked();
1466 game_->runnerConfig.virtualDesktopWidth = desktopWidthSpin_->value();
1467 game_->runnerConfig.virtualDesktopHeight = desktopHeightSpin_->value();
1468
1469 // Update game runner enum based on type
1470 QString runnerType = runnerTypeCombo_->currentData().toString();
1471 if (runnerType == "native")
1472 game_->runner = GameRunner::Native;
1473 else if (runnerType == "wine")
1474 game_->runner = GameRunner::Wine;
1475 else if (runnerType == "proton")
1476 game_->runner = GameRunner::Proton;
1477
1478 // Clear and rebuild environment variables
1479 game_->runnerConfig.environmentVariables.clear();
1480
1481 // Performance tab env vars
1482 if (ntSyncCheck_->isChecked())
1483 game_->runnerConfig.environmentVariables["PROTON_USE_NTSYNC"] = "1";
1484 if (fsyncCheck_->isChecked())
1485 game_->runnerConfig.environmentVariables["WINEFSYNC"] = "1";
1486 if (localShaderCacheCheck_->isChecked())
1487 game_->runnerConfig.environmentVariables["__GL_SHADER_DISK_CACHE"] = "1";
1488 if (skipShaderCleanupCheck_->isChecked())
1489 game_->runnerConfig.environmentVariables["__GL_SHADER_DISK_CACHE_SKIP_CLEANUP"] = "1";
1490 if (dxvkAsyncCheck_->isChecked())
1491 game_->runnerConfig.environmentVariables["DXVK_ASYNC"] = "1";
1492 if (mangoHudCheck_->isChecked())
1493 game_->runnerConfig.environmentVariables["MANGOHUD"] = "1";
1494 if (vkBasaltCheck_->isChecked())
1495 game_->runnerConfig.environmentVariables["ENABLE_VKBASALT"] = "1";
1496 if (protonLogCheck_->isChecked())
1497 game_->runnerConfig.environmentVariables["PROTON_LOG"] = "1";
1498 if (dxvkHudCheck_->isChecked())
1499 game_->runnerConfig.environmentVariables["DXVK_HUD"] = "compiler";
1500
1501 // Graphics tab env vars - GPU-specific options (may be nullptr if not applicable)
1502 if (dlssUpgradeCheck_ && dlssUpgradeCheck_->isChecked())
1503 game_->runnerConfig.environmentVariables["PROTON_DLSS_UPGRADE"] = "1";
1504 if (dlssIndicatorCheck_ && dlssIndicatorCheck_->isChecked())
1505 game_->runnerConfig.environmentVariables["PROTON_DLSS_INDICATOR"] = "1";
1506 if (nvidiaLibsCheck_ && nvidiaLibsCheck_->isChecked())
1507 game_->runnerConfig.environmentVariables["PROTON_NVIDIA_LIBS"] = "1";
1508 if (nvidia4000FixCheck_ && nvidia4000FixCheck_->isChecked())
1509 game_->runnerConfig.environmentVariables["PROTON_NVIDIA_LIBS_NO_32BIT"] = "1";
1510 if (fsr4UpgradeCheck_ && fsr4UpgradeCheck_->isChecked())
1511 game_->runnerConfig.environmentVariables["PROTON_FSR4_UPGRADE"] = "1";
1512 if (fsr4Rdna3Check_ && fsr4Rdna3Check_->isChecked())
1513 game_->runnerConfig.environmentVariables["PROTON_FSR4_RDNA3_UPGRADE"] = "1";
1514 if (fsrCheck_ && fsrCheck_->isChecked())
1515 game_->runnerConfig.environmentVariables["WINE_FULLSCREEN_FSR"] = "1";
1516 if (xessUpgradeCheck_ && xessUpgradeCheck_->isChecked())
1517 game_->runnerConfig.environmentVariables["PROTON_XESS_UPGRADE"] = "1";
1518 if (hdrCheck_->isChecked())
1519 game_->runnerConfig.environmentVariables["PROTON_ENABLE_HDR"] = "1";
1520 if (dxvkHdrCheck_->isChecked())
1521 game_->runnerConfig.environmentVariables["DXVK_HDR"] = "1";
1522 if (waylandCheck_->isChecked())
1523 game_->runnerConfig.environmentVariables["PROTON_ENABLE_WAYLAND"] = "1";
1524
1525 // Performance wrapper flags
1526 game_->runnerConfig.enableMangoHud = mangoHudCheck_->isChecked();
1527 game_->runnerConfig.enableGameMode = gameModeCheck_->isChecked();
1528 game_->runnerConfig.enableGamePerformance = gamePerformanceCheck_->isChecked();
1529 game_->runnerConfig.enableVkBasalt = vkBasaltCheck_->isChecked();
1530 game_->runnerConfig.enableGamescope = gamescopeCheck_->isChecked();
1531 game_->runnerConfig.enableFsync = fsyncCheck_->isChecked();
1532
1533 // Custom environment variables from table
1534 for (int row = 0; row < envVarTable_->rowCount(); ++row)
1535 {
1536 QTableWidgetItem* keyItem = envVarTable_->item(row, 0);
1537 QTableWidgetItem* valueItem = envVarTable_->item(row, 1);
1538 if (keyItem && valueItem && !keyItem->text().isEmpty())
1539 {
1540 game_->runnerConfig.environmentVariables[keyItem->text().toStdString()] =
1541 valueItem->text().toStdString();
1542 }
1543 }
1544 game_->runnerConfig.useSteamDefaults = useSteamDefaultsCheck_->isChecked();
1545 game_->runnerConfig.useSteamLaunch = useSteamLaunchCheck_->isChecked();
1546
1547 // NOTE: For Steam games we deliberately do NOT write Steam's
1548 // CompatToolMapping (config.vdf) here. That used to shut down Steam, wait
1549 // up to 15s on the GUI thread, rewrite config.vdf, and restart Steam — a
1550 // hard UI freeze on every Proton-version change. It is redundant:
1551 // GameLaunchManager::checkAndSyncSettings() (launch_manager.cpp) performs
1552 // the identical read/diff/shutdown/write/restart on its own background
1553 // launch thread, sourced from the same game_->runnerConfig.runnerVersion we
1554 // just saved, and no-ops when nothing changed. Deferring to launch time
1555 // removes the freeze and avoids force-restarting Steam when the user isn't
1556 // even launching this game. The display->internal Proton-id mapping now
1557 // lives in SteamLibraryScanner::normalizeProtonName so both paths agree.
1558
1559 // Invalidate name cache since name might have changed
1560 game_->invalidateCache();
1561}
1562
1563void GameConfigDialog::applyPreset(ConfigPreset preset)
1564{
1565 updatingPreset_ = true;
1566
1567 // Reset all to defaults first
1568 ntSyncCheck_->setChecked(false);
1569 fsyncCheck_->setChecked(false);
1570 localShaderCacheCheck_->setChecked(false);
1571 skipShaderCleanupCheck_->setChecked(false);
1572 dxvkAsyncCheck_->setChecked(false);
1573 mangoHudCheck_->setChecked(false);
1574 gameModeCheck_->setChecked(false);
1575 gamePerformanceCheck_->setChecked(false);
1576 vkBasaltCheck_->setChecked(false);
1577 protonLogCheck_->setChecked(false);
1578 dxvkHudCheck_->setChecked(false);
1579
1580 // GPU-specific checkboxes (may be nullptr if not applicable)
1581 if (dlssUpgradeCheck_)
1582 dlssUpgradeCheck_->setChecked(false);
1583 if (dlssIndicatorCheck_)
1584 dlssIndicatorCheck_->setChecked(false);
1585 if (nvidiaLibsCheck_)
1586 nvidiaLibsCheck_->setChecked(false);
1587 if (nvidia4000FixCheck_)
1588 nvidia4000FixCheck_->setChecked(false);
1589 if (fsr4UpgradeCheck_)
1590 fsr4UpgradeCheck_->setChecked(false);
1591 if (fsr4Rdna3Check_)
1592 fsr4Rdna3Check_->setChecked(false);
1593 if (fsrCheck_)
1594 fsrCheck_->setChecked(false);
1595 if (xessUpgradeCheck_)
1596 xessUpgradeCheck_->setChecked(false);
1597 hdrCheck_->setChecked(false);
1598 dxvkHdrCheck_->setChecked(false);
1599 gamescopeCheck_->setChecked(false);
1600 waylandCheck_->setChecked(false);
1601
1602 switch (preset)
1603 {
1605 presetDescLabel_->setText(
1606 "Good balance of performance and quality. Enables shader caching and "
1607 "async compilation to reduce stuttering.");
1608 fsyncCheck_->setChecked(true);
1609 localShaderCacheCheck_->setChecked(true);
1610 dxvkAsyncCheck_->setChecked(true);
1611 mangoHudCheck_->setChecked(true);
1612 break;
1613
1615 presetDescLabel_->setText(
1616 "Prioritize FPS over everything. Enables NTSync, all performance wrappers, "
1617 "and GPU-specific optimizations.");
1618 ntSyncCheck_->setChecked(true);
1619 fsyncCheck_->setChecked(true);
1620 localShaderCacheCheck_->setChecked(true);
1621 skipShaderCleanupCheck_->setChecked(true);
1622 dxvkAsyncCheck_->setChecked(true);
1623 mangoHudCheck_->setChecked(true);
1624 gameModeCheck_->setChecked(true);
1625 gamePerformanceCheck_->setChecked(true);
1626 // Enable GPU-specific based on detected GPU (with null checks)
1627 {
1628 QString gpu = getGpuVendor();
1629 if (gpu.contains("NVIDIA", Qt::CaseInsensitive))
1630 {
1631 if (dlssUpgradeCheck_)
1632 dlssUpgradeCheck_->setChecked(true);
1633 if (nvidiaLibsCheck_)
1634 nvidiaLibsCheck_->setChecked(true);
1635 }
1636 else if (gpu.contains("AMD", Qt::CaseInsensitive))
1637 {
1638 if (fsr4UpgradeCheck_)
1639 fsr4UpgradeCheck_->setChecked(true);
1640 // Auto-enable RDNA3 optimization for RX 7000 series GPUs
1641 const auto& gpuInfo = SystemInfoService::instance().getGPUInfo();
1642 if (gpuInfo.generation == GPUGeneration::AMD_RDNA3 && fsr4Rdna3Check_)
1643 {
1644 fsr4Rdna3Check_->setChecked(true);
1645 }
1646 }
1647 }
1648 break;
1649
1651 presetDescLabel_->setText("Maximum visual quality. Enables HDR, upscaling upgrades, and "
1652 "quality-focused settings.");
1653 fsyncCheck_->setChecked(true);
1654 localShaderCacheCheck_->setChecked(true);
1655 mangoHudCheck_->setChecked(true);
1656 // Enable all upscaling (with null checks for GPU-specific options)
1657 if (dlssUpgradeCheck_)
1658 dlssUpgradeCheck_->setChecked(true);
1659 if (dlssIndicatorCheck_)
1660 dlssIndicatorCheck_->setChecked(true);
1661 if (nvidiaLibsCheck_)
1662 nvidiaLibsCheck_->setChecked(true);
1663 if (fsr4UpgradeCheck_)
1664 fsr4UpgradeCheck_->setChecked(true);
1665 if (xessUpgradeCheck_)
1666 xessUpgradeCheck_->setChecked(true);
1667 hdrCheck_->setChecked(true);
1668 dxvkHdrCheck_->setChecked(true);
1669 break;
1670
1672 presetDescLabel_->setText(
1673 "Maximum compatibility with minimal tweaks. Only basic shader caching enabled. "
1674 "Use this if games don't work with other presets.");
1675 localShaderCacheCheck_->setChecked(true);
1676 break;
1677
1679 presetDescLabel_->setText(
1680 "Manual configuration. Settings have been modified from a preset.");
1681 break;
1682 }
1683
1684 updatingPreset_ = false;
1685 updateLaunchPreview();
1686}
1687
1688ConfigPreset GameConfigDialog::detectCurrentPreset() const
1689{
1690 // Check if matches Balanced
1691 bool isBalanced = !ntSyncCheck_->isChecked() && fsyncCheck_->isChecked() &&
1692 localShaderCacheCheck_->isChecked() &&
1693 !skipShaderCleanupCheck_->isChecked() && dxvkAsyncCheck_->isChecked() &&
1694 mangoHudCheck_->isChecked() && !gameModeCheck_->isChecked() &&
1695 !gamePerformanceCheck_->isChecked();
1696
1697 if (isBalanced)
1699
1700 // Check if matches Compatibility
1701 bool isCompatibility = !ntSyncCheck_->isChecked() && !fsyncCheck_->isChecked() &&
1702 localShaderCacheCheck_->isChecked() &&
1703 !skipShaderCleanupCheck_->isChecked() && !dxvkAsyncCheck_->isChecked() &&
1704 !mangoHudCheck_->isChecked() && !gameModeCheck_->isChecked() &&
1705 !gamePerformanceCheck_->isChecked();
1706
1707 if (isCompatibility)
1709
1710 // Otherwise it's Custom
1711 return ConfigPreset::Custom;
1712}
1713
1714void GameConfigDialog::updatePresetComboSilently(ConfigPreset preset)
1715{
1716 updatingPreset_ = true;
1717 int index = presetCombo_->findData(static_cast<int>(preset));
1718 if (index >= 0)
1719 {
1720 presetCombo_->setCurrentIndex(index);
1721 }
1722
1723 // Update description
1724 switch (preset)
1725 {
1727 presetDescLabel_->setText(
1728 "Good balance of performance and quality. Enables shader caching and "
1729 "async compilation to reduce stuttering.");
1730 break;
1732 presetDescLabel_->setText(
1733 "Prioritize FPS over everything. Enables NTSync, all performance wrappers, "
1734 "and GPU-specific optimizations.");
1735 break;
1737 presetDescLabel_->setText("Maximum visual quality. Enables HDR, upscaling upgrades, and "
1738 "quality-focused settings.");
1739 break;
1741 presetDescLabel_->setText(
1742 "Maximum compatibility with minimal tweaks. Only basic shader caching enabled. "
1743 "Use this if games don't work with other presets.");
1744 break;
1746 presetDescLabel_->setText(
1747 "Manual configuration. Settings have been modified from a preset.");
1748 break;
1749 }
1750
1751 updatingPreset_ = false;
1752}
1753
1754QString GameConfigDialog::buildEnvironmentString() const
1755{
1756 QStringList envVars;
1757
1758 // Performance env vars
1759 if (ntSyncCheck_->isChecked())
1760 envVars << "PROTON_USE_NTSYNC=1";
1761 if (fsyncCheck_->isChecked())
1762 envVars << "WINEFSYNC=1";
1763 if (localShaderCacheCheck_->isChecked())
1764 envVars << "__GL_SHADER_DISK_CACHE=1";
1765 if (skipShaderCleanupCheck_->isChecked())
1766 envVars << "__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1";
1767 if (dxvkAsyncCheck_->isChecked())
1768 envVars << "DXVK_ASYNC=1";
1769 if (mangoHudCheck_->isChecked())
1770 envVars << "MANGOHUD=1";
1771 if (vkBasaltCheck_->isChecked())
1772 envVars << "ENABLE_VKBASALT=1";
1773 if (protonLogCheck_->isChecked())
1774 envVars << "PROTON_LOG=1";
1775 if (dxvkHudCheck_->isChecked())
1776 envVars << "DXVK_HUD=compiler";
1777
1778 // Graphics env vars - GPU-specific options (may be nullptr if not applicable)
1779 if (dlssUpgradeCheck_ && dlssUpgradeCheck_->isChecked())
1780 envVars << "PROTON_DLSS_UPGRADE=1";
1781 if (dlssIndicatorCheck_ && dlssIndicatorCheck_->isChecked())
1782 envVars << "PROTON_DLSS_INDICATOR=1";
1783 if (nvidiaLibsCheck_ && nvidiaLibsCheck_->isChecked())
1784 envVars << "PROTON_NVIDIA_LIBS=1";
1785 if (nvidia4000FixCheck_ && nvidia4000FixCheck_->isChecked())
1786 envVars << "PROTON_NVIDIA_LIBS_NO_32BIT=1";
1787 if (fsr4UpgradeCheck_ && fsr4UpgradeCheck_->isChecked())
1788 envVars << "PROTON_FSR4_UPGRADE=1";
1789 if (fsr4Rdna3Check_ && fsr4Rdna3Check_->isChecked())
1790 envVars << "PROTON_FSR4_RDNA3_UPGRADE=1";
1791 if (fsrCheck_ && fsrCheck_->isChecked())
1792 envVars << "WINE_FULLSCREEN_FSR=1";
1793 if (xessUpgradeCheck_ && xessUpgradeCheck_->isChecked())
1794 envVars << "PROTON_XESS_UPGRADE=1";
1795 if (hdrCheck_->isChecked())
1796 envVars << "PROTON_ENABLE_HDR=1";
1797 if (dxvkHdrCheck_->isChecked())
1798 envVars << "DXVK_HDR=1";
1799 if (waylandCheck_->isChecked())
1800 envVars << "PROTON_ENABLE_WAYLAND=1";
1801
1802 // Custom env vars from table
1803 for (int row = 0; row < envVarTable_->rowCount(); ++row)
1804 {
1805 QTableWidgetItem* keyItem = envVarTable_->item(row, 0);
1806 QTableWidgetItem* valueItem = envVarTable_->item(row, 1);
1807 if (keyItem && valueItem && !keyItem->text().isEmpty())
1808 {
1809 envVars << QString("%1=%2").arg(keyItem->text(), valueItem->text());
1810 }
1811 }
1812
1813 return envVars.join("\n");
1814}
1815
1816QString GameConfigDialog::buildLaunchCommand() const
1817{
1818 QStringList parts;
1819
1820 // Wrappers (order matters)
1821 if (gameModeCheck_->isChecked())
1822 parts << "gamemoderun";
1823 if (gamePerformanceCheck_->isChecked())
1824 parts << "game-performance";
1825 if (gamescopeCheck_->isChecked())
1826 parts << "gamescope";
1827 if (mangoHudCheck_->isChecked())
1828 parts << "mangohud";
1829
1830 // Runner
1831 QString runnerType = runnerTypeCombo_->currentData().toString();
1832 if (runnerType == "proton")
1833 {
1834 parts << QString("proton run");
1835 }
1836 else if (runnerType == "wine")
1837 {
1838 QString winePath = winePathEdit_->text();
1839 if (winePath.isEmpty())
1840 parts << "wine";
1841 else
1842 parts << winePath;
1843 }
1844
1845 // Executable
1846 QString exe = executableEdit_->text();
1847 if (!exe.isEmpty())
1848 {
1849 parts << exe;
1850 }
1851 else
1852 {
1853 parts << "<executable>";
1854 }
1855
1856 // Arguments
1857 QString args = argumentsEdit_->text();
1858 if (!args.isEmpty())
1859 {
1860 parts << args;
1861 }
1862
1863 return parts.join(" ");
1864}
1865
1866QString GameConfigDialog::getGpuVendor() const
1867{
1868 // GPU vendor is fixed for the process lifetime, so detect once and cache.
1869 // getGpuVendor() is a const getter called from several places (and can be
1870 // called repeatedly); without caching, each call blocked the GUI thread in
1871 // lspci.waitForFinished() for up to 1s. Called only on the GUI thread, so
1872 // the function-local static needs no extra synchronization.
1873 static const QString cached = []() -> QString
1874 {
1875 // Try to detect GPU vendor from /proc/driver/nvidia or lspci
1876 QFile nvidiaFile("/proc/driver/nvidia/version");
1877 if (nvidiaFile.exists())
1878 return "NVIDIA";
1879
1880 QProcess lspci;
1881 lspci.start("lspci", QStringList() << "-nn");
1882 lspci.waitForFinished(1000);
1883
1884 QString output = QString::fromUtf8(lspci.readAllStandardOutput());
1885
1886 if (output.contains("NVIDIA", Qt::CaseInsensitive))
1887 return "NVIDIA";
1888 if (output.contains("AMD", Qt::CaseInsensitive) ||
1889 output.contains("Radeon", Qt::CaseInsensitive) ||
1890 output.contains("ATI", Qt::CaseInsensitive))
1891 return "AMD";
1892 if (output.contains("Intel", Qt::CaseInsensitive))
1893 return "Intel";
1894
1895 return "Unknown";
1896 }();
1897 return cached;
1898}
1899
1900void GameConfigDialog::updatePerfWrapperWarning()
1901{
1902 if (!perfWrapperWarning_)
1903 return;
1904
1905 // Show warning when both GameMode and game-performance are enabled
1906 bool bothEnabled = gameModeCheck_ && gameModeCheck_->isChecked() && gamePerformanceCheck_ &&
1907 gamePerformanceCheck_->isChecked();
1908 perfWrapperWarning_->setVisible(bothEnabled);
1909}
1910
1911void GameConfigDialog::updateRecommendationsBanner()
1912{
1913 // This method is kept for signal compatibility but the RecommendationsWidget
1914 // now handles its own display. The auto-preview is handled in the loadingComplete
1915 // lambda in setupPerformanceTab.
1916}
1917
1918void GameConfigDialog::showRecommendationPreview(const GameSuggestions& suggestions)
1919{
1920 if (!previewSettingsText_ || !previewTitleLabel_ || !previewComparisonLabel_)
1921 return;
1922
1923 const auto& c = themeManager_->colors();
1924
1925 previewTitleLabel_->setText("<b>Recommendation Preview</b>");
1926
1927 QString html;
1928 html += QString("<style>"
1929 "body { font-family: monospace; font-size: 11px; }"
1930 ".header { color: %1; font-weight: bold; margin-top: 8px; }"
1931 ".current { color: %2; }"
1932 ".new { color: %3; }"
1933 ".unchanged { color: %4; }"
1934 "</style>")
1935 .arg(c.accent.name(), c.textSecondary.name(), c.success.name(), c.textMuted.name());
1936
1937 int changesCount = 0;
1938
1939 // Environment variables section
1940 html += "<p class='header'>Environment Variables:</p>";
1941 for (const auto& suggestion : suggestions.suggestions)
1942 {
1943 if (suggestion.priority != SuggestionPriority::Critical &&
1944 suggestion.priority != SuggestionPriority::Recommended)
1945 continue;
1946
1947 if (!suggestion.envKey.empty() && !suggestion.envValue.empty())
1948 {
1949 QString key = QString::fromStdString(suggestion.envKey);
1950 QString value = QString::fromStdString(suggestion.envValue);
1951
1952 // Check current state
1953 bool currentlySet = false;
1954 if (key == "PROTON_USE_NTSYNC" && ntSyncCheck_)
1955 currentlySet = ntSyncCheck_->isChecked();
1956 else if (key == "WINEFSYNC" && fsyncCheck_)
1957 currentlySet = fsyncCheck_->isChecked();
1958 else if (key == "DXVK_ASYNC" && dxvkAsyncCheck_)
1959 currentlySet = dxvkAsyncCheck_->isChecked();
1960 else if (key == "MANGOHUD" && mangoHudCheck_)
1961 currentlySet = mangoHudCheck_->isChecked();
1962 // Check custom env vars
1963 else
1964 {
1965 for (int row = 0; row < envVarTable_->rowCount(); ++row)
1966 {
1967 if (envVarTable_->item(row, 0) && envVarTable_->item(row, 0)->text() == key)
1968 {
1969 currentlySet = (envVarTable_->item(row, 1)->text() == value);
1970 break;
1971 }
1972 }
1973 }
1974
1975 if (currentlySet)
1976 {
1977 html += QString("<p class='unchanged'>%1 %2=%3</p>")
1978 .arg(QString::fromUtf8("\xE2\x94\x80"), key.toHtmlEscaped(),
1979 value.toHtmlEscaped());
1980 }
1981 else
1982 {
1983 html += QString("<p class='new'>%1 %2=%3</p>")
1984 .arg(QString::fromUtf8("\xE2\x97\x8F"), key.toHtmlEscaped(),
1985 value.toHtmlEscaped());
1986 changesCount++;
1987 }
1988 }
1989 }
1990
1991 // Runner changes
1992 for (const auto& suggestion : suggestions.suggestions)
1993 {
1994 if (!suggestion.recommendedRunner.empty())
1995 {
1996 html += "<p class='header'>Runner:</p>";
1997 QString runner = QString::fromStdString(suggestion.recommendedRunner);
1998 QString current = runnerVersionCombo_->currentText();
1999
2000 if (current.contains(runner, Qt::CaseInsensitive))
2001 {
2002 html += QString("<p class='unchanged'>%1 %2</p>")
2003 .arg(QString::fromUtf8("\xE2\x94\x80"), runner);
2004 }
2005 else
2006 {
2007 html += QString("<p class='current'>%1 Current: %2</p>")
2008 .arg(QString::fromUtf8("\xE2\x97\x8B"),
2009 current.isEmpty() ? "(default)" : current);
2010 html += QString("<p class='new'>%1 New: %2</p>")
2011 .arg(QString::fromUtf8("\xE2\x97\x8F"), runner);
2012 changesCount++;
2013 }
2014 break;
2015 }
2016 }
2017
2018 // Summary
2019 if (changesCount > 0)
2020 {
2021 previewComparisonLabel_->setText(
2022 QString("<b>%1 change(s)</b> will be applied. Review above and click Apply to confirm.")
2023 .arg(changesCount));
2024 previewComparisonLabel_->setStyleSheet(
2025 QString("color: %1; font-size: 11px; padding: 4px;").arg(c.success.name()));
2026 }
2027 else
2028 {
2029 previewComparisonLabel_->setText("All recommended settings are already applied!");
2030 previewComparisonLabel_->setStyleSheet(
2031 QString("color: %1; font-size: 11px; padding: 4px;").arg(c.textSecondary.name()));
2032 }
2033
2034 previewSettingsText_->setHtml(html);
2035}
2036
2037void GameConfigDialog::showProfilePreview(const QString& profileId, bool isGlobal)
2038{
2039 if (!previewSettingsText_ || !previewTitleLabel_ || !profileService_)
2040 return;
2041
2042 const auto& c = themeManager_->colors();
2043
2044 std::optional<PerformanceProfile> profile;
2045 if (isGlobal)
2046 {
2047 auto globals = profileService_->getGlobalProfiles();
2048 for (const auto& p : globals)
2049 {
2050 if (p.id == profileId.toStdString())
2051 {
2052 profile = p;
2053 break;
2054 }
2055 }
2056 }
2057 else
2058 {
2059 profile = profileService_->getProfile(game_->id, profileId.toStdString());
2060 }
2061
2062 if (!profile)
2063 return;
2064
2065 previewTitleLabel_->setText(
2066 QString("<b>Profile: %1</b>").arg(QString::fromStdString(profile->name).toHtmlEscaped()));
2067
2068 QString html;
2069 html += QString("<style>"
2070 "body { font-family: monospace; font-size: 11px; }"
2071 ".header { color: %1; font-weight: bold; margin-top: 8px; }"
2072 ".setting { color: %2; }"
2073 ".desc { color: %3; font-style: italic; }"
2074 "</style>")
2075 .arg(c.accent.name(), c.textPrimary.name(), c.textSecondary.name());
2076
2077 // Description
2078 if (!profile->description.empty())
2079 {
2080 html += QString("<p class='desc'>%1</p>")
2081 .arg(QString::fromStdString(profile->description).toHtmlEscaped());
2082 }
2083
2084 // Sync settings
2085 html += "<p class='header'>Synchronization:</p>";
2086 if (profile->sync.enableNTSync)
2087 html += "<p class='setting'>• NTSync enabled</p>";
2088 else if (profile->sync.enableFsync)
2089 html += "<p class='setting'>• Fsync enabled</p>";
2090 else if (profile->sync.enableEsync)
2091 html += "<p class='setting'>• Esync enabled</p>";
2092
2093 // Wrappers
2094 html += "<p class='header'>Performance Wrappers:</p>";
2095 if (profile->wrappers.enableMangoHud)
2096 html += "<p class='setting'>• MangoHud overlay</p>";
2097 if (profile->wrappers.enableGameMode)
2098 html += "<p class='setting'>• GameMode</p>";
2099 if (profile->wrappers.enableGamePerformance)
2100 html += "<p class='setting'>• game-performance</p>";
2101 if (profile->wrappers.enableVkBasalt)
2102 html += "<p class='setting'>• VkBasalt</p>";
2103
2104 // Framerate
2105 if (profile->framerate.fpsLimit > 0 || profile->framerate.useGamescope)
2106 {
2107 html += "<p class='header'>Framerate:</p>";
2108 if (profile->framerate.fpsLimit > 0)
2109 html +=
2110 QString("<p class='setting'>• FPS Limit: %1</p>").arg(profile->framerate.fpsLimit);
2111 if (profile->framerate.useGamescope)
2112 html += "<p class='setting'>• Gamescope compositor</p>";
2113 }
2114
2115 // Environment variables
2116 if (!profile->environmentVariables.empty())
2117 {
2118 html += "<p class='header'>Environment Variables:</p>";
2119 for (const auto& [key, value] : profile->environmentVariables)
2120 {
2121 html += QString("<p class='setting'>• %1=%2</p>")
2122 .arg(QString::fromStdString(key).toHtmlEscaped(),
2123 QString::fromStdString(value).toHtmlEscaped());
2124 }
2125 }
2126
2127 previewComparisonLabel_->setText("Click 'Apply' to use this profile's settings.");
2128 previewComparisonLabel_->setStyleSheet(
2129 QString("color: %1; font-size: 11px; padding: 4px;").arg(c.textSecondary.name()));
2130
2131 previewSettingsText_->setHtml(html);
2132}
2133
2134void GameConfigDialog::onPresetChanged(int index)
2135{
2136 if (updatingPreset_)
2137 return;
2138
2139 ConfigPreset preset = static_cast<ConfigPreset>(presetCombo_->itemData(index).toInt());
2140 if (preset != ConfigPreset::Custom)
2141 {
2142 applyPreset(preset);
2143 }
2144}
2145
2146void GameConfigDialog::onAnySettingChanged()
2147{
2148 if (updatingPreset_)
2149 return;
2150
2151 // When user changes any setting, detect if it still matches a preset
2152 ConfigPreset detected = detectCurrentPreset();
2153 updatePresetComboSilently(detected);
2154 updateLaunchPreview();
2155}
2156
2157void GameConfigDialog::updateLaunchPreview()
2158{
2159 envVarsPreview_->setPlainText(buildEnvironmentString());
2160 commandPreview_->setPlainText(buildLaunchCommand());
2161}
2162
2163void GameConfigDialog::onBrowseExecutable()
2164{
2165 QString path =
2166 QFileDialog::getOpenFileName(this, "Select Game Executable", executableEdit_->text(),
2167 "Executables (*.exe *.sh *.AppImage *);;All Files (*)");
2168 if (!path.isEmpty())
2169 {
2170 executableEdit_->setText(path);
2171 updateLaunchPreview();
2172 }
2173}
2174
2175void GameConfigDialog::onBrowseWorkingDir()
2176{
2177 QString path = QFileDialog::getExistingDirectory(this, "Select Working Directory",
2178 workingDirEdit_->text());
2179 if (!path.isEmpty())
2180 {
2181 workingDirEdit_->setText(path);
2182 }
2183}
2184
2185void GameConfigDialog::onBrowseWinePrefix()
2186{
2187 QString path =
2188 QFileDialog::getExistingDirectory(this, "Select Wine Prefix", winePrefixEdit_->text());
2189 if (!path.isEmpty())
2190 {
2191 winePrefixEdit_->setText(path);
2192 }
2193}
2194
2195void GameConfigDialog::onAddEnvVar()
2196{
2197 int row = envVarTable_->rowCount();
2198 envVarTable_->insertRow(row);
2199 envVarTable_->setItem(row, 0, new QTableWidgetItem(""));
2200 envVarTable_->setItem(row, 1, new QTableWidgetItem(""));
2201 envVarTable_->editItem(envVarTable_->item(row, 0));
2202}
2203
2204void GameConfigDialog::onRemoveEnvVar()
2205{
2206 QList<QTableWidgetItem*> selected = envVarTable_->selectedItems();
2207 if (selected.isEmpty())
2208 return;
2209
2210 QSet<int> rows;
2211 for (QTableWidgetItem* item : selected)
2212 {
2213 rows.insert(item->row());
2214 }
2215
2216 QList<int> sortedRows = rows.values();
2217 std::sort(sortedRows.begin(), sortedRows.end(), std::greater<int>());
2218 for (int row : sortedRows)
2219 {
2220 envVarTable_->removeRow(row);
2221 }
2222
2223 updateLaunchPreview();
2224}
2225
2226void GameConfigDialog::onRunnerTypeChanged(int index)
2227{
2228 Q_UNUSED(index);
2229 updateLaunchPreview();
2230}
2231
2232void GameConfigDialog::onApply()
2233{
2234 saveToGame();
2235 // Steam's config.vdf (Proton version / launch options) is synced on the
2236 // next game launch by GameLaunchManager::checkAndSyncSettings().
2237}
2238
2239void GameConfigDialog::onAccept()
2240{
2241 saveToGame();
2242 // Steam config sync is deferred to launch time (see onApply / saveToGame).
2243 accept();
2244}
2245
2246// ==============================================================================
2247// Recommendations Integration (Unified)
2248// ==============================================================================
2249
2250void GameConfigDialog::onApplyRecommendations(const GameSuggestions& suggestions)
2251{
2252 int applied = 0;
2253 QStringList appliedItems;
2254
2255 // Apply each suggestion based on category
2256 for (const auto& suggestion : suggestions.suggestions)
2257 {
2258 // Only auto-apply Critical and Recommended priority
2259 if (suggestion.priority != SuggestionPriority::Critical &&
2260 suggestion.priority != SuggestionPriority::Recommended)
2261 {
2262 continue;
2263 }
2264
2265 // Apply environment variables
2266 if (!suggestion.envKey.empty() && !suggestion.envValue.empty())
2267 {
2268 QString key = QString::fromStdString(suggestion.envKey);
2269 QString value = QString::fromStdString(suggestion.envValue);
2270
2271 // Check if this maps to a known checkbox (null-check for GPU-specific options)
2272 bool handled = false;
2273
2274 if (key == "PROTON_USE_NTSYNC" && value == "1" && ntSyncCheck_)
2275 {
2276 ntSyncCheck_->setChecked(true);
2277 handled = true;
2278 }
2279 else if (key == "WINEFSYNC" && value == "1" && fsyncCheck_)
2280 {
2281 fsyncCheck_->setChecked(true);
2282 handled = true;
2283 }
2284 else if (key == "__GL_SHADER_DISK_CACHE" && value == "1" && localShaderCacheCheck_)
2285 {
2286 localShaderCacheCheck_->setChecked(true);
2287 handled = true;
2288 }
2289 else if (key == "DXVK_ASYNC" && value == "1" && dxvkAsyncCheck_)
2290 {
2291 dxvkAsyncCheck_->setChecked(true);
2292 handled = true;
2293 }
2294 else if (key == "MANGOHUD" && value == "1" && mangoHudCheck_)
2295 {
2296 mangoHudCheck_->setChecked(true);
2297 handled = true;
2298 }
2299 else if (key == "PROTON_ENABLE_HDR" && value == "1" && hdrCheck_)
2300 {
2301 hdrCheck_->setChecked(true);
2302 handled = true;
2303 }
2304 else if (key == "ENABLE_GAMESCOPE" && value == "1" && gamescopeCheck_)
2305 {
2306 gamescopeCheck_->setChecked(true);
2307 handled = true;
2308 }
2309 // FSR4 upgrades (AMD) - null-check
2310 else if (key == "PROTON_FSR4_UPGRADE" && value == "1" && fsr4UpgradeCheck_)
2311 {
2312 fsr4UpgradeCheck_->setChecked(true);
2313 handled = true;
2314 }
2315 else if (key == "PROTON_FSR4_RDNA3_UPGRADE" && value == "1" && fsr4Rdna3Check_)
2316 {
2317 fsr4Rdna3Check_->setChecked(true);
2318 handled = true;
2319 }
2320 // DLSS upgrades (NVIDIA) - null-check
2321 else if (key == "PROTON_DLSS_UPGRADE" && value == "1" && dlssUpgradeCheck_)
2322 {
2323 dlssUpgradeCheck_->setChecked(true);
2324 handled = true;
2325 }
2326 else if (key == "PROTON_DLSS_INDICATOR" && value == "1" && dlssIndicatorCheck_)
2327 {
2328 dlssIndicatorCheck_->setChecked(true);
2329 handled = true;
2330 }
2331 // NVIDIA libs - null-check
2332 else if ((key == "PROTON_FORCE_NVAPI" || key == "PROTON_NVIDIA_LIBS") && value == "1" &&
2333 nvidiaLibsCheck_)
2334 {
2335 nvidiaLibsCheck_->setChecked(true);
2336 handled = true;
2337 }
2338 // XeSS upgrade (Intel) - null-check
2339 else if (key == "PROTON_XESS_UPGRADE" && value == "1" && xessUpgradeCheck_)
2340 {
2341 xessUpgradeCheck_->setChecked(true);
2342 handled = true;
2343 }
2344 // Wine FSR (all GPUs) - null-check
2345 else if (key == "WINE_FULLSCREEN_FSR" && value == "1" && fsrCheck_)
2346 {
2347 fsrCheck_->setChecked(true);
2348 handled = true;
2349 }
2350 // Wayland
2351 else if (key == "PROTON_ENABLE_WAYLAND" && value == "1" && waylandCheck_)
2352 {
2353 waylandCheck_->setChecked(true);
2354 handled = true;
2355 }
2356
2357 // If not handled by a checkbox, add to custom env vars table
2358 if (!handled)
2359 {
2360 bool found = false;
2361 for (int row = 0; row < envVarTable_->rowCount(); ++row)
2362 {
2363 if (envVarTable_->item(row, 0) && envVarTable_->item(row, 0)->text() == key)
2364 {
2365 envVarTable_->item(row, 1)->setText(value);
2366 found = true;
2367 break;
2368 }
2369 }
2370 if (!found)
2371 {
2372 int row = envVarTable_->rowCount();
2373 envVarTable_->insertRow(row);
2374 envVarTable_->setItem(row, 0, new QTableWidgetItem(key));
2375 envVarTable_->setItem(row, 1, new QTableWidgetItem(value));
2376 }
2377 }
2378
2379 appliedItems << QString("%1=%2").arg(key, value);
2380 applied++;
2381 }
2382
2383 // Apply recommended runner
2384 if (!suggestion.recommendedRunner.empty())
2385 {
2386 QString runner = QString::fromStdString(suggestion.recommendedRunner);
2387
2388 // Set runner type based on runner name
2389 if (runner.contains("Proton", Qt::CaseInsensitive) ||
2390 runner.contains("GE-Proton", Qt::CaseInsensitive))
2391 {
2392 for (int i = 0; i < runnerTypeCombo_->count(); ++i)
2393 {
2394 if (runnerTypeCombo_->itemText(i).contains("Proton", Qt::CaseInsensitive))
2395 {
2396 runnerTypeCombo_->setCurrentIndex(i);
2397 break;
2398 }
2399 }
2400 }
2401 else if (runner.contains("Wine", Qt::CaseInsensitive))
2402 {
2403 for (int i = 0; i < runnerTypeCombo_->count(); ++i)
2404 {
2405 if (runnerTypeCombo_->itemText(i).contains("Wine", Qt::CaseInsensitive) &&
2406 !runnerTypeCombo_->itemText(i).contains("Proton", Qt::CaseInsensitive))
2407 {
2408 runnerTypeCombo_->setCurrentIndex(i);
2409 break;
2410 }
2411 }
2412 }
2413
2414 // Find and set the specific runner version
2415 int idx = runnerVersionCombo_->findText(runner, Qt::MatchExactly);
2416 if (idx < 0)
2417 idx = runnerVersionCombo_->findText(runner, Qt::MatchContains);
2418 if (idx >= 0)
2419 {
2420 runnerVersionCombo_->setCurrentIndex(idx);
2421 appliedItems << QString("Runner: %1").arg(runner);
2422 applied++;
2423 }
2424 else
2425 {
2426 runnerVersionCombo_->setCurrentText(runner);
2427 appliedItems << QString("Runner: %1 (custom)").arg(runner);
2428 applied++;
2429 }
2430 }
2431
2432 // Apply DLL overrides
2433 if (!suggestion.dllOverrides.empty())
2434 {
2435 QString current = wineDllEdit_->text();
2436 QString newOverrides = QString::fromStdString(suggestion.dllOverrides);
2437 if (current.isEmpty())
2438 wineDllEdit_->setText(newOverrides);
2439 else if (!current.contains(newOverrides))
2440 wineDllEdit_->setText(current + ";" + newOverrides);
2441 appliedItems << QString("DLL: %1").arg(newOverrides);
2442 applied++;
2443 }
2444
2445 // Apply launch arguments
2446 if (!suggestion.launchArgs.empty())
2447 {
2448 QString current = argumentsEdit_->text();
2449 QString newArgs = QString::fromStdString(suggestion.launchArgs);
2450 if (!current.contains(newArgs))
2451 {
2452 argumentsEdit_->setText(current.isEmpty() ? newArgs : current + " " + newArgs);
2453 appliedItems << QString("Args: %1").arg(newArgs);
2454 applied++;
2455 }
2456 }
2457
2458 // Apply performance wrappers based on category
2459 if (suggestion.category == SuggestionCategory::Performance)
2460 {
2461 QString title = QString::fromStdString(suggestion.title).toLower();
2462 if ((title.contains("gamemode") || title.contains("game mode")) && gameModeCheck_)
2463 {
2464 gameModeCheck_->setChecked(true);
2465 appliedItems << "GameMode enabled";
2466 applied++;
2467 }
2468 if (title.contains("mangohud") && mangoHudCheck_)
2469 {
2470 mangoHudCheck_->setChecked(true);
2471 appliedItems << "MangoHud enabled";
2472 applied++;
2473 }
2474 if ((title.contains("game-performance") || title.contains("cachyos")) &&
2475 gamePerformanceCheck_)
2476 {
2477 gamePerformanceCheck_->setChecked(true);
2478 appliedItems << "game-performance enabled";
2479 applied++;
2480 }
2481 }
2482 }
2483
2484 // For Steam games: when recommendations add custom env vars or wrappers,
2485 // disable "Use Steam defaults" so these settings get synced to Steam's VDF
2486 // launch options. Without this, Steam ignores our customizations because
2487 // the VDF sync is skipped when useSteamDefaults is true.
2488 if (applied > 0 && game_->source == GameSource::Steam && useSteamDefaultsCheck_)
2489 {
2490 if (useSteamDefaultsCheck_->isChecked())
2491 {
2492 useSteamDefaultsCheck_->setChecked(false);
2493 Logger::info("Auto-disabled 'Use Steam defaults' to apply recommended settings");
2494 }
2495 }
2496
2497 updateLaunchPreview();
2498
2499 // Show summary
2500 if (applied > 0)
2501 {
2502 QString summary = QString("Applied %1 recommendation(s):\n\n").arg(applied);
2503 if (!suggestions.protondbTier.empty())
2504 summary += QString("ProtonDB Rating: %1\n")
2505 .arg(QString::fromStdString(suggestions.protondbTier).toUpper());
2506 if (suggestions.isCachyOS)
2507 summary += "CachyOS optimizations included\n";
2508
2509 summary += "\nApplied settings:\n";
2510 for (const auto& item : appliedItems.mid(0, 10))
2511 summary += QString("• %1\n").arg(item);
2512 if (appliedItems.size() > 10)
2513 summary += QString("... and %1 more\n").arg(appliedItems.size() - 10);
2514
2515 summary += "\nReview the settings and click Apply or OK to save.";
2516 QMessageBox::information(this, "Recommendations Applied", summary);
2517 }
2518 else
2519 {
2520 QString msg = "No recommendations to apply.\n\n";
2521 if (!suggestions.protondbTier.empty())
2522 msg += QString("ProtonDB Rating: %1\n")
2523 .arg(QString::fromStdString(suggestions.protondbTier).toUpper());
2524 msg +=
2525 "This game may already have optimal settings,\nor no specific tweaks are known for it.";
2526 QMessageBox::information(this, "No Recommendations", msg);
2527 }
2528}
2529
2530// ==============================================================================
2531// Performance Profile Methods
2532// ==============================================================================
2533
2534void GameConfigDialog::refreshProfileList()
2535{
2536 if (!profileList_)
2537 return;
2538
2539 profileList_->clear();
2540
2541 if (!profileService_)
2542 {
2543 // Initialize the service if not done yet
2544 profileService_ = new PerformanceProfileService();
2545 std::string dataDir = QDir::homePath().toStdString() + "/.local/share/gamelauncher";
2546 profileService_->initialize(dataDir);
2547 }
2548
2549 // Get profiles for this game
2550 auto profiles = profileService_->getProfiles(game_->id);
2551
2552 // Also get global profiles
2553 auto globalProfiles = profileService_->getGlobalProfiles();
2554
2555 // Add global profiles first (with indicator)
2556 for (const auto& profile : globalProfiles)
2557 {
2558 QListWidgetItem* item = new QListWidgetItem(QString("\u25CF ") + // Global
2559 QString::fromStdString(profile.name));
2560 item->setData(Qt::UserRole, QString::fromStdString(profile.id));
2561 item->setData(Qt::UserRole + 1, true); // Is global
2562 item->setToolTip(QString::fromStdString(profile.description.empty()
2563 ? "Global profile (shared across games)"
2564 : profile.description));
2565 profileList_->addItem(item);
2566 }
2567
2568 // Add game-specific profiles
2569 for (const auto& profile : profiles)
2570 {
2571 QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(profile.name));
2572 item->setData(Qt::UserRole, QString::fromStdString(profile.id));
2573 item->setData(Qt::UserRole + 1, false); // Not global
2574 if (!profile.description.empty())
2575 item->setToolTip(QString::fromStdString(profile.description));
2576 profileList_->addItem(item);
2577 }
2578
2579 // Add empty state if no profiles exist
2580 if (profileList_->count() == 0)
2581 {
2582 const auto& c = themeManager_->colors();
2583 QListWidgetItem* emptyItem =
2584 new QListWidgetItem("No saved profiles yet. Use 'Save Current...' to create one.");
2585 emptyItem->setFlags(emptyItem->flags() & ~Qt::ItemIsSelectable);
2586 emptyItem->setForeground(c.textSecondary);
2587 emptyItem->setData(Qt::UserRole, QString()); // Empty ID indicates placeholder
2588 profileList_->addItem(emptyItem);
2589 }
2590
2591 // Update button states
2592 applyProfileBtn_->setEnabled(false);
2593}
2594
2595void GameConfigDialog::onProfileSelected(QListWidgetItem* current, QListWidgetItem* /* previous */)
2596{
2597 // Check if it's a valid profile (not the empty state placeholder)
2598 bool validProfile = current != nullptr && !current->data(Qt::UserRole).toString().isEmpty();
2599 applyProfileBtn_->setEnabled(validProfile);
2600
2601 // Show preview of the selected profile
2602 if (validProfile)
2603 {
2604 QString profileId = current->data(Qt::UserRole).toString();
2605 bool isGlobal = current->data(Qt::UserRole + 1).toBool();
2606 showProfilePreview(profileId, isGlobal);
2607 }
2608 else if (previewSettingsText_)
2609 {
2610 // Clear preview when no valid profile is selected
2611 previewSettingsText_->clear();
2612 }
2613}
2614
2615void GameConfigDialog::onApplyProfile()
2616{
2617 QListWidgetItem* currentItem = profileList_->currentItem();
2618 if (!currentItem || !profileService_)
2619 return;
2620
2621 QString profileId = currentItem->data(Qt::UserRole).toString();
2622 bool isGlobal = currentItem->data(Qt::UserRole + 1).toBool();
2623
2624 std::optional<PerformanceProfile> profile;
2625 if (isGlobal)
2626 {
2627 // Find in global profiles
2628 auto globals = profileService_->getGlobalProfiles();
2629 for (const auto& p : globals)
2630 {
2631 if (p.id == profileId.toStdString())
2632 {
2633 profile = p;
2634 break;
2635 }
2636 }
2637 }
2638 else
2639 {
2640 profile = profileService_->getProfile(game_->id, profileId.toStdString());
2641 }
2642
2643 if (!profile)
2644 return;
2645
2646 // Apply profile settings to the UI
2647 // Wrappers
2648 mangoHudCheck_->setChecked(profile->wrappers.enableMangoHud);
2649 gameModeCheck_->setChecked(profile->wrappers.enableGameMode);
2650 gamePerformanceCheck_->setChecked(profile->wrappers.enableGamePerformance);
2651 vkBasaltCheck_->setChecked(profile->wrappers.enableVkBasalt);
2652
2653 // Sync settings
2654 ntSyncCheck_->setChecked(profile->sync.enableNTSync);
2655 fsyncCheck_->setChecked(profile->sync.enableFsync);
2656
2657 // Environment variables from profile
2658 for (const auto& [key, value] : profile->environmentVariables)
2659 {
2660 // Update specific checkboxes
2661 if (key == "DXVK_ASYNC" && value == "1")
2662 dxvkAsyncCheck_->setChecked(true);
2663 else if (key == "PROTON_LOG" && value == "1")
2664 protonLogCheck_->setChecked(true);
2665 else if (key == "DXVK_HUD")
2666 dxvkHudCheck_->setChecked(true);
2667 }
2668
2669 // Update gamescope setting
2670 if (gamescopeCheck_)
2671 gamescopeCheck_->setChecked(profile->framerate.useGamescope);
2672
2673 updateLaunchPreview();
2674 updatePerfWrapperWarning();
2675
2676 QMessageBox::information(this, "Profile Applied",
2677 QString("Applied performance profile '%1'.\n\n"
2678 "Review the settings and click Apply or OK to save.")
2679 .arg(QString::fromStdString(profile->name)));
2680}
2681
2682void GameConfigDialog::onSaveAsProfile()
2683{
2684 if (!profileService_)
2685 {
2686 profileService_ = new PerformanceProfileService();
2687 std::string dataDir = QDir::homePath().toStdString() + "/.local/share/gamelauncher";
2688 profileService_->initialize(dataDir);
2689 }
2690
2691 bool ok;
2692 QString name = QInputDialog::getText(
2693 this, "Save Performance Profile",
2694 "Enter a name for this performance profile:", QLineEdit::Normal, "", &ok);
2695
2696 if (!ok || name.trimmed().isEmpty())
2697 return;
2698
2699 // Build a profile from current UI state
2700 PerformanceProfile profile;
2701 profile.name = name.trimmed().toStdString();
2702 profile.description = "Created from " + game_->name;
2703
2704 // Wrappers
2705 profile.wrappers.enableMangoHud = mangoHudCheck_->isChecked();
2706 profile.wrappers.enableGameMode = gameModeCheck_->isChecked();
2707 profile.wrappers.enableGamePerformance = gamePerformanceCheck_->isChecked();
2708 profile.wrappers.enableVkBasalt = vkBasaltCheck_->isChecked();
2709
2710 // Sync settings
2711 profile.sync.enableNTSync = ntSyncCheck_->isChecked();
2712 profile.sync.enableFsync = fsyncCheck_->isChecked();
2713 profile.sync.enableEsync = !ntSyncCheck_->isChecked() && !fsyncCheck_->isChecked();
2714
2715 // Environment variables
2716 if (dxvkAsyncCheck_->isChecked())
2717 profile.environmentVariables["DXVK_ASYNC"] = "1";
2718 if (protonLogCheck_->isChecked())
2719 profile.environmentVariables["PROTON_LOG"] = "1";
2720
2721 // Gamescope
2722 if (gamescopeCheck_ && gamescopeCheck_->isChecked())
2723 profile.framerate.useGamescope = true;
2724
2725 if (profileService_->createProfile(game_->id, profile))
2726 {
2727 refreshProfileList();
2728 QMessageBox::information(this, "Profile Saved",
2729 QString("Performance profile '%1' saved successfully.").arg(name));
2730 }
2731 else
2732 {
2733 QMessageBox::warning(this, "Error", "Failed to save performance profile.");
2734 }
2735}
2736
2737void GameConfigDialog::onManageProfiles()
2738{
2739 if (!profileService_)
2740 {
2741 profileService_ = new PerformanceProfileService();
2742 std::string dataDir = QDir::homePath().toStdString() + "/.local/share/gamelauncher";
2743 profileService_->initialize(dataDir);
2744 }
2745
2746 PerformanceProfileDialog dialog(game_, profileService_, this);
2747 dialog.exec();
2748 refreshProfileList();
2749}
void toggled(bool checked)
static bool isHandledEnvVar(const QString &key)
GameConfigDialog(Game *game, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
~GameConfigDialog() override
Complete representation of a game in the library.
Definition game.h:767
std::string name
Display name shown in UI.
Definition game.h:774
static void info(const std::string &message, Args &&... args)
Log info message (general information).
Definition logger.h:108
void applyRequested(const GameSuggestions &suggestions)
Emitted when user clicks "Apply Recommendations".
void loadingComplete(bool success)
Emitted when loading completes (async).
static bool writeSteamLaunchOptions(uint32_t appId, const std::string &launchOptions)
Write Steam launch options for a game to localconfig.vdf.
static std::string readSteamLaunchOptions(uint32_t appId)
Read Steam launch options for a game from localconfig.vdf.
static SystemInfoService & instance()
Get singleton instance.
const SystemCapabilities & getCapabilities()
Get complete system capabilities.
const GPUInfo & getGPUInfo()
Get full GPU information.
static QColor lightenColor(const QColor &color, int amount)
Lighten a color by increasing its lightness.
const ThemeColors & colors() const
Get effective colors (with accent customization applied).
GameSource
Where the game was acquired from (store/service/local).
Definition game.h:39
@ Steam
Steam store/platform.
Definition game.h:41
@ Local
Manually added game (not from a store).
Definition game.h:40
@ Itch
itch.io indie games
Definition game.h:44
@ Lutris
Lutris community scripts.
Definition game.h:45
@ GOG
GOG.com (DRM-free games).
Definition game.h:42
@ Epic
Epic Games Store.
Definition game.h:43
@ Proton
Proton (Steam's Wine fork).
Definition game.h:84
@ Native
Native Linux executable (no compatibility layer).
Definition game.h:82
@ Wine
Wine compatibility layer.
Definition game.h:83
static void applyAccentGroupStyle(QGroupBox *group, const ThemeColors &c, bool highlight=false)
ConfigPreset
bool useGamescope
Use Gamescope compositor.
Collection of suggestions for a game.
std::vector< GameSuggestion > suggestions
std::string description
Optional description.
std::map< std::string, std::string > environmentVariables
std::string name
Display name (e.g., "High Performance").
bool enableNTSync
Use NTSync (experimental, kernel 6.14+).
bool enableEsync
Use Esync if Fsync unavailable.
bool enableFsync
Use Fsync if available.
std::vector< RunnerInfo > runners
QColor panelBackground
QColor inputBackground
QColor borderLight
QColor cardBackground
QColor textSecondary
QColor textPrimary
QColor accentHover
QColor textMuted
QColor hoverBackground
QColor textOnAccent
bool enableGameMode
Feral GameMode.
bool enableVkBasalt
VkBasalt post-processing.
bool enableGamePerformance
CachyOS game-performance.
bool enableMangoHud
MangoHud overlay.