game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
settingsdialog.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// qt/settingsdialog.cpp
4// ==============================================================================
5// Settings dialog implementation
6// ==============================================================================
7
10#include "shortcut_manager.h"
11#include "theme_manager.h"
12
13#include <QApplication>
14#include <QColorDialog>
15#include <QDialogButtonBox>
16#include <QFileDialog>
17#include <QFont>
18#include <QFontComboBox>
19#include <QFormLayout>
20#include <QGraphicsDropShadowEffect>
21#include <QGroupBox>
22#include <QHBoxLayout>
23#include <QHeaderView>
24#include <QIcon>
25#include <QKeySequenceEdit>
26#include <QLabel>
27#include <QLineEdit>
28#include <QMessageBox>
29#include <QPushButton>
30#include <QScrollArea>
31#include <QSettings>
32#include <QSlider>
33#include <QSpinBox>
34#include <QStringList>
35#include <QTabWidget>
36#include <QTextEdit>
37#include <QTreeWidget>
38#include <QVBoxLayout>
39
40// ==============================================================================
41// Styling Helper - Consistent Group Box Visual Treatment
42// ==============================================================================
43
44static void applyGroupStyle(QGroupBox* group, const ThemeColors& c, bool highlight = false)
45{
46 if (highlight)
47 {
48 group->setStyleSheet(QString("QGroupBox {"
49 " font-weight: bold;"
50 " border: 1px solid %1;"
51 " border-left: 3px solid %1;"
52 " border-radius: 6px;"
53 " margin-top: 16px;"
54 " padding: 12px 8px 8px 8px;"
55 " color: %2;"
56 "}"
57 "QGroupBox::title {"
58 " subcontrol-origin: margin;"
59 " left: 12px;"
60 " padding: 0 6px;"
61 " color: %1;"
62 " font-weight: bold;"
63 "}"
64 "QCheckBox { color: %2; spacing: 8px; }"
65 "QRadioButton { color: %2; spacing: 8px; }"
66 "QLabel { color: %2; }")
67 .arg(c.accent.name(), c.textPrimary.name()));
68 }
69 else
70 {
71 // Non-highlighted groups: explicit title color for readability
72 group->setStyleSheet(QString("QGroupBox {"
73 " border: 1px solid %1;"
74 " border-left: 3px solid %2;"
75 " border-radius: 6px;"
76 " margin-top: 16px;"
77 " padding: 12px 8px 8px 8px;"
78 " color: %3;"
79 "}"
80 "QGroupBox::title {"
81 " subcontrol-origin: margin;"
82 " left: 12px;"
83 " padding: 0 6px;"
84 " color: %4;"
85 " font-weight: 600;"
86 "}"
87 "QCheckBox { color: %3; spacing: 8px; }"
88 "QRadioButton { color: %3; spacing: 8px; }"
89 "QLabel { color: %3; }")
90 .arg(c.borderLight.name(), c.textSecondary.name(),
91 c.textPrimary.name(), c.textPrimary.name()));
92 }
93}
94
96 ThemeManager* themeManager)
97 : QDialog(parent), controller_(controller),
98 themeManager_(themeManager ? themeManager : &ThemeManager::instance())
99{
100 // Save values that are applied immediately so Cancel can revert them
101 initialThemeId_ = themeManager_->currentThemeId();
102 {
103 QSettings s;
104 initialHamburgerState_ = s.value("ui/useHamburgerMenu", false).toBool();
105 }
106
107 setupUI();
108 loadSettings();
109 setWindowTitle("Application Settings");
110
111 // Calculate optimal size based on content
112 adjustSize();
113 QSize hint = sizeHint();
114
115 // Ensure minimum width to fit all 4 tabs without scrolling
116 int minWidth = qMax(hint.width(), 780);
117 int minHeight = qMax(hint.height(), 580);
118
119 // Set reasonable bounds
120 setMinimumSize(minWidth, minHeight);
121 resize(minWidth, minHeight);
122}
123
124void SettingsDialog::setupUI()
125{
126 const auto& c = themeManager_->colors();
127 QVBoxLayout* mainLayout = new QVBoxLayout(this);
128 mainLayout->setSpacing(12);
129
130 // Search field at the top
131 searchField_ = new QLineEdit(this);
132 searchField_->setPlaceholderText("Search settings...");
133 searchField_->setClearButtonEnabled(true);
134 searchField_->setStyleSheet(
135 QString("QLineEdit {"
136 " background-color: %1;"
137 " border: 1px solid %2;"
138 " border-radius: 6px;"
139 " padding: 6px 12px;"
140 " color: %3;"
141 " font-size: 13px;"
142 "}"
143 "QLineEdit:focus {"
144 " border-color: %4;"
145 "}")
146 .arg(c.inputBackground.name(), c.border.name(), c.textPrimary.name(), c.accent.name()));
147 mainLayout->addWidget(searchField_);
148
149 // Debounce timer for search
150 searchDebounceTimer_ = new QTimer(this);
151 searchDebounceTimer_->setSingleShot(true);
152 searchDebounceTimer_->setInterval(200);
153 connect(searchDebounceTimer_, &QTimer::timeout, this, &SettingsDialog::onSearchTextChanged);
154 connect(searchField_, &QLineEdit::textChanged, this,
155 [this]() { searchDebounceTimer_->start(); });
156
157 tabWidget_ = new QTabWidget(this);
158 QTabWidget* tabWidget = tabWidget_;
159
160 // Let global stylesheet handle tab styling — flat underline indicator
161 tabWidget->setStyleSheet(QString("QTabWidget::pane {"
162 " border: 1px solid %1;"
163 " border-top: none;"
164 " background: %2;"
165 "}")
166 .arg(c.borderLight.name(), c.panelBackground.name()));
167
168 // Create all tab widgets
169 QWidget* appearanceTab = new QWidget();
170 QWidget* generalTab = new QWidget();
171 QWidget* shortcutsTab = new QWidget();
172 QWidget* systemInfoTab = new QWidget();
173
174 // Setup each tab
175 setupAppearanceTab(appearanceTab);
176 setupBehaviorTab(generalTab);
177 setupKeyboardShortcutsTab(shortcutsTab);
178 setupSystemInfoTab(systemInfoTab);
179
180 // Add tabs with clear icons/labels
181 tabWidget->addTab(appearanceTab, "Appearance");
182 tabWidget->addTab(generalTab, "General");
183 tabWidget->addTab(shortcutsTab, "Shortcuts");
184 tabWidget->addTab(systemInfoTab, "System");
185
186 mainLayout->addWidget(tabWidget);
187
188 // Button box
189 QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
190
191 QPushButton* resetButton = new QPushButton("Reset to Defaults");
192 buttonBox->addButton(resetButton, QDialogButtonBox::ResetRole);
193 connect(resetButton, &QPushButton::clicked, this, &SettingsDialog::onReset);
194
195 buttonBox->addButton(QDialogButtonBox::Ok);
196 buttonBox->addButton(QDialogButtonBox::Cancel);
197 buttonBox->addButton(QDialogButtonBox::Apply);
198
199 // Style primary action buttons with accent color
200 auto styleAccentBtn = [&c](QPushButton* btn)
201 {
202 if (!btn)
203 return;
204 btn->setStyleSheet(QString("QPushButton { background-color: %1; color: %2; border: none; "
205 "border-radius: 6px; padding: 7px 20px; font-weight: bold; }"
206 "QPushButton:hover { background-color: %3; }"
207 "QPushButton:pressed { background-color: %4; }")
208 .arg(c.accent.name(), c.textOnAccent.name(), c.accentHover.name(),
209 c.accentPressed.name()));
210 };
211 styleAccentBtn(buttonBox->button(QDialogButtonBox::Ok));
212 styleAccentBtn(buttonBox->button(QDialogButtonBox::Apply));
213
214 // Style reset button as danger
215 if (resetButton)
216 {
217 resetButton->setStyleSheet(
218 QString("QPushButton { background-color: transparent; color: %1; border: 1px solid %1; "
219 "border-radius: 6px; padding: 7px 16px; }"
220 "QPushButton:hover { background-color: %1; color: %2; }")
221 .arg(c.error.name(), c.textOnAccent.name()));
222 }
223
224 connect(buttonBox, &QDialogButtonBox::accepted, this,
225 [this]()
226 {
227 saveSettings();
228 accept();
229 });
230 connect(buttonBox, &QDialogButtonBox::rejected, this,
231 [this]()
232 {
233 // Revert immediately-applied settings that were live-previewed
234 themeManager_->setTheme(initialThemeId_);
235 if (themeCombo_)
236 {
237 // Re-sync combo to reverted theme without re-triggering the apply
238 int idx = themeCombo_->findData(initialThemeId_);
239 if (idx >= 0)
240 {
241 QSignalBlocker blocker(themeCombo_);
242 themeCombo_->setCurrentIndex(idx);
243 }
244 }
245 {
246 QSettings s;
247 s.setValue("ui/useHamburgerMenu", initialHamburgerState_);
248 }
249 reject();
250 });
251 connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
252 &SettingsDialog::onApply);
253
254 mainLayout->addWidget(buttonBox);
255
256 // Collect all group boxes from all tabs for search filtering
257 for (int i = 0; i < tabWidget->count(); ++i)
258 {
259 QWidget* tab = tabWidget->widget(i);
260 QList<QGroupBox*> groups = tab->findChildren<QGroupBox*>();
261 for (QGroupBox* group : groups)
262 {
263 allGroupBoxes_.append(group);
264 groupBoxTabIndex_[group] = i;
265 }
266 }
267}
268
269void SettingsDialog::setupAppearanceTab(QWidget* tab)
270{
271 const auto& c = themeManager_->colors();
272 QVBoxLayout* layout = new QVBoxLayout(tab);
273 layout->setSpacing(16);
274
275 // Theme selection group
276 QGroupBox* themeGroup = new QGroupBox("Theme");
277 applyGroupStyle(themeGroup, c, true); // Highlighted - primary feature
278 QVBoxLayout* themeLayout = new QVBoxLayout(themeGroup);
279
280 QFormLayout* themeForm = new QFormLayout();
281 themeCombo_ = new QComboBox();
282
283 // Populate with available themes
284 const auto themeIds = themeManager_->getAvailableThemeIds();
285 for (const auto& id : themeIds)
286 {
287 const Theme* theme = themeManager_->getTheme(id);
288 if (theme)
289 {
290 themeCombo_->addItem(theme->displayName, theme->id);
291 }
292 }
293
294 themeForm->addRow("Theme Preset:", themeCombo_);
295 themeLayout->addLayout(themeForm);
296
297 // Connect theme change for live preview
298 connect(themeCombo_, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
299 [this](int index)
300 {
301 QString themeId = themeCombo_->itemData(index).toString();
302 themeManager_->setTheme(themeId);
303 });
304
305 layout->addWidget(themeGroup);
306
307 // Accent color group
308 QGroupBox* accentGroup = new QGroupBox("Accent Color");
309 applyGroupStyle(accentGroup, c, false);
310 QVBoxLayout* accentLayout = new QVBoxLayout(accentGroup);
311
312 QHBoxLayout* accentRow = new QHBoxLayout();
313
314 accentPreviewLabel_ = new QLabel();
315 accentPreviewLabel_->setFixedSize(32, 32);
316 accentPreviewLabel_->setFrameShape(QFrame::Box);
317 updateAccentPreview();
318
319 accentColorButton_ = new QPushButton("Choose Color...");
320 connect(accentColorButton_, &QPushButton::clicked, this,
321 [this]()
322 {
323 QColor currentAccent = themeManager_->colors().accent;
324 QColor newColor = QColorDialog::getColor(currentAccent, this, "Select Accent Color",
325 QColorDialog::ShowAlphaChannel);
326 if (newColor.isValid())
327 {
328 themeManager_->setAccentColor(newColor);
329 updateAccentPreview();
330 }
331 });
332
333 resetAccentButton_ = new QPushButton("Reset to Default");
334 connect(resetAccentButton_, &QPushButton::clicked, this,
335 [this]()
336 {
337 themeManager_->resetAccentToDefault();
338 updateAccentPreview();
339 });
340
341 accentRow->addWidget(accentPreviewLabel_);
342 accentRow->addWidget(accentColorButton_);
343 accentRow->addWidget(resetAccentButton_);
344 accentRow->addStretch();
345
346 accentLayout->addLayout(accentRow);
347
348 QLabel* accentNote =
349 new QLabel("The accent color is used for highlights, selection, and interactive elements.");
350 accentNote->setWordWrap(true);
351 accentNote->setStyleSheet(
352 QString("color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
353 accentLayout->addWidget(accentNote);
354
355 layout->addWidget(accentGroup);
356
357 // UI Scaling group
358 QGroupBox* scalingGroup = new QGroupBox("UI Scaling");
359 applyGroupStyle(scalingGroup, c, false);
360 QVBoxLayout* scalingLayout = new QVBoxLayout(scalingGroup);
361
362 // Zoom slider
363 QHBoxLayout* zoomRow = new QHBoxLayout();
364 QLabel* zoomLabel = new QLabel("Zoom:");
365 zoomSlider_ = new QSlider(Qt::Horizontal);
366 zoomSlider_->setRange(75, 150);
367 zoomSlider_->setSingleStep(5);
368 zoomSlider_->setPageStep(25);
369 zoomSlider_->setTickPosition(QSlider::TicksBelow);
370 zoomSlider_->setTickInterval(25);
371 zoomSlider_->setValue(themeManager_->zoomLevel());
372
373 zoomValueLabel_ = new QLabel(QString("%1%").arg(zoomSlider_->value()));
374 zoomValueLabel_->setFixedWidth(40);
375
376 // Connect zoom slider for live preview
377 connect(zoomSlider_, &QSlider::valueChanged, this,
378 [this](int value)
379 {
380 zoomValueLabel_->setText(QString("%1%").arg(value));
381 themeManager_->setZoomLevel(value);
382 });
383
384 zoomRow->addWidget(zoomLabel);
385 zoomRow->addWidget(zoomSlider_);
386 zoomRow->addWidget(zoomValueLabel_);
387 scalingLayout->addLayout(zoomRow);
388
389 // Font selection
390 QHBoxLayout* fontRow = new QHBoxLayout();
391 useSystemFontCheck_ = new QCheckBox("Use system font");
392 useSystemFontCheck_->setChecked(themeManager_->fontFamily().isEmpty());
393
394 fontCombo_ = new QFontComboBox();
395 fontCombo_->setCurrentFont(QFont(themeManager_->fontFamily().isEmpty()
396 ? QApplication::font().family()
397 : themeManager_->fontFamily()));
398 fontCombo_->setEnabled(!useSystemFontCheck_->isChecked());
399
400 // Connect font controls
401 connect(useSystemFontCheck_, &QCheckBox::toggled, this,
402 [this](bool checked)
403 {
404 fontCombo_->setEnabled(!checked);
405 if (checked)
406 {
407 themeManager_->setFontFamily(QString());
408 }
409 else
410 {
411 themeManager_->setFontFamily(fontCombo_->currentFont().family());
412 }
413 });
414
415 connect(fontCombo_, &QFontComboBox::currentFontChanged, this,
416 [this](const QFont& font)
417 {
418 if (!useSystemFontCheck_->isChecked())
419 {
420 themeManager_->setFontFamily(font.family());
421 }
422 });
423
424 fontRow->addWidget(useSystemFontCheck_);
425 fontRow->addWidget(fontCombo_);
426 fontRow->addStretch();
427 scalingLayout->addLayout(fontRow);
428
429 QLabel* scalingNote =
430 new QLabel("Zoom affects font sizes and spacing throughout the application. "
431 "Changes apply immediately.");
432 scalingNote->setWordWrap(true);
433 scalingNote->setStyleSheet(
434 QString("color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
435 scalingLayout->addWidget(scalingNote);
436
437 layout->addWidget(scalingGroup);
438
439 // Menu Style group
440 QGroupBox* menuGroup = new QGroupBox("Menu Style");
441 applyGroupStyle(menuGroup, c, false);
442 QVBoxLayout* menuLayout = new QVBoxLayout(menuGroup);
443
444 QCheckBox* hamburgerCheck = new QCheckBox("Use hamburger menu instead of menu bar");
445 QSettings menuSettings;
446 hamburgerCheck->setChecked(menuSettings.value("ui/useHamburgerMenu", false).toBool());
447 connect(hamburgerCheck, &QCheckBox::toggled, this,
448 [](bool checked)
449 {
450 QSettings s;
451 s.setValue("ui/useHamburgerMenu", checked);
452 });
453
454 QLabel* menuNote = new QLabel(
455 "When enabled, the traditional menu bar (File, Game, View, Tools, Help) is replaced "
456 "with a compact hamburger menu button in the toolbar.");
457 menuNote->setWordWrap(true);
458 menuNote->setStyleSheet(
459 QString("color: %1; font-size: 11px;").arg(themeManager_->colors().textSecondary.name()));
460
461 menuLayout->addWidget(hamburgerCheck);
462 menuLayout->addWidget(menuNote);
463 allGroupBoxes_.append(menuGroup);
464 groupBoxTabIndex_[menuGroup] = 0;
465 layout->addWidget(menuGroup);
466
467 layout->addStretch();
468}
469
470void SettingsDialog::updateAccentPreview()
471{
472 QColor accent = themeManager_->colors().accent;
473 accentPreviewLabel_->setStyleSheet(
474 QString("background-color: %1; border: 1px solid #555; border-radius: 4px;")
475 .arg(accent.name()));
476}
477
478void SettingsDialog::setupBehaviorTab(QWidget* tab)
479{
480 const auto& c = themeManager_->colors();
481
482 // Scroll area so all groups fit without clipping
483 QVBoxLayout* outerLayout = new QVBoxLayout(tab);
484 outerLayout->setContentsMargins(0, 0, 0, 0);
485 QScrollArea* scrollArea = new QScrollArea();
486 scrollArea->setWidgetResizable(true);
487 scrollArea->setFrameShape(QFrame::NoFrame);
488 QWidget* scrollContent = new QWidget();
489 QVBoxLayout* layout = new QVBoxLayout(scrollContent);
490 layout->setSpacing(16);
491 scrollArea->setWidget(scrollContent);
492 outerLayout->addWidget(scrollArea);
493
494 // Application settings group
495 QGroupBox* appGroup = new QGroupBox("Application Behavior");
496 applyGroupStyle(appGroup, c, false);
497 QVBoxLayout* appLayout = new QVBoxLayout(appGroup);
498 appLayout->setSpacing(8);
499
500 autoScanCheck_ = new QCheckBox("Auto-scan for new games on startup");
501 notificationsCheck_ = new QCheckBox("Show desktop notifications");
502 startMinimizedCheck_ = new QCheckBox("Start minimized to system tray");
503 minimizeToTrayCheck_ = new QCheckBox("Minimize to tray on close (uncheck to exit on close)");
504 confirmDeleteCheck_ = new QCheckBox("Confirm before deleting games");
505 showToolbarGameStatusCheck_ = new QCheckBox("Show running game status in toolbar");
506
507 appLayout->addWidget(autoScanCheck_);
508 appLayout->addWidget(notificationsCheck_);
509 appLayout->addWidget(startMinimizedCheck_);
510 appLayout->addWidget(minimizeToTrayCheck_);
511 appLayout->addWidget(confirmDeleteCheck_);
512 appLayout->addWidget(showToolbarGameStatusCheck_);
513
514 layout->addWidget(appGroup);
515
516 // Steam settings group
517 QGroupBox* steamGroup = new QGroupBox("Steam Integration");
518 applyGroupStyle(steamGroup, c, true); // Highlight - important section
519 QVBoxLayout* steamLayout = new QVBoxLayout(steamGroup);
520 steamLayout->setSpacing(8);
521
522 steamMinimizedCheck_ = new QCheckBox("Launch Steam minimized when starting Steam games");
523 autoApplyDefaultsCheck_ = new QCheckBox("Auto-apply default config to imported Steam games");
524
525 steamLayout->addWidget(steamMinimizedCheck_);
526 steamLayout->addWidget(autoApplyDefaultsCheck_);
527
528 layout->addWidget(steamGroup);
529
530 // Home Assistant panel group
531 QGroupBox* haGroup = new QGroupBox("Home Assistant Panel");
532 applyGroupStyle(haGroup, c, false);
533 QVBoxLayout* haLayout = new QVBoxLayout(haGroup);
534 haLayout->setSpacing(8);
535
536 enableHACheck_ = new QCheckBox("Enable Home Assistant panel");
537 enableHACheck_->setToolTip("Show the Home Assistant panel button in the toolbar");
538 haLayout->addWidget(enableHACheck_);
539
540 QFormLayout* haForm = new QFormLayout();
541 haUrlEdit_ = new QLineEdit();
542 haUrlEdit_->setPlaceholderText("http://homeassistant.local:8123");
543 haUrlEdit_->setToolTip("Your Home Assistant URL (leave empty to use the panel's saved URL)");
544 haForm->addRow("HA URL:", haUrlEdit_);
545 haLayout->addLayout(haForm);
546
547 // Enable/disable URL field based on checkbox
548 connect(enableHACheck_, &QCheckBox::toggled, haUrlEdit_, &QLineEdit::setEnabled);
549
550 layout->addWidget(haGroup);
551
552 // Default runner
553 QGroupBox* runnerGroup = new QGroupBox("Default Runner");
554 applyGroupStyle(runnerGroup, c, false);
555 QFormLayout* runnerLayout = new QFormLayout(runnerGroup);
556
557 defaultRunnerCombo_ = new QComboBox();
558 defaultRunnerCombo_->setEditable(true);
559 defaultRunnerCombo_->addItem("proton-cachyos-slr");
560 defaultRunnerCombo_->addItem("GE-Proton");
561 defaultRunnerCombo_->addItem("Proton Experimental");
562 defaultRunnerCombo_->addItem("Proton 9.0");
563
564 runnerLayout->addRow("Proton Version:", defaultRunnerCombo_);
565
566 layout->addWidget(runnerGroup);
567
568 // =========================================================================
569 // Gaming Mode section (merged from former Gaming Mode tab)
570 // =========================================================================
571
572 // Game Focus
573 QGroupBox* switchGroup = new QGroupBox("Game Focus");
574 applyGroupStyle(switchGroup, c, false);
575 QVBoxLayout* switchLayout = new QVBoxLayout(switchGroup);
576
577 autoSwitchToRunningGameCheck_ = new QCheckBox("Auto-switch to running game's details panel");
578 autoSwitchToRunningGameCheck_->setToolTip(
579 "When a game starts, automatically switch to its details panel to show frame metrics");
580 switchLayout->addWidget(autoSwitchToRunningGameCheck_);
581
582 layout->addWidget(switchGroup);
583
584 // Compact Gaming Layout
585 QGroupBox* gamingLayoutGroup = new QGroupBox("Compact Gaming Layout");
586 applyGroupStyle(gamingLayoutGroup, c, true);
587 QVBoxLayout* gamingLayout = new QVBoxLayout(gamingLayoutGroup);
588 gamingLayout->setSpacing(12);
589
590 autoGamingLayoutCheck_ = new QCheckBox("Enable compact gaming layout");
591 autoGamingLayoutCheck_->setToolTip(
592 "Automatically resize and position the window when a game starts");
593 QFont boldFont = autoGamingLayoutCheck_->font();
594 boldFont.setBold(true);
595 autoGamingLayoutCheck_->setFont(boldFont);
596 gamingLayout->addWidget(autoGamingLayoutCheck_);
597
598 QLabel* layoutDesc =
599 new QLabel("When enabled, the launcher window will resize and reposition to leave room "
600 "for your game and other monitoring tools.");
601 layoutDesc->setWordWrap(true);
602 layoutDesc->setStyleSheet(QString("color: %1; margin-left: 20px;").arg(c.textSecondary.name()));
603 gamingLayout->addWidget(layoutDesc);
604
605 QGroupBox* optionsBox = new QGroupBox("Layout Options");
606 optionsBox->setStyleSheet(QString("QGroupBox { border: none; margin-top: 8px; }"));
607 QFormLayout* optionsForm = new QFormLayout(optionsBox);
608 optionsForm->setContentsMargins(20, 8, 0, 0);
609
610 gamingLayoutWidthPercentSpin_ = new QSpinBox();
611 gamingLayoutWidthPercentSpin_->setRange(10, 50);
612 gamingLayoutWidthPercentSpin_->setSuffix("% of screen");
613 gamingLayoutWidthPercentSpin_->setToolTip("Window width as percentage of screen width");
614 optionsForm->addRow("Window Width:", gamingLayoutWidthPercentSpin_);
615
616 gamingLayoutEdgeCombo_ = new QComboBox();
617 gamingLayoutEdgeCombo_->addItem("Left edge", 0);
618 gamingLayoutEdgeCombo_->addItem("Right edge", 1);
619 gamingLayoutEdgeCombo_->addItem("Keep current position", 2);
620 gamingLayoutEdgeCombo_->setToolTip("Where to position the window during gaming mode");
621 optionsForm->addRow("Position:", gamingLayoutEdgeCombo_);
622
623 gamingLayoutFullHeightCheck_ = new QCheckBox("Use full screen height");
624 gamingLayoutFullHeightCheck_->setToolTip(
625 "Expand window to full screen height during gaming mode");
626 optionsForm->addRow("", gamingLayoutFullHeightCheck_);
627
628 gamingLayout->addWidget(optionsBox);
629
630 restoreLayoutOnExitCheck_ = new QCheckBox("Restore previous layout when game exits");
631 restoreLayoutOnExitCheck_->setToolTip(
632 "Return to normal window size/position after game closes");
633 restoreLayoutOnExitCheck_->setStyleSheet("margin-left: 20px;");
634 gamingLayout->addWidget(restoreLayoutOnExitCheck_);
635
636 connect(autoGamingLayoutCheck_, &QCheckBox::toggled, this,
637 [this](bool checked)
638 {
639 gamingLayoutWidthPercentSpin_->setEnabled(checked);
640 gamingLayoutEdgeCombo_->setEnabled(checked);
641 gamingLayoutFullHeightCheck_->setEnabled(checked);
642 restoreLayoutOnExitCheck_->setEnabled(checked);
643 });
644
645 layout->addWidget(gamingLayoutGroup);
646 layout->addStretch();
647}
648
649void SettingsDialog::setupGamingModeTab(QWidget* tab)
650{
651 Q_UNUSED(tab)
652}
653
654void SettingsDialog::loadSettings()
655{
656 const auto& app = controller_->getAppSettings();
657 // Appearance tab
658 QString currentTheme = themeManager_->currentThemeId();
659 int themeIndex = themeCombo_->findData(currentTheme);
660 if (themeIndex >= 0)
661 {
662 // Block signals to avoid triggering live preview during load
663 themeCombo_->blockSignals(true);
664 themeCombo_->setCurrentIndex(themeIndex);
665 themeCombo_->blockSignals(false);
666 }
667 updateAccentPreview();
668
669 // General tab
670 autoScanCheck_->setChecked(app.autoScan);
671 notificationsCheck_->setChecked(app.notifications);
672 startMinimizedCheck_->setChecked(app.startMinimized);
673 minimizeToTrayCheck_->setChecked(app.minimizeToTray);
674 confirmDeleteCheck_->setChecked(app.confirmDelete);
675 showToolbarGameStatusCheck_->setChecked(app.showToolbarGameStatus);
676 steamMinimizedCheck_->setChecked(app.steamMinimized);
677 autoApplyDefaultsCheck_->setChecked(app.autoApplyDefaults);
678 defaultRunnerCombo_->setCurrentText(QString::fromStdString(app.defaultRunner));
679
680 // Home Assistant
681 if (enableHACheck_)
682 {
683 enableHACheck_->setChecked(app.enableHomeAssistant);
684 haUrlEdit_->setText(QString::fromStdString(app.homeAssistantUrl));
685 haUrlEdit_->setEnabled(app.enableHomeAssistant);
686 }
687
688 // Gaming layout settings
689 autoSwitchToRunningGameCheck_->setChecked(app.autoSwitchToRunningGame);
690 autoGamingLayoutCheck_->setChecked(app.autoGamingLayout);
691 gamingLayoutWidthPercentSpin_->setValue(app.gamingLayoutWidthPercent);
692 gamingLayoutEdgeCombo_->setCurrentIndex(app.gamingLayoutEdge);
693 gamingLayoutFullHeightCheck_->setChecked(app.gamingLayoutFullHeight);
694 restoreLayoutOnExitCheck_->setChecked(app.restoreLayoutOnExit);
695
696 // Enable/disable layout controls based on autoGamingLayout
697 gamingLayoutWidthPercentSpin_->setEnabled(app.autoGamingLayout);
698 gamingLayoutEdgeCombo_->setEnabled(app.autoGamingLayout);
699 gamingLayoutFullHeightCheck_->setEnabled(app.autoGamingLayout);
700 restoreLayoutOnExitCheck_->setEnabled(app.autoGamingLayout);
701}
702
703void SettingsDialog::saveSettings()
704{
705 // Start with current settings to preserve fields not in this dialog
706 core::AppSettings app = controller_->getAppSettings();
707 app.autoScan = autoScanCheck_->isChecked();
708 app.notifications = notificationsCheck_->isChecked();
709 app.startMinimized = startMinimizedCheck_->isChecked();
710 app.minimizeToTray = minimizeToTrayCheck_->isChecked();
711 app.confirmDelete = confirmDeleteCheck_->isChecked();
712 app.showToolbarGameStatus = showToolbarGameStatusCheck_->isChecked();
713 app.steamMinimized = steamMinimizedCheck_->isChecked();
714 app.autoApplyDefaults = autoApplyDefaultsCheck_->isChecked();
715 app.defaultRunner = defaultRunnerCombo_->currentText().toStdString();
716
717 // Home Assistant
718 if (enableHACheck_)
719 {
720 app.enableHomeAssistant = enableHACheck_->isChecked();
721 app.homeAssistantUrl = haUrlEdit_->text().toStdString();
722 }
723
724 // Gaming layout settings
725 app.autoSwitchToRunningGame = autoSwitchToRunningGameCheck_->isChecked();
726 app.autoGamingLayout = autoGamingLayoutCheck_->isChecked();
727 app.gamingLayoutWidthPercent = gamingLayoutWidthPercentSpin_->value();
728 app.gamingLayoutEdge = gamingLayoutEdgeCombo_->currentData().toInt();
729 app.gamingLayoutFullHeight = gamingLayoutFullHeightCheck_->isChecked();
730 app.restoreLayoutOnExit = restoreLayoutOnExitCheck_->isChecked();
731
732 controller_->setAppSettings(app);
733
734 controller_->saveSettings();
735
736 // Theme settings are saved via ThemeManager (live preview already applied)
737 themeManager_->saveToSettings();
738
739 // Save keyboard shortcuts
741}
742
743void SettingsDialog::onApply()
744{
745 saveSettings();
746}
747
748void SettingsDialog::onReset()
749{
750 controller_->resetToDefaults();
751 loadSettings();
752}
753
754void SettingsDialog::setupKeyboardShortcutsTab(QWidget* tab)
755{
756 const auto& c = themeManager_->colors();
757 QVBoxLayout* layout = new QVBoxLayout(tab);
758 layout->setSpacing(12);
759
760 // Info label
761 QLabel* infoLabel =
762 new QLabel("Configure keyboard shortcuts. Select an action to edit its shortcut.");
763 infoLabel->setWordWrap(true);
764 infoLabel->setStyleSheet(QString("color: %1; padding: 8px; background: %2; border-radius: 6px;")
765 .arg(c.textSecondary.name(), c.cardBackground.name()));
766 layout->addWidget(infoLabel);
767
768 // Shortcuts tree widget
769 shortcutsTree_ = new QTreeWidget();
770 shortcutsTree_->setHeaderLabels({"Action", "Shortcut", "Default"});
771 shortcutsTree_->setColumnCount(3);
772 shortcutsTree_->setRootIsDecorated(true);
773 shortcutsTree_->setAlternatingRowColors(true);
774 shortcutsTree_->header()->setStretchLastSection(false);
775 shortcutsTree_->header()->setSectionResizeMode(0, QHeaderView::Stretch);
776 shortcutsTree_->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
777 shortcutsTree_->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
778 shortcutsTree_->setStyleSheet(QString("QTreeWidget {"
779 " border: 1px solid %1;"
780 " border-radius: 6px;"
781 "}")
782 .arg(c.border.name()));
783 layout->addWidget(shortcutsTree_, 1);
784
785 // Edit section
786 QGroupBox* editGroup = new QGroupBox("Edit Shortcut");
787 applyGroupStyle(editGroup, c, true); // Highlighted - main interaction area
788 QVBoxLayout* editLayout = new QVBoxLayout(editGroup);
789
790 QHBoxLayout* editRow = new QHBoxLayout();
791 QLabel* editLabel = new QLabel("New shortcut:");
792 shortcutEdit_ = new QKeySequenceEdit();
793 shortcutEdit_->setEnabled(false);
794 resetShortcutButton_ = new QPushButton("Reset");
795 resetShortcutButton_->setEnabled(false);
796 clearShortcutButton_ = new QPushButton("Clear");
797 clearShortcutButton_->setEnabled(false);
798
799 editRow->addWidget(editLabel);
800 editRow->addWidget(shortcutEdit_, 1);
801 editRow->addWidget(resetShortcutButton_);
802 editRow->addWidget(clearShortcutButton_);
803 editLayout->addLayout(editRow);
804
805 conflictLabel_ = new QLabel();
806 conflictLabel_->setStyleSheet(
807 QString("color: %1; font-weight: bold;").arg(themeManager_->colors().error.name()));
808 conflictLabel_->setVisible(false);
809 editLayout->addWidget(conflictLabel_);
810
811 layout->addWidget(editGroup);
812
813 // Buttons row
814 QHBoxLayout* buttonsRow = new QHBoxLayout();
815 QPushButton* resetAllButton = new QPushButton("Reset All to Defaults");
816 QPushButton* exportButton = new QPushButton("Export...");
817 QPushButton* importButton = new QPushButton("Import...");
818
819 buttonsRow->addWidget(resetAllButton);
820 buttonsRow->addStretch();
821 buttonsRow->addWidget(exportButton);
822 buttonsRow->addWidget(importButton);
823 layout->addLayout(buttonsRow);
824
825 // Connect signals
826 connect(shortcutsTree_, &QTreeWidget::currentItemChanged, this,
827 [this](QTreeWidgetItem* current, QTreeWidgetItem* /* previous */)
828 {
829 if (!current || current->childCount() > 0)
830 {
831 // Category item selected or nothing
832 shortcutEdit_->setEnabled(false);
833 resetShortcutButton_->setEnabled(false);
834 clearShortcutButton_->setEnabled(false);
835 selectedActionId_.clear();
836 return;
837 }
838
839 selectedActionId_ = current->data(0, Qt::UserRole).toString();
840 const auto* action = ShortcutManager::instance().getAction(selectedActionId_);
841 if (action)
842 {
843 shortcutEdit_->setEnabled(true);
844 shortcutEdit_->setKeySequence(action->currentShortcut);
845 resetShortcutButton_->setEnabled(action->isCustomized());
846 clearShortcutButton_->setEnabled(!action->currentShortcut.isEmpty());
847 }
848 conflictLabel_->setVisible(false);
849 });
850
851 connect(shortcutEdit_, &QKeySequenceEdit::editingFinished, this,
852 &SettingsDialog::onShortcutEdited);
853
854 connect(resetShortcutButton_, &QPushButton::clicked, this, &SettingsDialog::onResetShortcut);
855
856 connect(clearShortcutButton_, &QPushButton::clicked, this,
857 [this]()
858 {
859 if (!selectedActionId_.isEmpty())
860 {
861 ShortcutManager::instance().setShortcut(selectedActionId_, QKeySequence());
862 shortcutEdit_->setKeySequence(QKeySequence());
863 clearShortcutButton_->setEnabled(false);
864 populateShortcutsList();
865 }
866 });
867
868 connect(resetAllButton, &QPushButton::clicked, this, &SettingsDialog::onResetAllShortcuts);
869 connect(exportButton, &QPushButton::clicked, this, &SettingsDialog::onExportShortcuts);
870 connect(importButton, &QPushButton::clicked, this, &SettingsDialog::onImportShortcuts);
871
872 // Populate the list
873 populateShortcutsList();
874}
875
876void SettingsDialog::populateShortcutsList()
877{
878 QString previousSelection = selectedActionId_;
879 shortcutsTree_->clear();
880
881 auto& manager = ShortcutManager::instance();
882 QStringList categories = manager.getCategories();
883
884 QMap<QString, QTreeWidgetItem*> categoryItems;
885
886 for (const QString& category : categories)
887 {
888 QTreeWidgetItem* catItem = new QTreeWidgetItem(shortcutsTree_);
889 catItem->setText(0, category);
890 catItem->setExpanded(true);
891 QFont font = catItem->font(0);
892 font.setBold(true);
893 catItem->setFont(0, font);
894 categoryItems[category] = catItem;
895 }
896
897 auto actions = manager.getAllActions();
898 for (const auto& action : actions)
899 {
900 QTreeWidgetItem* catItem = categoryItems.value(action.category);
901 if (!catItem)
902 continue;
903
904 QTreeWidgetItem* item = new QTreeWidgetItem(catItem);
905 item->setText(0, action.label);
906 item->setText(1, ShortcutManager::keySequenceToString(action.currentShortcut));
907 item->setText(2, ShortcutManager::keySequenceToString(action.defaultShortcut));
908 item->setData(0, Qt::UserRole, action.id);
909
910 // Highlight customized shortcuts
911 if (action.isCustomized())
912 {
913 item->setForeground(1, QBrush(themeManager_->colors().accent));
914 }
915
916 // Restore selection
917 if (action.id == previousSelection)
918 {
919 shortcutsTree_->setCurrentItem(item);
920 }
921 }
922}
923
924void SettingsDialog::onShortcutEdited()
925{
926 if (selectedActionId_.isEmpty())
927 return;
928
929 QKeySequence newSeq = shortcutEdit_->keySequence();
930 auto& manager = ShortcutManager::instance();
931
932 // Check for conflicts
933 QString conflict = manager.checkConflict(newSeq, selectedActionId_);
934 if (!conflict.isEmpty())
935 {
936 const auto* conflictAction = manager.getAction(conflict);
937 if (conflictAction)
938 {
939 conflictLabel_->setText(
940 QString("Conflict: Already assigned to \"%1\"").arg(conflictAction->label));
941 conflictLabel_->setVisible(true);
942 return;
943 }
944 }
945
946 conflictLabel_->setVisible(false);
947
948 if (manager.setShortcut(selectedActionId_, newSeq))
949 {
950 const auto* action = manager.getAction(selectedActionId_);
951 resetShortcutButton_->setEnabled(action && action->isCustomized());
952 clearShortcutButton_->setEnabled(!newSeq.isEmpty());
953 populateShortcutsList();
954 }
955}
956
957void SettingsDialog::onResetShortcut()
958{
959 if (selectedActionId_.isEmpty())
960 return;
961
962 ShortcutManager::instance().resetToDefault(selectedActionId_);
963 const auto* action = ShortcutManager::instance().getAction(selectedActionId_);
964 if (action)
965 {
966 shortcutEdit_->setKeySequence(action->currentShortcut);
967 resetShortcutButton_->setEnabled(false);
968 clearShortcutButton_->setEnabled(!action->currentShortcut.isEmpty());
969 }
970 conflictLabel_->setVisible(false);
971 populateShortcutsList();
972}
973
974void SettingsDialog::onResetAllShortcuts()
975{
976 QMessageBox::StandardButton reply = QMessageBox::question(
977 this, "Reset All Shortcuts", "Reset all keyboard shortcuts to their defaults?",
978 QMessageBox::Yes | QMessageBox::No);
979
980 if (reply == QMessageBox::Yes)
981 {
983 populateShortcutsList();
984 if (!selectedActionId_.isEmpty())
985 {
986 const auto* action = ShortcutManager::instance().getAction(selectedActionId_);
987 if (action)
988 {
989 shortcutEdit_->setKeySequence(action->currentShortcut);
990 resetShortcutButton_->setEnabled(false);
991 }
992 }
993 }
994}
995
996void SettingsDialog::onExportShortcuts()
997{
998 QString filePath = QFileDialog::getSaveFileName(this, "Export Keyboard Shortcuts",
999 "shortcuts.json", "JSON Files (*.json)");
1000
1001 if (filePath.isEmpty())
1002 return;
1003
1004 if (ShortcutManager::instance().exportToFile(filePath))
1005 {
1006 QMessageBox::information(this, "Export Complete",
1007 "Keyboard shortcuts exported successfully.");
1008 }
1009 else
1010 {
1011 QMessageBox::warning(this, "Export Failed", "Failed to export keyboard shortcuts.");
1012 }
1013}
1014
1015void SettingsDialog::onImportShortcuts()
1016{
1017 QString filePath = QFileDialog::getOpenFileName(this, "Import Keyboard Shortcuts", QString(),
1018 "JSON Files (*.json)");
1019
1020 if (filePath.isEmpty())
1021 return;
1022
1023 int imported = ShortcutManager::instance().importFromFile(filePath);
1024 if (imported > 0)
1025 {
1026 QMessageBox::information(this, "Import Complete",
1027 QString("Imported %1 keyboard shortcut(s).").arg(imported));
1028 populateShortcutsList();
1029 }
1030 else
1031 {
1032 QMessageBox::warning(this, "Import Failed",
1033 "No shortcuts were imported. Check the file format.");
1034 }
1035}
1036
1037void SettingsDialog::updateShortcutConflictWarning()
1038{
1039 // This is called when editing to check for conflicts
1040 // Already handled in onShortcutEdited
1041}
1042
1043void SettingsDialog::setupSystemInfoTab(QWidget* tab)
1044{
1045 const auto& c = themeManager_->colors();
1046 QVBoxLayout* layout = new QVBoxLayout(tab);
1047 layout->setSpacing(12);
1048
1049 // Header with info and refresh button
1050 QHBoxLayout* headerLayout = new QHBoxLayout();
1051 QLabel* headerLabel = new QLabel("System capabilities and gaming readiness overview.");
1052 headerLabel->setStyleSheet(QString("color: %1;").arg(c.textSecondary.name()));
1053
1054 refreshSystemInfoButton_ = new QPushButton("Refresh");
1055 refreshSystemInfoButton_->setIcon(QIcon::fromTheme("view-refresh"));
1056 refreshSystemInfoButton_->setStyleSheet(
1057 QString("QPushButton {"
1058 " background: %1;"
1059 " color: %2;"
1060 " border: 1px solid %3;"
1061 " border-radius: 4px;"
1062 " padding: 6px 16px;"
1063 "}"
1064 "QPushButton:hover {"
1065 " background: %4;"
1066 "}")
1067 .arg(c.accent.name(), c.textOnAccent.name(), c.accent.name(), c.accentHover.name()));
1068 connect(refreshSystemInfoButton_, &QPushButton::clicked, this,
1069 &SettingsDialog::onRefreshSystemInfo);
1070
1071 headerLayout->addWidget(headerLabel);
1072 headerLayout->addStretch();
1073 headerLayout->addWidget(refreshSystemInfoButton_);
1074 layout->addLayout(headerLayout);
1075
1076 // System info text area
1077 systemInfoText_ = new QTextEdit();
1078 systemInfoText_->setReadOnly(true);
1079 systemInfoText_->setFont(QFont("monospace", themeManager_->scaledFontSize(9)));
1080 systemInfoText_->setStyleSheet(QString("QTextEdit {"
1081 " border: 1px solid %1;"
1082 " border-radius: 6px;"
1083 " background: %2;"
1084 " padding: 8px;"
1085 "}")
1086 .arg(c.border.name(), c.cardBackground.name()));
1087 layout->addWidget(systemInfoText_);
1088
1089 // Populate initial data
1090 refreshSystemInfo();
1091}
1092
1093void SettingsDialog::onRefreshSystemInfo()
1094{
1095 // Force refresh of system info
1097 refreshSystemInfo();
1098}
1099
1100void SettingsDialog::refreshSystemInfo()
1101{
1102 const auto& sys = SystemInfoService::instance().getCapabilities();
1103 QString info;
1104
1105 // Helper for status indicators
1106 auto statusIcon = [](bool ok)
1107 { return ok ? QString::fromUtf8("\u2713") : QString::fromUtf8("\u2717"); };
1108 auto yesNo = [](bool val) { return val ? "Yes" : "No"; };
1109
1110 // ===== GPU Section =====
1111 info += "=== GPU ===\n";
1112 info += QString(" Model: %1\n").arg(QString::fromStdString(sys.gpu.model));
1113 info += QString(" Vendor: %1\n").arg(QString::fromStdString(sys.gpu.vendorName));
1114 if (!sys.gpu.driverVersion.empty())
1115 {
1116 info +=
1117 QString(" Driver: %1\n").arg(QString::fromStdString(sys.gpu.driverVersion));
1118 }
1119 if (!sys.gpu.mesaVersion.empty())
1120 {
1121 info += QString(" Mesa: %1\n").arg(QString::fromStdString(sys.gpu.mesaVersion));
1122 }
1123 if (!sys.gpu.vulkanVersion.empty())
1124 {
1125 info +=
1126 QString(" Vulkan: %1\n").arg(QString::fromStdString(sys.gpu.vulkanVersion));
1127 }
1128 if (sys.gpu.vramMB > 0)
1129 {
1130 info += QString(" VRAM: %1 MB\n").arg(sys.gpu.vramMB);
1131 }
1132 info += QString(" Capabilities: ");
1133 QStringList gpuCaps;
1134 if (sys.gpu.supportsVulkan)
1135 gpuCaps << "Vulkan";
1136 if (sys.gpu.supportsRayTracing)
1137 gpuCaps << "Ray Tracing";
1138 if (sys.gpu.supportsFSR)
1139 gpuCaps << "FSR";
1140 if (sys.gpu.supportsFSR3)
1141 gpuCaps << "FSR3";
1142 if (sys.gpu.supportsDLSS)
1143 gpuCaps << "DLSS";
1144 if (sys.gpu.supportsDLSS3)
1145 gpuCaps << "DLSS3";
1146 if (sys.gpu.supportsXeSS)
1147 gpuCaps << "XeSS";
1148 if (sys.gpu.supportsHDR)
1149 gpuCaps << "HDR";
1150 info += gpuCaps.isEmpty() ? "None detected" : gpuCaps.join(", ");
1151 info += "\n\n";
1152
1153 // ===== CPU Section =====
1154 info += "=== CPU ===\n";
1155 info += QString(" Model: %1\n").arg(QString::fromStdString(sys.cpu.model));
1156 info += QString(" Cores/Threads: %1 / %2\n").arg(sys.cpu.coreCount).arg(sys.cpu.threadCount);
1157 if (sys.cpu.isHybrid)
1158 {
1159 info += QString(" Hybrid Cores: %1 P-cores, %2 E-cores\n")
1160 .arg(sys.cpu.performanceCores)
1161 .arg(sys.cpu.efficiencyCores);
1162 }
1163 if (sys.cpu.maxFrequencyMHz > 0)
1164 {
1165 info += QString(" Max Frequency: %.0f MHz\n").arg(sys.cpu.maxFrequencyMHz);
1166 }
1167 if (!sys.cpu.governor.empty())
1168 {
1169 info += QString(" Governor: %1 %2\n")
1170 .arg(QString::fromStdString(sys.cpu.governor))
1171 .arg(sys.cpu.hasOptimalGovernor() ? statusIcon(true) : statusIcon(false));
1172 }
1173 QString schedulerName;
1174 switch (sys.cpu.scheduler)
1175 {
1176 case CPUScheduler::BORE:
1177 schedulerName = "BORE (CachyOS)";
1178 break;
1180 schedulerName = "EEVDF";
1181 break;
1182 case CPUScheduler::CFS:
1183 schedulerName = "CFS";
1184 break;
1185 default:
1186 schedulerName = "Unknown";
1187 break;
1188 }
1189 info += QString(" Scheduler: %1\n\n").arg(schedulerName);
1190
1191 // ===== Memory Section =====
1192 info += "=== Memory ===\n";
1193 info += QString(" Total RAM: %1 MB (%2 GB)\n")
1194 .arg(sys.memory.totalMB)
1195 .arg(sys.memory.totalMB / 1024);
1196 info += QString(" Available: %1 MB (%.1f%% used)\n")
1197 .arg(sys.memory.availableMB)
1198 .arg(sys.memory.usagePercent());
1199 if (sys.memory.swapTotalMB > 0)
1200 {
1201 info += QString(" Swap: %1 MB total, %2 MB free\n")
1202 .arg(sys.memory.swapTotalMB)
1203 .arg(sys.memory.swapFreeMB);
1204 }
1205 else
1206 {
1207 info += QString(" Swap: None configured\n");
1208 }
1209 info += "\n";
1210
1211 // ===== Kernel Section =====
1212 info += "=== Kernel ===\n";
1213 info += QString(" Version: %1\n").arg(QString::fromStdString(sys.kernel.version));
1214 info += QString(" Distribution: %1\n").arg(QString::fromStdString(sys.kernel.distro));
1215 info += QString(" CachyOS: %1\n").arg(yesNo(sys.kernel.isCachyOS));
1216 info += QString(" Fsync: %1 %2\n")
1217 .arg(yesNo(sys.kernel.supportsFsync))
1218 .arg(statusIcon(sys.kernel.supportsFsync));
1219 info += QString(" NTSync: %1 (module: %2) %3\n")
1220 .arg(yesNo(sys.kernel.supportsNTSync))
1221 .arg(yesNo(sys.kernel.ntsyncModuleLoaded))
1222 .arg(statusIcon(sys.kernel.supportsNTSync && sys.kernel.ntsyncModuleLoaded));
1223 if (sys.kernel.maxMapCount > 0)
1224 {
1225 info += QString(" vm.max_map_count: %1 %2\n")
1226 .arg(sys.kernel.maxMapCount)
1227 .arg(statusIcon(sys.kernel.maxMapCountOk));
1228 }
1229 if (sys.kernel.swappiness >= 0)
1230 {
1231 info += QString(" vm.swappiness: %1 %2\n")
1232 .arg(sys.kernel.swappiness)
1233 .arg(statusIcon(sys.kernel.swappinessOk));
1234 }
1235 info += "\n";
1236
1237 // ===== Display Section =====
1238 info += "=== Display ===\n";
1239 QString displayServerStr;
1240 switch (sys.displayServer)
1241 {
1243 displayServerStr = "Wayland";
1244 break;
1245 case DisplayServer::X11:
1246 displayServerStr = "X11";
1247 break;
1248 default:
1249 displayServerStr = "Unknown";
1250 break;
1251 }
1252 info += QString(" Server: %1\n").arg(displayServerStr);
1253
1254 if (!sys.monitors.empty())
1255 {
1256 info += QString(" Monitors: %1\n").arg(sys.monitors.size());
1257 for (size_t i = 0; i < sys.monitors.size(); ++i)
1258 {
1259 const auto& mon = sys.monitors[i];
1260 info += QString(" [%1] %2 (%3)\n")
1261 .arg(i + 1)
1262 .arg(QString::fromStdString(mon.name.empty() ? mon.connector : mon.name))
1263 .arg(QString::fromStdString(mon.connector));
1264 info += QString(" %1x%2 @ %.0fHz")
1265 .arg(mon.widthPixels)
1266 .arg(mon.heightPixels)
1267 .arg(mon.refreshRate);
1268 QStringList monFlags;
1269 if (mon.isPrimary)
1270 monFlags << "Primary";
1271 if (mon.supportsVRR)
1272 monFlags << "VRR";
1273 if (mon.supportsHDR)
1274 monFlags << "HDR";
1275 if (!monFlags.isEmpty())
1276 {
1277 info += QString(" [%1]").arg(monFlags.join(", "));
1278 }
1279 info += "\n";
1280 }
1281 }
1282 else
1283 {
1284 info += " Monitors: None detected\n";
1285 }
1286 info += "\n";
1287
1288 // ===== Tools Section =====
1289 info += "=== Performance Tools ===\n";
1290 info += QString(" MangoHud: %1").arg(yesNo(sys.tools.mangoHud));
1291 if (!sys.tools.mangoHudVersion.empty())
1292 {
1293 info += QString(" (v%1)").arg(QString::fromStdString(sys.tools.mangoHudVersion));
1294 }
1295 info += "\n";
1296 info += QString(" GameMode: %1").arg(yesNo(sys.tools.gameMode));
1297 if (!sys.tools.gameModeVersion.empty())
1298 {
1299 info += QString(" (v%1)").arg(QString::fromStdString(sys.tools.gameModeVersion));
1300 }
1301 info += "\n";
1302 info += QString(" game-performance: %1\n").arg(yesNo(sys.tools.gamePerformance));
1303 info += QString(" Gamescope: %1\n").arg(yesNo(sys.tools.gamescope));
1304 info += QString(" vkBasalt: %1\n").arg(yesNo(sys.tools.vkBasalt));
1305 info += QString(" libstrangle: %1\n").arg(yesNo(sys.tools.strangle));
1306 info += "\n";
1307
1308 // ===== Storage Section =====
1309 if (!sys.storage.empty())
1310 {
1311 info += "=== Storage ===\n";
1312 for (const auto& store : sys.storage)
1313 {
1314 QString typeStr;
1315 switch (store.type)
1316 {
1317 case StorageType::NVMe:
1318 typeStr = "NVMe";
1319 break;
1320 case StorageType::SSD:
1321 typeStr = "SSD";
1322 break;
1323 case StorageType::HDD:
1324 typeStr = "HDD";
1325 break;
1326 default:
1327 typeStr = "Unknown";
1328 break;
1329 }
1330 info += QString(" %1\n").arg(QString::fromStdString(store.mountPoint));
1331 info += QString(" Device: %1 (%2)\n")
1332 .arg(QString::fromStdString(store.device))
1333 .arg(typeStr);
1334 info += QString(" Space: %1 GB free / %2 GB total\n")
1335 .arg(store.freeGB)
1336 .arg(store.totalGB);
1337 }
1338 info += "\n";
1339 }
1340
1341 // ===== Controllers Section =====
1342 if (!sys.controllers.empty())
1343 {
1344 info += "=== Controllers ===\n";
1345 for (const auto& ctrl : sys.controllers)
1346 {
1347 info += QString(" %1\n").arg(QString::fromStdString(ctrl.name));
1348 info += QString(" Type: %1%2\n")
1349 .arg(QString::fromStdString(ctrl.type))
1350 .arg(ctrl.isWireless ? " (wireless)" : "");
1351 }
1352 info += "\n";
1353 }
1354
1355 // ===== Power Section =====
1356 if (sys.power.isLaptop || sys.power.batteryPercent >= 0)
1357 {
1358 info += "=== Power ===\n";
1359 info += QString(" Type: %1\n").arg(sys.power.isLaptop ? "Laptop" : "Desktop");
1360 if (sys.power.batteryPercent >= 0)
1361 {
1362 info += QString(" Battery: %1%% %2\n")
1363 .arg(sys.power.batteryPercent)
1364 .arg(sys.power.onBattery ? "(discharging)" : "(charging/AC)");
1365 }
1366 if (!sys.power.activeProfile.empty())
1367 {
1368 info += QString(" Power Profile: %1\n")
1369 .arg(QString::fromStdString(sys.power.activeProfile));
1370 }
1371 info += "\n";
1372 }
1373
1374 // ===== Runners Section =====
1375 if (!sys.runners.empty())
1376 {
1377 info += "=== Installed Runners ===\n";
1378 for (const auto& runner : sys.runners)
1379 {
1380 info += QString(" %1\n").arg(QString::fromStdString(runner.name));
1381 info += QString(" Type: %1").arg(QString::fromStdString(runner.type));
1382 if (!runner.version.empty())
1383 {
1384 info += QString(" Version: %1").arg(QString::fromStdString(runner.version));
1385 }
1386 info += "\n";
1387 }
1388 info += "\n";
1389 }
1390
1391 // ===== Summary Section =====
1392 info += "=== Summary ===\n";
1393 info += QString(" Recommended Sync: %1\n")
1394 .arg(QString::fromStdString(sys.getRecommendedSyncMethod()));
1395 info += QString(" Optimal for Gaming: %1 %2\n")
1396 .arg(yesNo(sys.isOptimalForGaming()))
1397 .arg(statusIcon(sys.isOptimalForGaming()));
1398
1399 systemInfoText_->setPlainText(info);
1400}
1401
1402// ==============================================================================
1403// Settings Search/Filter
1404// ==============================================================================
1405
1406void SettingsDialog::onSearchTextChanged()
1407{
1408 filterSettings(searchField_->text());
1409}
1410
1411void SettingsDialog::filterSettings(const QString& searchText)
1412{
1413 if (!tabWidget_)
1414 return;
1415
1416 QString search = searchText.trimmed();
1417
1418 // If search is empty, show everything
1419 if (search.isEmpty())
1420 {
1421 for (QGroupBox* group : allGroupBoxes_)
1422 {
1423 group->setVisible(true);
1424 }
1425 for (int i = 0; i < tabWidget_->count(); ++i)
1426 {
1427 tabWidget_->setTabVisible(i, true);
1428 }
1429 return;
1430 }
1431
1432 // Track which tabs have visible groups
1433 QVector<bool> tabHasVisibleGroups(tabWidget_->count(), false);
1434
1435 for (QGroupBox* group : allGroupBoxes_)
1436 {
1437 bool matches = false;
1438
1439 // Check group box title
1440 if (group->title().contains(search, Qt::CaseInsensitive))
1441 {
1442 matches = true;
1443 }
1444
1445 // Check child widget text (QLabel, QCheckBox, QComboBox)
1446 if (!matches)
1447 {
1448 const auto labels = group->findChildren<QLabel*>();
1449 for (const QLabel* label : labels)
1450 {
1451 if (label->text().contains(search, Qt::CaseInsensitive))
1452 {
1453 matches = true;
1454 break;
1455 }
1456 }
1457 }
1458
1459 if (!matches)
1460 {
1461 const auto checkBoxes = group->findChildren<QCheckBox*>();
1462 for (const QCheckBox* cb : checkBoxes)
1463 {
1464 if (cb->text().contains(search, Qt::CaseInsensitive) ||
1465 cb->toolTip().contains(search, Qt::CaseInsensitive))
1466 {
1467 matches = true;
1468 break;
1469 }
1470 }
1471 }
1472
1473 if (!matches)
1474 {
1475 const auto comboBoxes = group->findChildren<QComboBox*>();
1476 for (const QComboBox* combo : comboBoxes)
1477 {
1478 for (int i = 0; i < combo->count(); ++i)
1479 {
1480 if (combo->itemText(i).contains(search, Qt::CaseInsensitive))
1481 {
1482 matches = true;
1483 break;
1484 }
1485 }
1486 if (matches)
1487 break;
1488 }
1489 }
1490
1491 group->setVisible(matches);
1492
1493 if (matches)
1494 {
1495 int tabIdx = groupBoxTabIndex_.value(group, -1);
1496 if (tabIdx >= 0 && tabIdx < tabHasVisibleGroups.size())
1497 {
1498 tabHasVisibleGroups[tabIdx] = true;
1499 }
1500 }
1501 }
1502
1503 // Show/hide tabs based on whether they have matching groups
1504 int firstVisibleTab = -1;
1505 for (int i = 0; i < tabWidget_->count(); ++i)
1506 {
1507 tabWidget_->setTabVisible(i, tabHasVisibleGroups[i]);
1508 if (tabHasVisibleGroups[i] && firstVisibleTab < 0)
1509 {
1510 firstVisibleTab = i;
1511 }
1512 }
1513
1514 // Auto-switch to the first tab with results
1515 if (firstVisibleTab >= 0)
1516 {
1517 tabWidget_->setCurrentIndex(firstVisibleTab);
1518 }
1519}
static void applyGroupStyle(QGroupBox *group, const ThemeColors &c, bool highlight=false)
SettingsDialog(core::SettingsController *controller, QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
void saveCustomizations()
Save custom shortcuts to settings.
bool setShortcut(const QString &actionId, const QKeySequence &shortcut)
Set a custom shortcut for an action.
void resetAllToDefaults()
Reset all shortcuts to defaults.
const ShortcutAction * getAction(const QString &actionId) const
Get an action by ID.
static ShortcutManager & instance()
Get singleton instance.
static QString keySequenceToString(const QKeySequence &seq)
Get display string for a key sequence.
void resetToDefault(const QString &actionId)
Reset an action to its default shortcut.
int importFromFile(const QString &filePath)
Import shortcuts from JSON file.
static SystemInfoService & instance()
Get singleton instance.
const SystemCapabilities & getCapabilities()
Get complete system capabilities.
void refresh()
Force refresh of all cached data.
const ThemeColors & colors() const
Get effective colors (with accent customization applied).
static void applyGroupStyle(QGroupBox *group, const ThemeColors &c, bool highlight=false)
QColor borderLight
QColor textSecondary
QColor textPrimary
QString displayName
QString id