161 const ThemeColors& c = impl_->themeManager->colors();
166 I.draggableToolbar =
new DraggableToolbar(I.mainWindow, impl_->themeManager);
168 QToolBar* toolBarContainer = I.mainWindow->addToolBar(
"Main Toolbar");
169 toolBarContainer->setMovable(
false);
170 toolBarContainer->setFloatable(
false);
171 toolBarContainer->setContextMenuPolicy(Qt::NoContextMenu);
172 toolBarContainer->addWidget(I.draggableToolbar);
176 QString(
"QComboBox { background-color: %1; color: %2; border: 1px solid %3; "
177 "border-radius: 3px; padding: 4px 8px; padding-right: 24px; min-width: 80px; }"
178 "QComboBox::drop-down { width: 20px; border-left: 1px solid %3; "
179 "border-top-right-radius: 3px; border-bottom-right-radius: 3px; }"
180 "QComboBox::down-arrow { border-left: 4px solid transparent; "
181 "border-right: 4px solid transparent; border-top: 5px solid %2; }"
182 "QComboBox:hover { border-color: %4; }"
183 "QComboBox QAbstractItemView { background-color: %1; color: %2; "
184 "selection-background-color: %4; border: 1px solid %3; }")
190 auto panelBtnStyle = [&c]()
192 return QString(
"QPushButton { background-color: transparent; color: %1; border: none; "
193 "border-radius: 3px; padding: 3px 8px; font-size: 12px; }"
194 "QPushButton:hover { background-color: %2; }"
195 "QPushButton:checked { background-color: %3; color: %4; }")
202 auto actionBtnStyle = [&c]()
204 return QString(
"QPushButton { background-color: transparent; color: %1; border: none; "
205 "border-radius: 3px; padding: 3px 8px; font-size: 12px; }"
206 "QPushButton:hover { background-color: %2; color: %3; }")
215 auto* menuSection = I.draggableToolbar->addSection(
"menu",
"Menu");
216 menuSection->setFixed(
true);
218 I.hamburgerBtn =
new QToolButton(I.mainWindow);
220 I.hamburgerBtn->setToolTip(
"Menu");
221 a11y::describe(I.hamburgerBtn, tr(
"Main menu"), tr(
"Open the application main menu"));
222 I.hamburgerBtn->setPopupMode(QToolButton::InstantPopup);
223 I.hamburgerBtn->setFixedSize(26, 26);
224 I.hamburgerBtn->setStyleSheet(
225 QString(
"QToolButton { background-color: transparent; color: %1; border: none; "
226 "border-radius: 3px; font-family: '%3'; font-size: %4px; }"
227 "QToolButton:hover { background-color: %2; }"
228 "QToolButton::menu-indicator { image: none; }")
230 .arg(impl_->themeManager->scaledFontSize(14)));
232 I.mainMenu =
new QMenu(I.hamburgerBtn);
233 impl_->themeManager->styleMenu(I.mainMenu);
235 QAction* addGameAction = I.mainMenu->addAction(
"\u002B Add Game...");
236 connect(addGameAction, &QAction::triggered,
this, [
this]() { emit
addGameRequested(); });
238 QAction* importGamesAction = I.mainMenu->addAction(
"\u21E9 Import Games...");
239 connect(importGamesAction, &QAction::triggered,
this,
242 QAction* installLutrisAction = I.mainMenu->addAction(
"\u2617 Install from Lutris...");
243 connect(installLutrisAction, &QAction::triggered,
this,
246 QAction* refreshAction = I.mainMenu->addAction(
"\u21BB Refresh Library");
249 I.mainMenu->addSeparator();
251 QAction* settingsAction = I.mainMenu->addAction(
"\u2699\ufe0f Settings...");
252 connect(settingsAction, &QAction::triggered,
this, [
this]() { emit
settingsRequested(); });
254 I.mainMenu->addSeparator();
257 QMenu* toolsSubmenu = I.mainMenu->addMenu(
"\u2699 Tools");
258 impl_->themeManager->styleMenu(toolsSubmenu);
260 QAction* manageRunnersAction = toolsSubmenu->addAction(
"\u25A3 Manage Runners...");
261 connect(manageRunnersAction, &QAction::triggered,
this,
264 QAction* systemInfoAction = toolsSubmenu->addAction(
"\u2261 System Info...");
265 connect(systemInfoAction, &QAction::triggered,
this,
272 : (sys.canUseFsync() ?
"Fsync"
273 : (sys.kernel.supportsEsync ?
"Esync" :
"None"));
274 QString info = QString(
"<h3>System Information</h3>"
276 "<tr><td><b>GPU:</b></td><td>%1</td></tr>"
277 "<tr><td><b>Vulkan:</b></td><td>%2</td></tr>"
278 "<tr><td><b>CPU:</b></td><td>%3 (%4 cores)</td></tr>"
279 "<tr><td><b>Sync Method:</b></td><td>%5</td></tr>"
280 "<tr><td><b>GameMode:</b></td><td>%6</td></tr>"
281 "<tr><td><b>MangoHud:</b></td><td>%7</td></tr>"
282 "<tr><td><b>Gamescope:</b></td><td>%8</td></tr>"
284 .arg(QString::fromStdString(sys.gpu.model))
285 .arg(sys.gpu.hasVulkanSupport() ?
"Available" :
"Not found")
286 .arg(QString::fromStdString(sys.cpu.model))
287 .arg(sys.cpu.coreCount)
289 .arg(sys.tools.gameMode ?
"Available" :
"Not installed")
290 .arg(sys.tools.mangoHud ?
"Available" :
"Not installed")
291 .arg(sys.tools.gamescope ?
"Available" :
"Not installed");
293 QMessageBox msgBox(impl_->mainWindow);
294 msgBox.setWindowTitle(
"System Information");
295 msgBox.setTextFormat(Qt::RichText);
296 msgBox.setText(info);
297 msgBox.setIcon(QMessageBox::Information);
301 toolsSubmenu->addSeparator();
303 QAction* libraryStatsAction = toolsSubmenu->addAction(
"\u25B2 Library Statistics...");
304 connect(libraryStatsAction, &QAction::triggered,
this,
307 QAction* exportImportAction = toolsSubmenu->addAction(
"\u21C5 Export/Import Library...");
308 connect(exportImportAction, &QAction::triggered,
this,
311 QAction* downloadQueueAction = toolsSubmenu->addAction(
"\u21E9 Download Queue...");
312 connect(downloadQueueAction, &QAction::triggered,
this,
315 I.mainMenu->addSeparator();
317 I.themeSubmenu = I.mainMenu->addMenu(
"\u25D0 Theme");
318 impl_->themeManager->styleMenu(I.themeSubmenu);
320 I.themeActionGroup =
new QActionGroup(
this);
321 I.themeActionGroup->setExclusive(
true);
322 QString currentThemeId = impl_->themeManager->currentThemeId();
324 for (
const auto& themeId : impl_->themeManager->getAvailableThemeIds())
326 const Theme* theme = impl_->themeManager->getTheme(themeId);
329 QAction* action = I.themeSubmenu->addAction(theme->
displayName);
330 action->setCheckable(
true);
331 action->setData(themeId);
332 action->setChecked(themeId == currentThemeId);
333 I.themeActionGroup->addAction(action);
336 connect(I.themeActionGroup, &QActionGroup::triggered,
this,
337 [
this](QAction* action) { emit themeSelected(action->data().toString()); });
339 I.mainMenu->addSeparator();
341 QAction* aboutAction = I.mainMenu->addAction(
"\u2139\ufe0f About");
342 connect(aboutAction, &QAction::triggered,
this,
345 QMessageBox::about(impl_->mainWindow,
"About Game Launcher",
346 "Game Launcher v1.0.0\n\n"
347 "A Linux game launcher with Steam integration.\n\n"
348 "Built with Qt and the core library.");
351 I.mainMenu->addSeparator();
353 QAction* exitAction = I.mainMenu->addAction(
"\u2715 Exit");
354 connect(exitAction, &QAction::triggered,
this, [
this]() { emit
exitRequested(); });
356 I.hamburgerBtn->setMenu(I.mainMenu);
357 menuSection->contentLayout()->addWidget(I.hamburgerBtn);
362 auto* panelsSection = I.draggableToolbar->addSection(
"panels",
"Panels");
363 auto panelSettings = I.settingsController->getAppSettings();
366 I.panelHABtn =
new QPushButton(
"Home Assistant", I.mainWindow);
368 I.panelHABtn->setCheckable(
true);
369 I.panelHABtn->setChecked(panelSettings.panelHAVisible);
370 I.panelHABtn->setToolTip(
"Toggle Home Assistant panel");
371 I.panelHABtn->setStyleSheet(panelBtnStyle());
372 connect(I.panelHABtn, &QPushButton::clicked,
this,
373 [
this]() { emit panelToggleRequested(QStringLiteral(
"ha")); });
374 panelsSection->contentLayout()->addWidget(I.panelHABtn);
375 if (!panelSettings.enableHomeAssistant)
376 I.panelHABtn->setVisible(
false);
379 I.panelSidebarBtn =
new QPushButton(
"Sidebar", I.mainWindow);
381 I.panelSidebarBtn->setCheckable(
true);
382 I.panelSidebarBtn->setChecked(panelSettings.panelSidebarVisible);
383 I.panelSidebarBtn->setToolTip(
"Toggle sidebar panel");
384 I.panelSidebarBtn->setStyleSheet(panelBtnStyle());
385 connect(I.panelSidebarBtn, &QPushButton::clicked,
this,
386 [
this]() { emit panelToggleRequested(QStringLiteral(
"sidebar")); });
387 panelsSection->contentLayout()->addWidget(I.panelSidebarBtn);
389 I.panelGamesBtn =
new QPushButton(
"Games", I.mainWindow);
391 I.panelGamesBtn->setCheckable(
true);
392 I.panelGamesBtn->setChecked(panelSettings.panelGamesVisible);
393 I.panelGamesBtn->setToolTip(
"Toggle games list panel");
394 I.panelGamesBtn->setStyleSheet(panelBtnStyle());
395 connect(I.panelGamesBtn, &QPushButton::clicked,
this,
396 [
this]() { emit panelToggleRequested(QStringLiteral(
"games")); });
397 panelsSection->contentLayout()->addWidget(I.panelGamesBtn);
399 I.panelDetailsBtn =
new QPushButton(
"Details", I.mainWindow);
401 I.panelDetailsBtn->setCheckable(
true);
402 I.panelDetailsBtn->setChecked(panelSettings.panelDetailsVisible);
403 I.panelDetailsBtn->setToolTip(
"Toggle game details panel");
404 I.panelDetailsBtn->setStyleSheet(panelBtnStyle());
405 connect(I.panelDetailsBtn, &QPushButton::clicked,
this,
406 [
this]() { emit panelToggleRequested(QStringLiteral(
"details")); });
407 panelsSection->contentLayout()->addWidget(I.panelDetailsBtn);
409#ifdef HAVE_QTERMWIDGET
410 I.panelMonitorBtn =
new QPushButton(
"Monitor", I.mainWindow);
412 I.panelMonitorBtn->setCheckable(
true);
413 I.panelMonitorBtn->setChecked(panelSettings.panelMonitorVisible);
414 I.panelMonitorBtn->setToolTip(
"Toggle system monitor panel");
415 I.panelMonitorBtn->setStyleSheet(panelBtnStyle());
416 connect(I.panelMonitorBtn, &QPushButton::clicked,
this,
417 [
this]() { emit panelToggleRequested(QStringLiteral(
"monitor")); });
418 panelsSection->contentLayout()->addWidget(I.panelMonitorBtn);
424 auto* gameControlsSection = I.draggableToolbar->addSection(
"gameControls",
"Game Controls");
426 int searchWidth = I.settingsController->getAppSettings().toolbarSearchWidth;
427 I.searchEdit =
new QLineEdit(I.mainWindow);
428 I.searchEdit->setPlaceholderText(
"Search games...");
429 I.searchEdit->setMinimumWidth(searchWidth);
430 I.searchEdit->setMaximumWidth(searchWidth);
431 I.searchEdit->setToolTip(
"Search games (Ctrl+F)");
432 I.searchEdit->setClearButtonEnabled(
true);
433 I.searchEdit->setStyleSheet(
434 QString(
"QLineEdit { background-color: %1; color: %2; border: 1px solid %3; "
435 "border-radius: 4px; padding: 4px 8px; }"
436 "QLineEdit:focus { border-color: %4; }")
443 I.searchDebounceTimer =
new QTimer(
this);
444 I.searchDebounceTimer->setSingleShot(
true);
445 connect(I.searchDebounceTimer, &QTimer::timeout,
this,
446 [
this]() { emit searchTextChanged(impl_->pendingSearchText); });
447 connect(I.searchEdit, &QLineEdit::textChanged,
this,
448 [
this](
const QString& text)
450 impl_->pendingSearchText = text;
451 impl_->searchDebounceTimer->start(200);
453 gameControlsSection->contentLayout()->addWidget(I.searchEdit);
457 I.searchDragHandle->setLeftWidgetConstraints(80, 300);
458 I.searchDragHandle->setToolTip(
"Drag to resize search field");
462 auto settings = impl_->settingsController->getAppSettings();
463 settings.toolbarSearchWidth = newWidth;
464 impl_->settingsController->setAppSettings(settings);
465 impl_->settingsController->saveSettings();
467 gameControlsSection->contentLayout()->addWidget(I.searchDragHandle);
469 I.sortCombo =
new QComboBox(I.mainWindow);
475 I.sortCombo->setToolTip(
"Sort order");
476 I.sortCombo->setStyleSheet(comboStyle);
477 connect(I.sortCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
478 [
this](
int index) { emit sortChanged(index); });
479 gameControlsSection->contentLayout()->addWidget(I.sortCombo);
483 gameControlsSection->contentLayout()->addWidget(sep1);
486 I.viewModeGroup =
new QActionGroup(
this);
487 I.viewModeGroup->setExclusive(
true);
489 QPushButton* listBtn =
new QPushButton(
"\u2630", I.mainWindow);
490 listBtn->setCheckable(
true);
491 listBtn->setChecked(
true);
492 listBtn->setToolTip(
"List View");
493 listBtn->setFixedSize(24, 24);
494 listBtn->setStyleSheet(panelBtnStyle());
496 QPushButton* gridBtn =
new QPushButton(
"\u25A6", I.mainWindow);
497 gridBtn->setCheckable(
true);
498 gridBtn->setToolTip(
"Grid View");
499 gridBtn->setFixedSize(24, 24);
500 gridBtn->setStyleSheet(panelBtnStyle());
502 QPushButton* compactBtn =
new QPushButton(
"\u2261", I.mainWindow);
503 compactBtn->setCheckable(
true);
504 compactBtn->setToolTip(
"Compact View");
505 compactBtn->setFixedSize(24, 24);
506 compactBtn->setStyleSheet(panelBtnStyle());
508 connect(listBtn, &QPushButton::clicked,
this,
509 [
this, listBtn, gridBtn, compactBtn]()
511 listBtn->setChecked(
true);
512 gridBtn->setChecked(
false);
513 compactBtn->setChecked(
false);
516 connect(gridBtn, &QPushButton::clicked,
this,
517 [
this, listBtn, gridBtn, compactBtn]()
519 listBtn->setChecked(
false);
520 gridBtn->setChecked(
true);
521 compactBtn->setChecked(
false);
524 connect(compactBtn, &QPushButton::clicked,
this,
525 [
this, listBtn, gridBtn, compactBtn]()
527 listBtn->setChecked(
false);
528 gridBtn->setChecked(
false);
529 compactBtn->setChecked(
true);
533 gameControlsSection->contentLayout()->addWidget(listBtn);
534 gameControlsSection->contentLayout()->addWidget(gridBtn);
535 gameControlsSection->contentLayout()->addWidget(compactBtn);
538 int zoomWidth = I.settingsController->getAppSettings().toolbarZoomWidth;
540 I.zoomDragHandle->setLeftWidgetConstraints(30, 100);
541 I.zoomDragHandle->setToolTip(
"Drag to resize zoom slider");
542 gameControlsSection->contentLayout()->addWidget(I.zoomDragHandle);
544 I.zoomSlider =
new QSlider(Qt::Horizontal, I.mainWindow);
545 I.zoomSlider->setRange(50, 200);
546 I.zoomSlider->setValue(100);
547 I.zoomSlider->setMinimumWidth(zoomWidth);
548 I.zoomSlider->setMaximumWidth(zoomWidth);
549 I.zoomSlider->setToolTip(
"Zoom (50-200%)");
550 I.zoomSlider->setStyleSheet(
551 QString(
"QSlider::groove:horizontal { background: %1; height: 4px; border-radius: 2px; }"
552 "QSlider::handle:horizontal { background: %2; width: 10px; margin: -3px 0; "
553 "border-radius: 5px; }")
558 I.zoomDebounceTimer =
new QTimer(
this);
559 I.zoomDebounceTimer->setSingleShot(
true);
560 I.zoomDebounceTimer->setInterval(150);
561 connect(I.zoomDebounceTimer, &QTimer::timeout,
this,
562 [
this]() { emit zoomChanged(impl_->zoomSlider->value()); });
563 connect(I.zoomSlider, &QSlider::valueChanged,
this,
566 if (impl_->zoomLabel)
567 impl_->zoomLabel->setText(QString(
"%1%").arg(value));
568 impl_->zoomDebounceTimer->start();
570 gameControlsSection->contentLayout()->addWidget(I.zoomSlider);
576 impl_->zoomSlider->setMinimumWidth(newWidth);
577 impl_->zoomSlider->setMaximumWidth(newWidth);
578 auto settings = impl_->settingsController->getAppSettings();
579 settings.toolbarZoomWidth = newWidth;
580 impl_->settingsController->setAppSettings(settings);
581 impl_->settingsController->saveSettings();
584 I.zoomLabel =
new QLabel(
"100%", I.mainWindow);
585 I.zoomLabel->setFixedWidth(30);
586 I.zoomLabel->setStyleSheet(QString(
"color: %1; font-size: 10px;").arg(c.
textMuted.name()));
587 gameControlsSection->contentLayout()->addWidget(I.zoomLabel);
590 I.listViewAction =
new QAction(
"List",
this);
591 I.listViewAction->setCheckable(
true);
592 I.listViewAction->setChecked(
true);
593 I.viewModeGroup->addAction(I.listViewAction);
594 I.gridViewAction =
new QAction(
"Grid",
this);
595 I.gridViewAction->setCheckable(
true);
596 I.viewModeGroup->addAction(I.gridViewAction);
597 I.compactViewAction =
new QAction(
"Compact",
this);
598 I.compactViewAction->setCheckable(
true);
599 I.viewModeGroup->addAction(I.compactViewAction);
601#ifdef HAVE_QTERMWIDGET
605 auto* monitorSection = I.draggableToolbar->addSection(
"monitor",
"Monitor");
606 monitorSection->setVisible(
false);
608 I.monitorTypeCombo =
new QComboBox(I.mainWindow);
609 I.monitorTypeCombo->addItem(
"btop++",
"btop");
610 I.monitorTypeCombo->addItem(
"htop",
"htop");
611 I.monitorTypeCombo->addItem(
"top",
"top");
615 QString userShell = QString::fromLocal8Bit(qgetenv(
"SHELL"));
616 if (userShell.isEmpty())
617 userShell = QStringLiteral(
"/bin/bash");
618 I.monitorTypeCombo->addItem(
"Shell", userShell);
620 I.monitorTypeCombo->setToolTip(
"Monitor type");
621 I.monitorTypeCombo->setStyleSheet(comboStyle);
622 connect(I.monitorTypeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
624 { emit monitorCommandRequested(Impl::monitorCommandForIndex(index)); });
625 monitorSection->contentLayout()->addWidget(I.monitorTypeCombo);
627 I.monitorRestartBtn =
new QPushButton(
"\u21BB", I.mainWindow);
628 I.monitorRestartBtn->setToolTip(
"Restart monitor");
629 I.monitorRestartBtn->setFixedSize(26, 26);
630 I.monitorRestartBtn->setStyleSheet(actionBtnStyle());
631 connect(I.monitorRestartBtn, &QPushButton::clicked,
this,
632 [
this]() { emit monitorRestartRequested(); });
633 monitorSection->contentLayout()->addWidget(I.monitorRestartBtn);
635 Q_UNUSED(actionBtnStyle);
641 auto* runningSection = I.draggableToolbar->addSection(
"running",
"Running");
642 runningSection->setVisible(
false);
646 [
this]() { emit runningGameDetailsRequested(); });
647 runningSection->contentLayout()->addWidget(I.runningGameStatusWidget);
650 I.draggableToolbar->addSpacer();
654 QString::fromStdString(I.settingsController->getAppSettings().toolbarSectionOrder);
655 if (!savedOrder.isEmpty())
657 I.draggableToolbar->setSectionOrder(savedOrder.split(
',', Qt::SkipEmptyParts));
659 I.draggableToolbar->setLocked(I.settingsController->getAppSettings().toolbarLocked);
662 [
this](
const QStringList& order)
664 auto settings = impl_->settingsController->getAppSettings();
665 settings.toolbarSectionOrder = order.join(
',').toStdString();
666 impl_->settingsController->setAppSettings(settings);
667 impl_->settingsController->saveSettings();
672 auto settings = impl_->settingsController->getAppSettings();
673 settings.toolbarLocked = locked;
674 impl_->settingsController->setAppSettings(settings);
675 impl_->settingsController->saveSettings();