From 5e1fc20276e8e3a8a26e59c481b249db9456891d Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 24 Feb 2022 09:10:00 -0500 Subject: [PATCH] Add option to close automatically when game is launched --- src/launchercore.cpp | 10 + src/launchercore.h | 8 + src/launcherwindow.cpp | 9 + src/settingswindow.cpp | 481 ++++++++++++++++++++++------------------- src/settingswindow.h | 3 + 5 files changed, 294 insertions(+), 217 deletions(-) diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 15b4e97..a5adc55 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -197,7 +197,14 @@ void LauncherCore::launchGame(const ProfileSettings& profile, const LoginAuth au arguments.append(argJoined); } + connect(gameProcess, QOverload::of(&QProcess::finished), + [=](int exitCode, QProcess::ExitStatus exitStatus){ + gameClosed(); + }); + launchExecutable(profile, gameProcess, arguments); + + successfulLaunch(); } void LauncherCore::launchExecutable(const ProfileSettings& profile, const QStringList args) { @@ -269,6 +276,8 @@ QString LauncherCore::readVersion(QString path) { void LauncherCore::readInitialInformation() { defaultProfileIndex = settings.value("defaultProfile", 0).toInt(); + appSettings.closeWhenLaunched = settings.value("closeWhenLaunched", true).toBool(); + gamescopeAvailable = checkIfInPath("gamescope"); gamemodeAvailable = checkIfInPath("gamemoderun"); @@ -512,6 +521,7 @@ int LauncherCore::deleteProfile(QString name) { void LauncherCore::saveSettings() { settings.setValue("defaultProfile", defaultProfileIndex); + settings.setValue("closeWhenLaunched", appSettings.closeWhenLaunched); for(int i = 0; i < profileSettings.size(); i++) { const auto& profile = profileSettings[i]; diff --git a/src/launchercore.h b/src/launchercore.h index b6f0bfc..c343a16 100755 --- a/src/launchercore.h +++ b/src/launchercore.h @@ -57,6 +57,10 @@ struct ProfileSettings { bool useSteam = false; }; +struct AppSettings { + bool closeWhenLaunched = true; +}; + struct LoginInformation { const ProfileSettings* settings = nullptr; @@ -112,9 +116,13 @@ public: bool gamescopeAvailable = false; bool gamemodeAvailable = false; + AppSettings appSettings; + int defaultProfileIndex = 0; signals: void settingsChanged(); + void successfulLaunch(); + void gameClosed(); private: void readExpansionVersions(ProfileSettings& info, int max); diff --git a/src/launcherwindow.cpp b/src/launcherwindow.cpp index 0b59586..4a74d72 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -146,6 +146,15 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo } }); + connect(&core, &LauncherCore::successfulLaunch, [&] { + hide(); + }); + + connect(&core, &LauncherCore::gameClosed, [&] { + if(core.appSettings.closeWhenLaunched) + QCoreApplication::quit(); + }); + reloadControls(); } diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index e190c41..8b9b1d1 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -26,308 +26,353 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg auto tabWidget = new QTabWidget(); mainLayout->addWidget(tabWidget); - auto profileTabWidget = new QWidget(); - tabWidget->addTab(profileTabWidget, "Profiles"); + // general tab + { + auto generalTabWidget = new QWidget(); + tabWidget->addTab(generalTabWidget, "General"); - auto profileLayout = new QGridLayout(); - profileTabWidget->setLayout(profileLayout); + auto layout = new QFormLayout(); + generalTabWidget->setLayout(layout); - profileWidget = new QListWidget(); - profileWidget->addItem("INVALID *DEBUG*"); - profileWidget->setCurrentRow(0); + closeWhenLaunched = new QCheckBox("Close Astra when game is launched"); + connect(closeWhenLaunched, &QCheckBox::stateChanged, [&](int state) { + core.appSettings.closeWhenLaunched = state; - connect(profileWidget, &QListWidget::currentRowChanged, this, &SettingsWindow::reloadControls); + core.saveSettings(); + }); + layout->addWidget(closeWhenLaunched); + } - profileLayout->addWidget(profileWidget, 0, 0, 0, 1); + // profile tab + { + auto profileTabWidget = new QWidget(); + tabWidget->addTab(profileTabWidget, "Profiles"); - auto addProfileButton = new QPushButton("Add Profile"); - connect(addProfileButton, &QPushButton::pressed, [=] { - profileWidget->setCurrentRow(this->core.addProfile()); + auto profileLayout = new QGridLayout(); + profileTabWidget->setLayout(profileLayout); - this->core.saveSettings(); - }); - profileLayout->addWidget(addProfileButton, 2, 0); + profileWidget = new QListWidget(); + profileWidget->addItem("INVALID *DEBUG*"); + profileWidget->setCurrentRow(0); - deleteProfileButton = new QPushButton("Delete Profile"); - connect(deleteProfileButton, &QPushButton::pressed, [=] { - profileWidget->setCurrentRow(this->core.deleteProfile(getCurrentProfile().name)); + connect(profileWidget, &QListWidget::currentRowChanged, this, + &SettingsWindow::reloadControls); - this->core.saveSettings(); - }); - profileLayout->addWidget(deleteProfileButton, 3, 0); + profileLayout->addWidget(profileWidget, 0, 0, 0, 1); - nameEdit = new QLineEdit(); - connect(nameEdit, &QLineEdit::editingFinished, [=] { - getCurrentProfile().name = nameEdit->text(); + auto addProfileButton = new QPushButton("Add Profile"); + connect(addProfileButton, &QPushButton::pressed, [=] { + profileWidget->setCurrentRow(this->core.addProfile()); - reloadControls(); - this->core.saveSettings(); - }); - profileLayout->addWidget(nameEdit, 0, 1); + this->core.saveSettings(); + }); + profileLayout->addWidget(addProfileButton, 2, 0); - auto gameBox = new QGroupBox("Game Options"); - auto gameBoxLayout = new QFormLayout(); - gameBox->setLayout(gameBoxLayout); + deleteProfileButton = new QPushButton("Delete Profile"); + connect(deleteProfileButton, &QPushButton::pressed, [=] { + profileWidget->setCurrentRow( + this->core.deleteProfile(getCurrentProfile().name)); - profileLayout->addWidget(gameBox, 1, 1); + this->core.saveSettings(); + }); + profileLayout->addWidget(deleteProfileButton, 3, 0); - directXCombo = new QComboBox(); - directXCombo->addItem("DirectX 11"); - directXCombo->addItem("DirectX 9"); - gameBoxLayout->addRow("DirectX Version", directXCombo); + nameEdit = new QLineEdit(); + connect(nameEdit, &QLineEdit::editingFinished, [=] { + getCurrentProfile().name = nameEdit->text(); - connect(directXCombo, static_cast(&QComboBox::currentIndexChanged), [=](int index) { - getCurrentProfile().useDX9 = directXCombo->currentIndex() == 1; - this->core.saveSettings(); - }); + reloadControls(); + this->core.saveSettings(); + }); + profileLayout->addWidget(nameEdit, 0, 1); - currentGameDirectory = new QLineEdit(); - currentGameDirectory->setReadOnly(true); - gameBoxLayout->addRow("Game Directory", currentGameDirectory); + auto gameBox = new QGroupBox("Game Options"); + auto gameBoxLayout = new QFormLayout(); + gameBox->setLayout(gameBoxLayout); - auto gameDirButtonLayout = new QHBoxLayout(); - auto gameDirButtonContainer = new QWidget(); - gameDirButtonContainer->setLayout(gameDirButtonLayout); - gameBoxLayout->addWidget(gameDirButtonContainer); + profileLayout->addWidget(gameBox, 1, 1); - auto selectDirectoryButton = new QPushButton("Select Game Directory"); - connect(selectDirectoryButton, &QPushButton::pressed, [this] { - getCurrentProfile().gamePath = QFileDialog::getExistingDirectory(this, "Open Game Directory"); + directXCombo = new QComboBox(); + directXCombo->addItem("DirectX 11"); + directXCombo->addItem("DirectX 9"); + gameBoxLayout->addRow("DirectX Version", directXCombo); - this->reloadControls(); - this->core.saveSettings(); + connect(directXCombo, + static_cast( + &QComboBox::currentIndexChanged), + [=](int index) { + getCurrentProfile().useDX9 = + directXCombo->currentIndex() == 1; + this->core.saveSettings(); + }); - this->core.readGameVersion(); - }); - gameDirButtonLayout->addWidget(selectDirectoryButton); + currentGameDirectory = new QLineEdit(); + currentGameDirectory->setReadOnly(true); + gameBoxLayout->addRow("Game Directory", currentGameDirectory); - auto gameDirectoryButton = new QPushButton("Open Game Directory"); - connect(gameDirectoryButton, &QPushButton::pressed, [this] { - openPath(getCurrentProfile().gamePath); - }); - gameDirButtonLayout->addWidget(gameDirectoryButton); + auto gameDirButtonLayout = new QHBoxLayout(); + auto gameDirButtonContainer = new QWidget(); + gameDirButtonContainer->setLayout(gameDirButtonLayout); + gameBoxLayout->addWidget(gameDirButtonContainer); + + auto selectDirectoryButton = new QPushButton("Select Game Directory"); + connect(selectDirectoryButton, &QPushButton::pressed, [this] { + getCurrentProfile().gamePath = + QFileDialog::getExistingDirectory(this, "Open Game Directory"); + + this->reloadControls(); + this->core.saveSettings(); + + this->core.readGameVersion(); + }); + gameDirButtonLayout->addWidget(selectDirectoryButton); + + auto gameDirectoryButton = new QPushButton("Open Game Directory"); + connect(gameDirectoryButton, &QPushButton::pressed, + [this] { openPath(getCurrentProfile().gamePath); }); + gameDirButtonLayout->addWidget(gameDirectoryButton); #ifdef ENABLE_WATCHDOG - enableWatchdog = new QCheckBox("Enable Watchdog (X11 only)"); - gameBoxLayout->addWidget(enableWatchdog); + enableWatchdog = new QCheckBox("Enable Watchdog (X11 only)"); + gameBoxLayout->addWidget(enableWatchdog); - connect(enableWatchdog, &QCheckBox::stateChanged, [this](int state) { - getCurrentProfile().enableWatchdog = state; + connect(enableWatchdog, &QCheckBox::stateChanged, [this](int state) { + getCurrentProfile().enableWatchdog = state; - this->core.saveSettings(); - }); + this->core.saveSettings(); + }); #endif - expansionVersionLabel = new QLabel(); - gameBoxLayout->addRow("Game Version", expansionVersionLabel); + expansionVersionLabel = new QLabel(); + gameBoxLayout->addRow("Game Version", expansionVersionLabel); - auto loginBox = new QGroupBox("Login Options"); - auto loginBoxLayout = new QFormLayout(); - loginBox->setLayout(loginBoxLayout); + auto loginBox = new QGroupBox("Login Options"); + auto loginBoxLayout = new QFormLayout(); + loginBox->setLayout(loginBoxLayout); - profileLayout->addWidget(loginBox, 2, 1); + profileLayout->addWidget(loginBox, 2, 1); - encryptArgumentsBox = new QCheckBox(); - connect(encryptArgumentsBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().encryptArguments = encryptArgumentsBox->isChecked(); + encryptArgumentsBox = new QCheckBox(); + connect(encryptArgumentsBox, &QCheckBox::stateChanged, [=](int) { + getCurrentProfile().encryptArguments = + encryptArgumentsBox->isChecked(); - this->core.saveSettings(); - }); - loginBoxLayout->addRow("Encrypt Game Arguments", encryptArgumentsBox); + this->core.saveSettings(); + }); + loginBoxLayout->addRow("Encrypt Game Arguments", encryptArgumentsBox); - serverType = new QComboBox(); - serverType->insertItem(0, "Square Enix"); - serverType->insertItem(1, "Sapphire"); + serverType = new QComboBox(); + serverType->insertItem(0, "Square Enix"); + serverType->insertItem(1, "Sapphire"); - connect(serverType, static_cast(&QComboBox::currentIndexChanged), [=](int index) { - getCurrentProfile().isSapphire = index == 1; + connect(serverType, + static_cast( + &QComboBox::currentIndexChanged), + [=](int index) { + getCurrentProfile().isSapphire = index == 1; - reloadControls(); - this->core.saveSettings(); - }); + reloadControls(); + this->core.saveSettings(); + }); - loginBoxLayout->addRow("Server Lobby", serverType); + loginBoxLayout->addRow("Server Lobby", serverType); - lobbyServerURL = new QLineEdit(); - connect(lobbyServerURL, &QLineEdit::editingFinished, [=] { - getCurrentProfile().lobbyURL = lobbyServerURL->text(); - this->core.saveSettings(); - }); - loginBoxLayout->addRow("Lobby URL", lobbyServerURL); + lobbyServerURL = new QLineEdit(); + connect(lobbyServerURL, &QLineEdit::editingFinished, [=] { + getCurrentProfile().lobbyURL = lobbyServerURL->text(); + this->core.saveSettings(); + }); + loginBoxLayout->addRow("Lobby URL", lobbyServerURL); - rememberUsernameBox = new QCheckBox(); - connect(rememberUsernameBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().rememberUsername = rememberUsernameBox->isChecked(); + rememberUsernameBox = new QCheckBox(); + connect(rememberUsernameBox, &QCheckBox::stateChanged, [=](int) { + getCurrentProfile().rememberUsername = + rememberUsernameBox->isChecked(); - this->core.saveSettings(); - }); - loginBoxLayout->addRow("Remember Username?", rememberUsernameBox); + this->core.saveSettings(); + }); + loginBoxLayout->addRow("Remember Username?", rememberUsernameBox); - rememberPasswordBox = new QCheckBox(); - connect(rememberPasswordBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().rememberPassword = rememberPasswordBox->isChecked(); + rememberPasswordBox = new QCheckBox(); + connect(rememberPasswordBox, &QCheckBox::stateChanged, [=](int) { + getCurrentProfile().rememberPassword = + rememberPasswordBox->isChecked(); - this->core.saveSettings(); - }); - loginBoxLayout->addRow("Remember Password?", rememberPasswordBox); + this->core.saveSettings(); + }); + loginBoxLayout->addRow("Remember Password?", rememberPasswordBox); - useSteamBox = new QCheckBox(); - connect(useSteamBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().useSteam = useSteamBox->isChecked(); + useSteamBox = new QCheckBox(); + connect(useSteamBox, &QCheckBox::stateChanged, [=](int) { + getCurrentProfile().useSteam = useSteamBox->isChecked(); - this->core.saveSettings(); - }); - loginBoxLayout->addRow("Use Steam?", useSteamBox); + this->core.saveSettings(); + }); + loginBoxLayout->addRow("Use Steam?", useSteamBox); #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) - auto wineBox = new QGroupBox("Wine Options"); - auto wineBoxLayout = new QFormLayout(); - wineBox->setLayout(wineBoxLayout); + auto wineBox = new QGroupBox("Wine Options"); + auto wineBoxLayout = new QFormLayout(); + wineBox->setLayout(wineBoxLayout); - profileLayout->addWidget(wineBox, 1, 2, 1, 1); + profileLayout->addWidget(wineBox, 1, 2, 1, 1); - winePathLabel = new QLineEdit(); - winePathLabel->setReadOnly(true); - wineBoxLayout->addRow("Wine Executable", winePathLabel); + winePathLabel = new QLineEdit(); + winePathLabel->setReadOnly(true); + wineBoxLayout->addRow("Wine Executable", winePathLabel); - wineVersionCombo = new QComboBox(); + wineVersionCombo = new QComboBox(); #if defined(Q_OS_MAC) - wineVersionCombo->insertItem(2, "FFXIV Built-In"); + wineVersionCombo->insertItem(2, "FFXIV Built-In"); #endif - wineVersionCombo->insertItem(0, "System Wine"); - wineVersionCombo->insertItem(1, "Custom Path..."); + wineVersionCombo->insertItem(0, "System Wine"); + wineVersionCombo->insertItem(1, "Custom Path..."); - wineBoxLayout->addWidget(wineVersionCombo); + wineBoxLayout->addWidget(wineVersionCombo); - selectWineButton = new QPushButton("Select Wine Executable"); - wineBoxLayout->addWidget(selectWineButton); + selectWineButton = new QPushButton("Select Wine Executable"); + wineBoxLayout->addWidget(selectWineButton); - connect(wineVersionCombo, static_cast(&QComboBox::currentIndexChanged), [this](int index) { - getCurrentProfile().wineVersion = index; + connect(wineVersionCombo, + static_cast( + &QComboBox::currentIndexChanged), + [this](int index) { + getCurrentProfile().wineVersion = index; - this->core.readWineInfo(getCurrentProfile()); - this->core.saveSettings(); - this->reloadControls(); - }); + this->core.readWineInfo(getCurrentProfile()); + this->core.saveSettings(); + this->reloadControls(); + }); - connect(selectWineButton, &QPushButton::pressed, [this] { - getCurrentProfile().winePath = QFileDialog::getOpenFileName(this, "Open Wine Executable"); + connect(selectWineButton, &QPushButton::pressed, [this] { + getCurrentProfile().winePath = + QFileDialog::getOpenFileName(this, "Open Wine Executable"); - this->core.saveSettings(); - this->reloadControls(); - }); + this->core.saveSettings(); + this->reloadControls(); + }); - winePrefixDirectory = new QLineEdit(); - winePrefixDirectory->setReadOnly(true); - wineBoxLayout->addRow("Wine Prefix", winePrefixDirectory); + winePrefixDirectory = new QLineEdit(); + winePrefixDirectory->setReadOnly(true); + wineBoxLayout->addRow("Wine Prefix", winePrefixDirectory); - auto winePrefixButtonLayout = new QHBoxLayout(); - auto winePrefixButtonContainer = new QWidget(); - winePrefixButtonContainer->setLayout(winePrefixButtonLayout); - wineBoxLayout->addWidget(winePrefixButtonContainer); + auto winePrefixButtonLayout = new QHBoxLayout(); + auto winePrefixButtonContainer = new QWidget(); + winePrefixButtonContainer->setLayout(winePrefixButtonLayout); + wineBoxLayout->addWidget(winePrefixButtonContainer); - auto selectPrefixButton = new QPushButton("Select Wine Prefix"); - connect(selectPrefixButton, &QPushButton::pressed, [this] { - getCurrentProfile().winePrefixPath = QFileDialog::getExistingDirectory(this, "Open Wine Prefix"); + auto selectPrefixButton = new QPushButton("Select Wine Prefix"); + connect(selectPrefixButton, &QPushButton::pressed, [this] { + getCurrentProfile().winePrefixPath = + QFileDialog::getExistingDirectory(this, "Open Wine Prefix"); - this->core.saveSettings(); - this->reloadControls(); - }); - winePrefixButtonLayout->addWidget(selectPrefixButton); + this->core.saveSettings(); + this->reloadControls(); + }); + winePrefixButtonLayout->addWidget(selectPrefixButton); - auto openPrefixButton = new QPushButton("Open Wine Prefix"); - connect(openPrefixButton, &QPushButton::pressed, [this] { - openPath(getCurrentProfile().winePrefixPath); - }); - winePrefixButtonLayout->addWidget(openPrefixButton); + auto openPrefixButton = new QPushButton("Open Wine Prefix"); + connect(openPrefixButton, &QPushButton::pressed, + [this] { openPath(getCurrentProfile().winePrefixPath); }); + winePrefixButtonLayout->addWidget(openPrefixButton); - auto enableDXVKhud = new QCheckBox("Enable DXVK HUD"); - wineBoxLayout->addRow("Wine Tweaks", enableDXVKhud); + auto enableDXVKhud = new QCheckBox("Enable DXVK HUD"); + wineBoxLayout->addRow("Wine Tweaks", enableDXVKhud); - connect(enableDXVKhud, &QCheckBox::stateChanged, [this](int state) { - getCurrentProfile().enableDXVKhud = state; - this->core.settings.setValue("enableDXVKhud", static_cast(state)); - }); + connect(enableDXVKhud, &QCheckBox::stateChanged, [this](int state) { + getCurrentProfile().enableDXVKhud = state; + this->core.settings.setValue("enableDXVKhud", + static_cast(state)); + }); #endif #if defined(Q_OS_LINUX) - useEsync = new QCheckBox("Use Better Sync Primitives (Esync, Fsync, and Futex2)"); - wineBoxLayout->addWidget(useEsync); + useEsync = new QCheckBox( + "Use Better Sync Primitives (Esync, Fsync, and Futex2)"); + wineBoxLayout->addWidget(useEsync); - auto esyncLabel = new QPushButton("?"); - connect(esyncLabel, &QPushButton::pressed, [esyncLabel] { - QToolTip::showText(esyncLabel->mapToGlobal(QPoint()), "This may improve game performance, but requires a Wine and kernel with the patches included."); - }); - wineBoxLayout->addWidget(esyncLabel); + auto esyncLabel = new QPushButton("?"); + connect(esyncLabel, &QPushButton::pressed, [esyncLabel] { + QToolTip::showText( + esyncLabel->mapToGlobal(QPoint()), + "This may improve game performance, but requires a Wine and kernel with the patches included."); + }); + wineBoxLayout->addWidget(esyncLabel); - connect(useEsync, &QCheckBox::stateChanged, [this](int state) { - getCurrentProfile().useEsync = state; + connect(useEsync, &QCheckBox::stateChanged, [this](int state) { + getCurrentProfile().useEsync = state; - this->core.saveSettings(); - }); + this->core.saveSettings(); + }); - useGamescope = new QCheckBox("Use Gamescope"); - wineBoxLayout->addWidget(useGamescope); + useGamescope = new QCheckBox("Use Gamescope"); + wineBoxLayout->addWidget(useGamescope); - auto gamescopeButtonLayout = new QHBoxLayout(); - auto gamescopeButtonContainer = new QWidget(); - gamescopeButtonContainer->setLayout(gamescopeButtonLayout); - wineBoxLayout->addWidget(gamescopeButtonContainer); + auto gamescopeButtonLayout = new QHBoxLayout(); + auto gamescopeButtonContainer = new QWidget(); + gamescopeButtonContainer->setLayout(gamescopeButtonLayout); + wineBoxLayout->addWidget(gamescopeButtonContainer); - auto gamescopeLabel = new QPushButton("?"); - connect(gamescopeLabel, &QPushButton::pressed, [gamescopeLabel] { - QToolTip::showText(gamescopeLabel->mapToGlobal(QPoint()), "Use the micro-compositor compositor that uses Wayland and XWayland to create a nested session.\nIf you primarily use fullscreen mode, this may improve input handling especially on Wayland."); - }); - gamescopeButtonLayout->addWidget(gamescopeLabel); + auto gamescopeLabel = new QPushButton("?"); + connect(gamescopeLabel, &QPushButton::pressed, [gamescopeLabel] { + QToolTip::showText( + gamescopeLabel->mapToGlobal(QPoint()), + "Use the micro-compositor compositor that uses Wayland and XWayland to create a nested session.\nIf you primarily use fullscreen mode, this may improve input handling especially on Wayland."); + }); + gamescopeButtonLayout->addWidget(gamescopeLabel); - configureGamescopeButton = new QPushButton("Configure..."); - connect(configureGamescopeButton, &QPushButton::pressed, [&] { - auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this->core, this); - gamescopeSettingsWindow->show(); - }); - gamescopeButtonLayout->addWidget(configureGamescopeButton); + configureGamescopeButton = new QPushButton("Configure..."); + connect(configureGamescopeButton, &QPushButton::pressed, [&] { + auto gamescopeSettingsWindow = new GamescopeSettingsWindow( + getCurrentProfile(), this->core, this); + gamescopeSettingsWindow->show(); + }); + gamescopeButtonLayout->addWidget(configureGamescopeButton); - connect(useGamescope, &QCheckBox::stateChanged, [this](int state) { - getCurrentProfile().useGamescope = state; + connect(useGamescope, &QCheckBox::stateChanged, [this](int state) { + getCurrentProfile().useGamescope = state; - this->core.saveSettings(); - this->reloadControls(); - }); + this->core.saveSettings(); + this->reloadControls(); + }); - useGamemode = new QCheckBox("Use GameMode"); - wineBoxLayout->addWidget(useGamemode); + useGamemode = new QCheckBox("Use GameMode"); + wineBoxLayout->addWidget(useGamemode); - auto gamemodeLabel = new QPushButton("?"); - connect(gamemodeLabel, &QPushButton::pressed, [gamemodeLabel] { - QToolTip::showText(gamemodeLabel->mapToGlobal(QPoint()), "A special game performance enhancer, which automatically tunes your CPU scheduler among other things. This may improve game performance."); - }); - wineBoxLayout->addWidget(gamemodeLabel); + auto gamemodeLabel = new QPushButton("?"); + connect(gamemodeLabel, &QPushButton::pressed, [gamemodeLabel] { + QToolTip::showText( + gamemodeLabel->mapToGlobal(QPoint()), + "A special game performance enhancer, which automatically tunes your CPU scheduler among other things. This may improve game performance."); + }); + wineBoxLayout->addWidget(gamemodeLabel); - connect(useGamemode, &QCheckBox::stateChanged, [this](int state) { - getCurrentProfile().useGamemode = state; + connect(useGamemode, &QCheckBox::stateChanged, [this](int state) { + getCurrentProfile().useGamemode = state; - this->core.saveSettings(); - }); + this->core.saveSettings(); + }); #endif - auto dalamudBox = new QGroupBox("Dalamud Options"); - auto dalamudBoxLayout = new QFormLayout(); - dalamudBox->setLayout(dalamudBoxLayout); + auto dalamudBox = new QGroupBox("Dalamud Options"); + auto dalamudBoxLayout = new QFormLayout(); + dalamudBox->setLayout(dalamudBoxLayout); - profileLayout->addWidget(dalamudBox, 2, 2, 1, 1); + profileLayout->addWidget(dalamudBox, 2, 2, 1, 1); - enableDalamudBox = new QCheckBox(); - connect(enableDalamudBox, &QCheckBox::stateChanged, [=](int) { - getCurrentProfile().enableDalamud = enableDalamudBox->isChecked(); + enableDalamudBox = new QCheckBox(); + connect(enableDalamudBox, &QCheckBox::stateChanged, [=](int) { + getCurrentProfile().enableDalamud = enableDalamudBox->isChecked(); - this->core.saveSettings(); - }); - dalamudBoxLayout->addRow("Enable Dalamud Injection", enableDalamudBox); + this->core.saveSettings(); + }); + dalamudBoxLayout->addRow("Enable Dalamud Injection", enableDalamudBox); - dalamudVersionLabel = new QLabel(); - dalamudBoxLayout->addRow("Dalamud Version", dalamudVersionLabel); + dalamudVersionLabel = new QLabel(); + dalamudBoxLayout->addRow("Dalamud Version", dalamudVersionLabel); + } reloadControls(); } @@ -347,6 +392,8 @@ void SettingsWindow::reloadControls() { } profileWidget->setCurrentRow(oldRow); + closeWhenLaunched->setChecked(core.appSettings.closeWhenLaunched); + // deleting the main profile is unsupported behavior deleteProfileButton->setEnabled(core.profileList().size() > 1); diff --git a/src/settingswindow.h b/src/settingswindow.h index ff61656..089132d 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -26,6 +26,9 @@ private: QListWidget* profileWidget = nullptr; QPushButton* deleteProfileButton = nullptr; + // general + QCheckBox* closeWhenLaunched = nullptr; + // game QLineEdit* nameEdit = nullptr; QComboBox* directXCombo = nullptr;