From e7b4eb99c25d812751b8f30ebdd56e48f8cb2711 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 18:26:45 +0300 Subject: [PATCH 1/9] force fullscreen in gamescope Signed-off-by: Trial97 --- launcher/ui/MainWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index d89224504..3c94dc4f7 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -234,6 +234,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi // does not implement decorations if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") { ui->mainToolBar->addAction(ui->actionCloseWindow); + showFullScreen(); + setFixedSize(this->width(), this->height()); } ui->actionViewJavaFolder->setEnabled(BuildConfig.JAVA_DOWNLOADER_ENABLED); From 4f42580440c05bfabba37205b635a0584a3517fe Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 19:22:36 +0300 Subject: [PATCH 2/9] force fullscreen on other dialogs Signed-off-by: Trial97 --- launcher/DesktopServices.cpp | 5 + launcher/DesktopServices.h | 5 + launcher/ui/InstanceWindow.cpp | 8 +- launcher/ui/MainWindow.cpp | 2 +- launcher/ui/dialogs/NewInstanceDialog.cpp | 26 +- .../ui/dialogs/ResourceDownloadDialog.cpp | 21 +- .../pages/instance/InstanceSettingsPage.cpp | 615 ++++++++++++++++++ 7 files changed, 668 insertions(+), 14 deletions(-) create mode 100644 launcher/ui/pages/instance/InstanceSettingsPage.cpp diff --git a/launcher/DesktopServices.cpp b/launcher/DesktopServices.cpp index 841c1399c..2194d9379 100644 --- a/launcher/DesktopServices.cpp +++ b/launcher/DesktopServices.cpp @@ -84,4 +84,9 @@ bool isSnap() #endif } +bool isGameScope() +{ + return qgetenv("XDG_CURRENT_DESKTOP") == "gamescope"; +} + } // namespace DesktopServices diff --git a/launcher/DesktopServices.h b/launcher/DesktopServices.h index 6c6208e82..c788264aa 100644 --- a/launcher/DesktopServices.h +++ b/launcher/DesktopServices.h @@ -41,4 +41,9 @@ bool isFlatpak(); * Determine whether the launcher is running in a Snap environment */ bool isSnap(); + +/** + * Determine whether the launcher is running in a gamescope environment + */ +bool isGameScope(); } // namespace DesktopServices diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp index 0742fa51d..2c49cb26c 100644 --- a/launcher/ui/InstanceWindow.cpp +++ b/launcher/ui/InstanceWindow.cpp @@ -44,6 +44,7 @@ #include #include +#include "DesktopServices.h" #include "ui/widgets/PageContainer.h" #include "InstancePageProvider.h" @@ -118,8 +119,13 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget* parent) : QMainWin { auto base64State = APPLICATION->settings()->get("ConsoleWindowState").toString().toUtf8(); restoreState(QByteArray::fromBase64(base64State)); - auto base64Geometry = APPLICATION->settings()->get("ConsoleWindowGeometry").toString().toUtf8(); + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } else { + auto base64Geometry = APPLICATION->settings()->get("ConsoleWindowGeometry").toString().toUtf8(); restoreGeometry(QByteArray::fromBase64(base64Geometry)); + } } // set up instance and launch process recognition diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 3c94dc4f7..a67ecdd0e 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -232,7 +232,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi // add a close button at the end of the main toolbar when running on gamescope / steam deck // this is only needed on gamescope because it defaults to an X11/XWayland session and // does not implement decorations - if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") { + if (DesktopServices::isGameScope()) { ui->mainToolBar->addAction(ui->actionCloseWindow); showFullScreen(); setFixedSize(this->width(), this->height()); diff --git a/launcher/ui/dialogs/NewInstanceDialog.cpp b/launcher/ui/dialogs/NewInstanceDialog.cpp index 9e74cd7ac..d1b589cfe 100644 --- a/launcher/ui/dialogs/NewInstanceDialog.cpp +++ b/launcher/ui/dialogs/NewInstanceDialog.cpp @@ -45,6 +45,7 @@ #include #include +#include "DesktopServices.h" #include "IconPickerDialog.h" #include "ProgressDialog.h" #include "VersionSelectDialog.h" @@ -133,15 +134,24 @@ NewInstanceDialog::NewInstanceDialog(const QString& initialGroup, updateDialogState(); - if (APPLICATION->settings()->get("NewInstanceGeometry").isValid()) { - restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toString().toUtf8())); - } else { - auto screen = parent->screen(); - auto geometry = screen->availableSize(); - resize(width(), qMin(geometry.height() - 50, 710)); - } - connect(m_container, &PageContainer::selectedPageChanged, this, &NewInstanceDialog::selectedPageChanged); + + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } else { + if (APPLICATION->settings()->get("NewInstanceGeometry").isValid()) { + restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toString().toUtf8())); + } else { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + auto screen = parent->screen(); +#else + auto screen = QGuiApplication::primaryScreen(); +#endif + auto geometry = screen->availableSize(); + resize(width(), qMin(geometry.height() - 50, 710)); + } + } } void NewInstanceDialog::reject() diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index 191feeb88..c9de2ff21 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -24,6 +24,7 @@ #include #include "Application.h" +#include "DesktopServices.h" #include "ResourceDownloadTask.h" #include "minecraft/PackProfile.h" @@ -274,7 +275,10 @@ ModDownloadDialog::ModDownloadDialog(QWidget* parent, const std::shared_ptrwidth(), this->height()); + } else if (!geometrySaveKey().isEmpty()) restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get(geometrySaveKey()).toString().toUtf8())); } @@ -317,7 +321,10 @@ ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent, initializeContainer(); connectButtons(); - if (!geometrySaveKey().isEmpty()) + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } else if (!geometrySaveKey().isEmpty()) restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get(geometrySaveKey()).toString().toUtf8())); } @@ -342,7 +349,10 @@ TexturePackDownloadDialog::TexturePackDownloadDialog(QWidget* parent, initializeContainer(); connectButtons(); - if (!geometrySaveKey().isEmpty()) + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } else if (!geometrySaveKey().isEmpty()) restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get(geometrySaveKey()).toString().toUtf8())); } @@ -367,7 +377,10 @@ ShaderPackDownloadDialog::ShaderPackDownloadDialog(QWidget* parent, initializeContainer(); connectButtons(); - if (!geometrySaveKey().isEmpty()) + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } else if (!geometrySaveKey().isEmpty()) restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get(geometrySaveKey()).toString().toUtf8())); } diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp new file mode 100644 index 000000000..f619aca8c --- /dev/null +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -0,0 +1,615 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (c) 2022 Jamie Mansfield + * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 TheKodeToad + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "InstanceSettingsPage.h" +#include "DesktopServices.h" +#include "minecraft/MinecraftInstance.h" +#include "minecraft/WorldList.h" +#include "settings/Setting.h" +#include "ui/dialogs/CustomMessageBox.h" +#include "ui/java/InstallJavaDialog.h" +#include "ui_InstanceSettingsPage.h" + +#include +#include +#include + +#include + +#include "ui/dialogs/VersionSelectDialog.h" +#include "ui/widgets/CustomCommands.h" + +#include "Application.h" +#include "BuildConfig.h" +#include "JavaCommon.h" +#include "minecraft/auth/AccountList.h" + +#include "FileSystem.h" +#include "java/JavaInstallList.h" +#include "java/JavaUtils.h" + +InstanceSettingsPage::InstanceSettingsPage(BaseInstance* inst, QWidget* parent) + : QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst) +{ + m_settings = inst->settings(); + ui->setupUi(this); + + ui->javaDownloadBtn->setHidden(!BuildConfig.JAVA_DOWNLOADER_ENABLED); + + connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked); + connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings); + connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings); + connect(ui->instanceAccountSelector, QOverload::of(&QComboBox::currentIndexChanged), this, + &InstanceSettingsPage::changeInstanceAccount); + + connect(ui->useNativeGLFWCheck, &QAbstractButton::toggled, this, &InstanceSettingsPage::onUseNativeGLFWChanged); + connect(ui->useNativeOpenALCheck, &QAbstractButton::toggled, this, &InstanceSettingsPage::onUseNativeOpenALChanged); + + auto mInst = dynamic_cast(inst); + m_world_quickplay_supported = mInst && mInst->traits().contains("feature:is_quick_play_singleplayer"); + if (m_world_quickplay_supported) { + auto worlds = mInst->worldList(); + worlds->update(); + for (const auto& world : worlds->allWorlds()) { + ui->worldsCb->addItem(world.folderName()); + } + } else { + ui->worldsCb->hide(); + ui->worldJoinButton->hide(); + ui->serverJoinAddressButton->setChecked(true); + ui->serverJoinAddress->setEnabled(true); + ui->serverJoinAddressButton->setStyleSheet("QRadioButton::indicator { width: 0px; height: 0px; }"); + } + + loadSettings(); + + updateThresholds(); + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } +} + +InstanceSettingsPage::~InstanceSettingsPage() +{ + delete ui; +} + +void InstanceSettingsPage::globalSettingsButtonClicked(bool) +{ + switch (ui->settingsTabs->currentIndex()) { + case 0: + APPLICATION->ShowGlobalSettings(this, "java-settings"); + return; + case 2: + APPLICATION->ShowGlobalSettings(this, "custom-commands"); + return; + case 3: + APPLICATION->ShowGlobalSettings(this, "environment-variables"); + return; + default: + APPLICATION->ShowGlobalSettings(this, "minecraft-settings"); + return; + } +} + +bool InstanceSettingsPage::apply() +{ + applySettings(); + return true; +} + +void InstanceSettingsPage::applySettings() +{ + SettingsObject::Lock lock(m_settings); + + // Miscellaneous + bool miscellaneous = ui->miscellaneousSettingsBox->isChecked(); + m_settings->set("OverrideMiscellaneous", miscellaneous); + if (miscellaneous) { + m_settings->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked()); + m_settings->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked()); + } else { + m_settings->reset("CloseAfterLaunch"); + m_settings->reset("QuitAfterGameStop"); + } + + // Console + bool console = ui->consoleSettingsBox->isChecked(); + m_settings->set("OverrideConsole", console); + if (console) { + m_settings->set("ShowConsole", ui->showConsoleCheck->isChecked()); + m_settings->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); + m_settings->set("ShowConsoleOnError", ui->showConsoleErrorCheck->isChecked()); + } else { + m_settings->reset("ShowConsole"); + m_settings->reset("AutoCloseConsole"); + m_settings->reset("ShowConsoleOnError"); + } + + // Window Size + bool window = ui->windowSizeGroupBox->isChecked(); + m_settings->set("OverrideWindow", window); + if (window) { + m_settings->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); + m_settings->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); + m_settings->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); + } else { + m_settings->reset("LaunchMaximized"); + m_settings->reset("MinecraftWinWidth"); + m_settings->reset("MinecraftWinHeight"); + } + + // Memory + bool memory = ui->memoryGroupBox->isChecked(); + m_settings->set("OverrideMemory", memory); + if (memory) { + int min = ui->minMemSpinBox->value(); + int max = ui->maxMemSpinBox->value(); + if (min < max) { + m_settings->set("MinMemAlloc", min); + m_settings->set("MaxMemAlloc", max); + } else { + m_settings->set("MinMemAlloc", max); + m_settings->set("MaxMemAlloc", min); + } + m_settings->set("PermGen", ui->permGenSpinBox->value()); + } else { + m_settings->reset("MinMemAlloc"); + m_settings->reset("MaxMemAlloc"); + m_settings->reset("PermGen"); + } + + // Java Install Settings + bool javaInstall = ui->javaSettingsGroupBox->isChecked(); + m_settings->set("OverrideJavaLocation", javaInstall); + if (javaInstall) { + m_settings->set("JavaPath", ui->javaPathTextBox->text()); + m_settings->set("IgnoreJavaCompatibility", ui->skipCompatibilityCheckbox->isChecked()); + } else { + m_settings->reset("JavaPath"); + m_settings->reset("IgnoreJavaCompatibility"); + } + + // Java arguments + bool javaArgs = ui->javaArgumentsGroupBox->isChecked(); + m_settings->set("OverrideJavaArgs", javaArgs); + if (javaArgs) { + m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " ")); + } else { + m_settings->reset("JvmArgs"); + } + + // Custom Commands + bool custcmd = ui->customCommands->checked(); + m_settings->set("OverrideCommands", custcmd); + if (custcmd) { + m_settings->set("PreLaunchCommand", ui->customCommands->prelaunchCommand()); + m_settings->set("WrapperCommand", ui->customCommands->wrapperCommand()); + m_settings->set("PostExitCommand", ui->customCommands->postexitCommand()); + } else { + m_settings->reset("PreLaunchCommand"); + m_settings->reset("WrapperCommand"); + m_settings->reset("PostExitCommand"); + } + + // Environment Variables + auto env = ui->environmentVariables->override(); + m_settings->set("OverrideEnv", env); + if (env) + m_settings->set("Env", ui->environmentVariables->value()); + else + m_settings->reset("Env"); + + // Workarounds + bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked(); + m_settings->set("OverrideNativeWorkarounds", workarounds); + if (workarounds) { + m_settings->set("UseNativeGLFW", ui->useNativeGLFWCheck->isChecked()); + m_settings->set("CustomGLFWPath", ui->lineEditGLFWPath->text()); + m_settings->set("UseNativeOpenAL", ui->useNativeOpenALCheck->isChecked()); + m_settings->set("CustomOpenALPath", ui->lineEditOpenALPath->text()); + } else { + m_settings->reset("UseNativeGLFW"); + m_settings->reset("CustomGLFWPath"); + m_settings->reset("UseNativeOpenAL"); + m_settings->reset("CustomOpenALPath"); + } + + // Performance + bool performance = ui->perfomanceGroupBox->isChecked(); + m_settings->set("OverridePerformance", performance); + if (performance) { + m_settings->set("EnableFeralGamemode", ui->enableFeralGamemodeCheck->isChecked()); + m_settings->set("EnableMangoHud", ui->enableMangoHud->isChecked()); + m_settings->set("UseDiscreteGpu", ui->useDiscreteGpuCheck->isChecked()); + m_settings->set("UseZink", ui->useZink->isChecked()); + + } else { + m_settings->reset("EnableFeralGamemode"); + m_settings->reset("EnableMangoHud"); + m_settings->reset("UseDiscreteGpu"); + m_settings->reset("UseZink"); + } + + // Game time + bool gameTime = ui->gameTimeGroupBox->isChecked(); + m_settings->set("OverrideGameTime", gameTime); + if (gameTime) { + m_settings->set("ShowGameTime", ui->showGameTime->isChecked()); + m_settings->set("RecordGameTime", ui->recordGameTime->isChecked()); + } else { + m_settings->reset("ShowGameTime"); + m_settings->reset("RecordGameTime"); + } + + // Join server on launch + bool joinServerOnLaunch = ui->serverJoinGroupBox->isChecked(); + m_settings->set("JoinServerOnLaunch", joinServerOnLaunch); + if (joinServerOnLaunch) { + if (ui->serverJoinAddressButton->isChecked() || !m_world_quickplay_supported) { + m_settings->set("JoinServerOnLaunchAddress", ui->serverJoinAddress->text()); + m_settings->reset("JoinWorldOnLaunch"); + } else { + m_settings->set("JoinWorldOnLaunch", ui->worldsCb->currentText()); + m_settings->reset("JoinServerOnLaunchAddress"); + } + } else { + m_settings->reset("JoinServerOnLaunchAddress"); + m_settings->reset("JoinWorldOnLaunch"); + } + + // Use an account for this instance + bool useAccountForInstance = ui->instanceAccountGroupBox->isChecked(); + m_settings->set("UseAccountForInstance", useAccountForInstance); + if (!useAccountForInstance) { + m_settings->reset("InstanceAccountId"); + } + + bool overrideLegacySettings = ui->legacySettingsGroupBox->isChecked(); + m_settings->set("OverrideLegacySettings", overrideLegacySettings); + if (overrideLegacySettings) { + m_settings->set("OnlineFixes", ui->onlineFixes->isChecked()); + } else { + m_settings->reset("OnlineFixes"); + } + + // FIXME: This should probably be called by a signal instead + m_instance->updateRuntimeContext(); +} + +void InstanceSettingsPage::loadSettings() +{ + // Miscellaneous + ui->miscellaneousSettingsBox->setChecked(m_settings->get("OverrideMiscellaneous").toBool()); + ui->closeAfterLaunchCheck->setChecked(m_settings->get("CloseAfterLaunch").toBool()); + ui->quitAfterGameStopCheck->setChecked(m_settings->get("QuitAfterGameStop").toBool()); + + // Console + ui->consoleSettingsBox->setChecked(m_settings->get("OverrideConsole").toBool()); + ui->showConsoleCheck->setChecked(m_settings->get("ShowConsole").toBool()); + ui->autoCloseConsoleCheck->setChecked(m_settings->get("AutoCloseConsole").toBool()); + ui->showConsoleErrorCheck->setChecked(m_settings->get("ShowConsoleOnError").toBool()); + + // Window Size + ui->windowSizeGroupBox->setChecked(m_settings->get("OverrideWindow").toBool()); + ui->maximizedCheckBox->setChecked(m_settings->get("LaunchMaximized").toBool()); + ui->windowWidthSpinBox->setValue(m_settings->get("MinecraftWinWidth").toInt()); + ui->windowHeightSpinBox->setValue(m_settings->get("MinecraftWinHeight").toInt()); + + // Memory + ui->memoryGroupBox->setChecked(m_settings->get("OverrideMemory").toBool()); + int min = m_settings->get("MinMemAlloc").toInt(); + int max = m_settings->get("MaxMemAlloc").toInt(); + if (min < max) { + ui->minMemSpinBox->setValue(min); + ui->maxMemSpinBox->setValue(max); + } else { + ui->minMemSpinBox->setValue(max); + ui->maxMemSpinBox->setValue(min); + } + ui->permGenSpinBox->setValue(m_settings->get("PermGen").toInt()); + bool permGenVisible = m_settings->get("PermGenVisible").toBool(); + ui->permGenSpinBox->setVisible(permGenVisible); + ui->labelPermGen->setVisible(permGenVisible); + ui->labelPermgenNote->setVisible(permGenVisible); + + // Java Settings + bool overrideLocation = m_settings->get("OverrideJavaLocation").toBool(); + bool overrideArgs = m_settings->get("OverrideJavaArgs").toBool(); + + connect(m_settings->getSetting("OverrideJavaLocation").get(), &Setting::SettingChanged, ui->javaSettingsGroupBox, + [this] { ui->javaSettingsGroupBox->setChecked(m_settings->get("OverrideJavaLocation").toBool()); }); + ui->javaSettingsGroupBox->setChecked(overrideLocation); + ui->javaPathTextBox->setText(m_settings->get("JavaPath").toString()); + connect(m_settings->getSetting("JavaPath").get(), &Setting::SettingChanged, ui->javaSettingsGroupBox, + [this] { ui->javaPathTextBox->setText(m_settings->get("JavaPath").toString()); }); + + ui->skipCompatibilityCheckbox->setChecked(m_settings->get("IgnoreJavaCompatibility").toBool()); + + ui->javaArgumentsGroupBox->setChecked(overrideArgs); + ui->jvmArgsTextBox->setPlainText(m_settings->get("JvmArgs").toString()); + + // Custom commands + ui->customCommands->initialize(true, m_settings->get("OverrideCommands").toBool(), m_settings->get("PreLaunchCommand").toString(), + m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString()); + + // Environment variables + ui->environmentVariables->initialize(true, m_settings->get("OverrideEnv").toBool(), m_settings->get("Env").toMap()); + + // Workarounds + ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool()); + ui->useNativeGLFWCheck->setChecked(m_settings->get("UseNativeGLFW").toBool()); + ui->lineEditGLFWPath->setText(m_settings->get("CustomGLFWPath").toString()); +#ifdef Q_OS_LINUX + ui->lineEditGLFWPath->setPlaceholderText(APPLICATION->m_detectedGLFWPath); +#else + ui->lineEditGLFWPath->setPlaceholderText(tr("Path to %1 library file").arg(BuildConfig.GLFW_LIBRARY_NAME)); +#endif + ui->useNativeOpenALCheck->setChecked(m_settings->get("UseNativeOpenAL").toBool()); + ui->lineEditOpenALPath->setText(m_settings->get("CustomOpenALPath").toString()); +#ifdef Q_OS_LINUX + ui->lineEditOpenALPath->setPlaceholderText(APPLICATION->m_detectedOpenALPath); +#else + ui->lineEditOpenALPath->setPlaceholderText(tr("Path to %1 library file").arg(BuildConfig.OPENAL_LIBRARY_NAME)); +#endif + + // Performance + ui->perfomanceGroupBox->setChecked(m_settings->get("OverridePerformance").toBool()); + ui->enableFeralGamemodeCheck->setChecked(m_settings->get("EnableFeralGamemode").toBool()); + ui->enableMangoHud->setChecked(m_settings->get("EnableMangoHud").toBool()); + ui->useDiscreteGpuCheck->setChecked(m_settings->get("UseDiscreteGpu").toBool()); + ui->useZink->setChecked(m_settings->get("UseZink").toBool()); + +#if !defined(Q_OS_LINUX) + ui->settingsTabs->setTabVisible(ui->settingsTabs->indexOf(ui->performancePage), false); +#endif + + if (!(APPLICATION->capabilities() & Application::SupportsGameMode)) { + ui->enableFeralGamemodeCheck->setDisabled(true); + ui->enableFeralGamemodeCheck->setToolTip(tr("Feral Interactive's GameMode could not be found on your system.")); + } + + if (!(APPLICATION->capabilities() & Application::SupportsMangoHud)) { + ui->enableMangoHud->setDisabled(true); + ui->enableMangoHud->setToolTip(tr("MangoHud could not be found on your system.")); + } + + // Miscellanous + ui->gameTimeGroupBox->setChecked(m_settings->get("OverrideGameTime").toBool()); + ui->showGameTime->setChecked(m_settings->get("ShowGameTime").toBool()); + ui->recordGameTime->setChecked(m_settings->get("RecordGameTime").toBool()); + + ui->serverJoinGroupBox->setChecked(m_settings->get("JoinServerOnLaunch").toBool()); + + if (auto server = m_settings->get("JoinServerOnLaunchAddress").toString(); !server.isEmpty()) { + ui->serverJoinAddress->setText(server); + ui->serverJoinAddressButton->setChecked(true); + ui->worldJoinButton->setChecked(false); + ui->serverJoinAddress->setEnabled(true); + ui->worldsCb->setEnabled(false); + } else if (auto world = m_settings->get("JoinWorldOnLaunch").toString(); !world.isEmpty() && m_world_quickplay_supported) { + ui->worldsCb->setCurrentText(world); + ui->serverJoinAddressButton->setChecked(false); + ui->worldJoinButton->setChecked(true); + ui->serverJoinAddress->setEnabled(false); + ui->worldsCb->setEnabled(true); + } else { + ui->serverJoinAddressButton->setChecked(true); + ui->worldJoinButton->setChecked(false); + ui->serverJoinAddress->setEnabled(true); + ui->worldsCb->setEnabled(false); + } + + ui->instanceAccountGroupBox->setChecked(m_settings->get("UseAccountForInstance").toBool()); + updateAccountsMenu(); + + ui->legacySettingsGroupBox->setChecked(m_settings->get("OverrideLegacySettings").toBool()); + ui->onlineFixes->setChecked(m_settings->get("OnlineFixes").toBool()); +} + +void InstanceSettingsPage::on_javaDownloadBtn_clicked() +{ + auto jdialog = new Java::InstallDialog({}, m_instance, this); + jdialog->exec(); +} + +void InstanceSettingsPage::on_javaDetectBtn_clicked() +{ + if (JavaUtils::getJavaCheckPath().isEmpty()) { + JavaCommon::javaCheckNotFound(this); + return; + } + + JavaInstallPtr java; + + VersionSelectDialog vselect(APPLICATION->javalist().get(), tr("Select a Java version"), this, true); + vselect.setResizeOn(2); + vselect.exec(); + + if (vselect.result() == QDialog::Accepted && vselect.selectedVersion()) { + java = std::dynamic_pointer_cast(vselect.selectedVersion()); + ui->javaPathTextBox->setText(java->path); + bool visible = java->id.requiresPermGen() && m_settings->get("OverrideMemory").toBool(); + ui->permGenSpinBox->setVisible(visible); + ui->labelPermGen->setVisible(visible); + ui->labelPermgenNote->setVisible(visible); + m_settings->set("PermGenVisible", visible); + + if (!java->is_64bit && m_settings->get("MaxMemAlloc").toInt() > 2048) { + CustomMessageBox::selectable(this, tr("Confirm Selection"), + tr("You selected a 32-bit version of Java.\n" + "This installation does not support more than 2048MiB of RAM.\n" + "Please make sure that the maximum memory value is lower."), + QMessageBox::Warning, QMessageBox::Ok, QMessageBox::Ok) + ->exec(); + } + } +} + +void InstanceSettingsPage::on_javaBrowseBtn_clicked() +{ + QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable")); + + // do not allow current dir - it's dirty. Do not allow dirs that don't exist + if (raw_path.isEmpty()) { + return; + } + QString cooked_path = FS::NormalizePath(raw_path); + + QFileInfo javaInfo(cooked_path); + if (!javaInfo.exists() || !javaInfo.isExecutable()) { + return; + } + ui->javaPathTextBox->setText(cooked_path); + + // custom Java could be anything... enable perm gen option + ui->permGenSpinBox->setVisible(true); + ui->labelPermGen->setVisible(true); + ui->labelPermgenNote->setVisible(true); + m_settings->set("PermGenVisible", true); +} + +void InstanceSettingsPage::on_javaTestBtn_clicked() +{ + if (checker) { + return; + } + checker.reset(new JavaCommon::TestCheck(this, ui->javaPathTextBox->text(), ui->jvmArgsTextBox->toPlainText().replace("\n", " "), + ui->minMemSpinBox->value(), ui->maxMemSpinBox->value(), ui->permGenSpinBox->value())); + connect(checker.get(), SIGNAL(finished()), SLOT(checkerFinished())); + checker->run(); +} + +void InstanceSettingsPage::onUseNativeGLFWChanged(bool checked) +{ + ui->lineEditGLFWPath->setEnabled(checked); +} + +void InstanceSettingsPage::onUseNativeOpenALChanged(bool checked) +{ + ui->lineEditOpenALPath->setEnabled(checked); +} + +void InstanceSettingsPage::updateAccountsMenu() +{ + ui->instanceAccountSelector->clear(); + auto accounts = APPLICATION->accounts(); + int accountIndex = accounts->findAccountByProfileId(m_settings->get("InstanceAccountId").toString()); + + for (int i = 0; i < accounts->count(); i++) { + MinecraftAccountPtr account = accounts->at(i); + ui->instanceAccountSelector->addItem(getFaceForAccount(account), account->profileName(), i); + if (i == accountIndex) + ui->instanceAccountSelector->setCurrentIndex(i); + } +} + +QIcon InstanceSettingsPage::getFaceForAccount(MinecraftAccountPtr account) +{ + if (auto face = account->getFace(); !face.isNull()) { + return face; + } + + return APPLICATION->getThemedIcon("noaccount"); +} + +void InstanceSettingsPage::changeInstanceAccount(int index) +{ + auto accounts = APPLICATION->accounts(); + if (index != -1 && accounts->at(index) && ui->instanceAccountGroupBox->isChecked()) { + auto account = accounts->at(index); + m_settings->set("InstanceAccountId", account->profileId()); + } +} + +void InstanceSettingsPage::on_maxMemSpinBox_valueChanged([[maybe_unused]] int i) +{ + updateThresholds(); +} + +void InstanceSettingsPage::checkerFinished() +{ + checker.reset(); +} + +void InstanceSettingsPage::retranslate() +{ + ui->retranslateUi(this); + ui->customCommands->retranslate(); // TODO: why is this seperate from the others? + ui->environmentVariables->retranslate(); +} + +void InstanceSettingsPage::updateThresholds() +{ + auto sysMiB = Sys::getSystemRam() / Sys::mebibyte; + unsigned int maxMem = ui->maxMemSpinBox->value(); + unsigned int minMem = ui->minMemSpinBox->value(); + + QString iconName; + + if (maxMem >= sysMiB) { + iconName = "status-bad"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity.")); + } else if (maxMem > (sysMiB * 0.9)) { + iconName = "status-yellow"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity.")); + } else if (maxMem < minMem) { + iconName = "status-yellow"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation is smaller than the minimum value")); + } else { + iconName = "status-good"; + ui->labelMaxMemIcon->setToolTip(""); + } + + { + auto height = ui->labelMaxMemIcon->fontInfo().pixelSize(); + QIcon icon = APPLICATION->getThemedIcon(iconName); + QPixmap pix = icon.pixmap(height, height); + ui->labelMaxMemIcon->setPixmap(pix); + } +} + +void InstanceSettingsPage::on_serverJoinAddressButton_toggled(bool checked) +{ + ui->serverJoinAddress->setEnabled(checked); +} + +void InstanceSettingsPage::on_worldJoinButton_toggled(bool checked) +{ + ui->worldsCb->setEnabled(checked); +} From 1709060a73f641b45fd42afd491854b820f9570a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 19:45:36 +0300 Subject: [PATCH 3/9] add more dialogs as fullscreen when in gamescope Signed-off-by: Trial97 --- launcher/ui/InstanceWindow.cpp | 4 ++++ launcher/ui/dialogs/ExportInstanceDialog.cpp | 6 ++++++ launcher/ui/dialogs/ExportPackDialog.cpp | 7 +++++++ launcher/ui/dialogs/ExportToModListDialog.cpp | 5 +++++ launcher/ui/dialogs/NewsDialog.cpp | 5 +++++ launcher/ui/pages/instance/InstanceSettingsPage.cpp | 4 ---- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp index 2c49cb26c..6ba6dcf37 100644 --- a/launcher/ui/InstanceWindow.cpp +++ b/launcher/ui/InstanceWindow.cpp @@ -68,6 +68,10 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget* parent) : QMainWin { auto provider = std::make_shared(m_instance); m_container = new PageContainer(provider.get(), "console", this); + if (DesktopServices::isGameScope()) { + m_container->showFullScreen(); + m_container->setFixedSize(this->width(), this->height()); + } m_container->setParentContainer(this); setCentralWidget(m_container); setContentsMargins(0, 0, 0, 0); diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp index 8d98b0513..481c4ac91 100644 --- a/launcher/ui/dialogs/ExportInstanceDialog.cpp +++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp @@ -41,6 +41,7 @@ #include #include #include +#include "DesktopServices.h" #include "FileIgnoreProxy.h" #include "QObjectPtr.h" #include "ui/dialogs/CustomMessageBox.h" @@ -89,6 +90,11 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); + + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } } ExportInstanceDialog::~ExportInstanceDialog() diff --git a/launcher/ui/dialogs/ExportPackDialog.cpp b/launcher/ui/dialogs/ExportPackDialog.cpp index e6c17972d..a87120234 100644 --- a/launcher/ui/dialogs/ExportPackDialog.cpp +++ b/launcher/ui/dialogs/ExportPackDialog.cpp @@ -17,6 +17,8 @@ */ #include "ExportPackDialog.h" +#include "DesktopServices.h" +#include "minecraft/mod/ModFolderModel.h" #include "minecraft/mod/ResourceFolderModel.h" #include "modplatform/ModIndex.h" #include "modplatform/flame/FlamePackExportTask.h" @@ -121,6 +123,11 @@ ExportPackDialog::ExportPackDialog(MinecraftInstancePtr instance, QWidget* paren m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); + + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } } ExportPackDialog::~ExportPackDialog() diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp index e8873f9b4..9db72b397 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.cpp +++ b/launcher/ui/dialogs/ExportToModListDialog.cpp @@ -20,6 +20,7 @@ #include #include #include +#include "DesktopServices.h" #include "FileSystem.h" #include "Markdown.h" #include "StringUtils.h" @@ -68,6 +69,10 @@ ExportToModListDialog::ExportToModListDialog(QString name, QList mods, QWi ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Save")); triggerImp(); + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } } ExportToModListDialog::~ExportToModListDialog() diff --git a/launcher/ui/dialogs/NewsDialog.cpp b/launcher/ui/dialogs/NewsDialog.cpp index b646e3918..d38a53cb7 100644 --- a/launcher/ui/dialogs/NewsDialog.cpp +++ b/launcher/ui/dialogs/NewsDialog.cpp @@ -1,4 +1,5 @@ #include "NewsDialog.h" +#include "DesktopServices.h" #include "ui_NewsDialog.h" NewsDialog::NewsDialog(QList entries, QWidget* parent) : QDialog(parent), ui(new Ui::NewsDialog()) @@ -23,6 +24,10 @@ NewsDialog::NewsDialog(QList entries, QWidget* parent) : QDialog(p ui->currentArticleContentBrowser->setText(article_entry->content); ui->currentArticleContentBrowser->flush(); + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } } NewsDialog::~NewsDialog() diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index f619aca8c..f5deed5fa 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -98,10 +98,6 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance* inst, QWidget* parent) loadSettings(); updateThresholds(); - if (DesktopServices::isGameScope()) { - showFullScreen(); - setFixedSize(this->width(), this->height()); - } } InstanceSettingsPage::~InstanceSettingsPage() From dcc76d250f02fed8917fb951ed42b48ffe11194f Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 19:59:10 +0300 Subject: [PATCH 4/9] fix settings page Signed-off-by: Trial97 --- launcher/Application.cpp | 4 ++++ launcher/ui/InstanceWindow.cpp | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index d7182c48d..cbb21e38c 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1673,6 +1673,10 @@ void Application::ShowGlobalSettings(class QWidget* parent, QString open_page) SettingsObject::Lock lock(APPLICATION->settings()); PageDialog dlg(m_globalSettingsProvider.get(), open_page, parent); connect(&dlg, &PageDialog::applied, this, &Application::globalSettingsApplied); + if (DesktopServices::isGameScope()) { + dlg.showFullScreen(); + dlg.setFixedSize(dlg.width(), dlg.height()); + } dlg.exec(); } } diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp index 6ba6dcf37..2c49cb26c 100644 --- a/launcher/ui/InstanceWindow.cpp +++ b/launcher/ui/InstanceWindow.cpp @@ -68,10 +68,6 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget* parent) : QMainWin { auto provider = std::make_shared(m_instance); m_container = new PageContainer(provider.get(), "console", this); - if (DesktopServices::isGameScope()) { - m_container->showFullScreen(); - m_container->setFixedSize(this->width(), this->height()); - } m_container->setParentContainer(this); setCentralWidget(m_container); setContentsMargins(0, 0, 0, 0); From f1c64d0d440c03dc6e4c0ec2f5914b9e9613d4c3 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 20:17:05 +0300 Subject: [PATCH 5/9] more dialogs Signed-off-by: Trial97 --- launcher/ui/dialogs/AboutDialog.cpp | 5 +++++ launcher/ui/dialogs/InstallLoaderDialog.cpp | 4 ++++ launcher/ui/dialogs/VersionSelectDialog.cpp | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp index 5b7d44ff7..f1d6132dd 100644 --- a/launcher/ui/dialogs/AboutDialog.cpp +++ b/launcher/ui/dialogs/AboutDialog.cpp @@ -37,6 +37,7 @@ #include #include "Application.h" #include "BuildConfig.h" +#include "DesktopServices.h" #include "Markdown.h" #include "StringUtils.h" #include "ui_AboutDialog.h" @@ -180,6 +181,10 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDia connect(ui->closeButton, &QPushButton::clicked, this, &AboutDialog::close); connect(ui->aboutQt, &QPushButton::clicked, &QApplication::aboutQt); + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } } AboutDialog::~AboutDialog() diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 7082125f2..9608eac21 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -128,6 +128,10 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* current) { validate(current); }); pageCast(container->selectedPage())->selectSearch(); validate(container->selectedPage()); + if (DesktopServices::isGameScope()) { + showFullScreen(); + setFixedSize(this->width(), this->height()); + } } QList InstallLoaderDialog::getPages() diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index 30377288b..38c9496eb 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -42,6 +42,7 @@ #include #include +#include "DesktopServices.h" #include "ui/widgets/VersionSelectWidget.h" #include "BaseVersion.h" @@ -90,6 +91,10 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList* vlist, QString title, if (!cancelable) { m_buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); } + if (DesktopServices::isGameScope()) { + this->showFullScreen(); + this->setFixedSize(this->width(), this->height()); + } } void VersionSelectDialog::retranslate() From 73e89ba1b4555157fe45c5494fed3fd658c913bf Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 20:22:13 +0300 Subject: [PATCH 6/9] add setup wizzard Signed-off-by: Trial97 --- launcher/Application.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index cbb21e38c..28272c757 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1256,6 +1256,10 @@ bool Application::createSetupWizard() m_setupWizard->addPage(new LoginWizardPage(m_setupWizard)); } connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished); + if (DesktopServices::isGameScope()) { + m_setupWizard->showFullScreen(); + m_setupWizard->setFixedSize(m_setupWizard->width(), m_setupWizard->height()); + } m_setupWizard->show(); } From a9b485c656f7b3382fcd901e141c11506f717d38 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 22:41:47 +0300 Subject: [PATCH 7/9] add progressDialog and remove wizzard from fullscreen on gamescope Signed-off-by: Trial97 --- launcher/Application.cpp | 4 ---- launcher/ui/dialogs/ProgressDialog.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 28272c757..cbb21e38c 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1256,10 +1256,6 @@ bool Application::createSetupWizard() m_setupWizard->addPage(new LoginWizardPage(m_setupWizard)); } connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished); - if (DesktopServices::isGameScope()) { - m_setupWizard->showFullScreen(); - m_setupWizard->setFixedSize(m_setupWizard->width(), m_setupWizard->height()); - } m_setupWizard->show(); } diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp index aa2f67bdb..f6e9d7001 100644 --- a/launcher/ui/dialogs/ProgressDialog.cpp +++ b/launcher/ui/dialogs/ProgressDialog.cpp @@ -35,6 +35,7 @@ #include "ProgressDialog.h" #include +#include "DesktopServices.h" #include "ui_ProgressDialog.h" #include @@ -98,6 +99,11 @@ ProgressDialog::~ProgressDialog() void ProgressDialog::updateSize(bool recenterParent) { + if (DesktopServices::isGameScope()) { + this->showFullScreen(); + this->setFixedSize(this->width(), this->height()); + return; + } QSize lastSize = this->size(); QPoint lastPos = this->pos(); int minHeight = ui->globalStatusDetailsLabel->minimumSize().height() + (ui->verticalLayout->spacing() * 2); From f7f7e1e3361567da2acee09a04d1599635133a41 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 30 Mar 2025 00:54:22 +0200 Subject: [PATCH 8/9] remove ProgressDialog from fullscreen on gamescope Signed-off-by: Trial97 --- launcher/ui/dialogs/ProgressDialog.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp index f6e9d7001..171989fb0 100644 --- a/launcher/ui/dialogs/ProgressDialog.cpp +++ b/launcher/ui/dialogs/ProgressDialog.cpp @@ -99,11 +99,6 @@ ProgressDialog::~ProgressDialog() void ProgressDialog::updateSize(bool recenterParent) { - if (DesktopServices::isGameScope()) { - this->showFullScreen(); - this->setFixedSize(this->width(), this->height()); - return; - } QSize lastSize = this->size(); QPoint lastPos = this->pos(); int minHeight = ui->globalStatusDetailsLabel->minimumSize().height() + (ui->verticalLayout->spacing() * 2); From 2bdd8c2d5a5df0deeebf6235b7e6721a9565abef Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 31 Mar 2025 01:19:34 +0300 Subject: [PATCH 9/9] apply suggestion Signed-off-by: Trial97 --- launcher/Application.cpp | 2 +- launcher/DesktopServices.cpp | 4 ++-- launcher/DesktopServices.h | 2 +- launcher/ui/InstanceWindow.cpp | 2 +- launcher/ui/MainWindow.cpp | 2 +- launcher/ui/dialogs/AboutDialog.cpp | 2 +- launcher/ui/dialogs/ExportInstanceDialog.cpp | 2 +- launcher/ui/dialogs/ExportPackDialog.cpp | 2 +- launcher/ui/dialogs/ExportToModListDialog.cpp | 2 +- launcher/ui/dialogs/InstallLoaderDialog.cpp | 2 +- launcher/ui/dialogs/NewInstanceDialog.cpp | 2 +- launcher/ui/dialogs/NewsDialog.cpp | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.cpp | 8 ++++---- launcher/ui/dialogs/VersionSelectDialog.cpp | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index cbb21e38c..edfdb0f03 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1673,7 +1673,7 @@ void Application::ShowGlobalSettings(class QWidget* parent, QString open_page) SettingsObject::Lock lock(APPLICATION->settings()); PageDialog dlg(m_globalSettingsProvider.get(), open_page, parent); connect(&dlg, &PageDialog::applied, this, &Application::globalSettingsApplied); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { dlg.showFullScreen(); dlg.setFixedSize(dlg.width(), dlg.height()); } diff --git a/launcher/DesktopServices.cpp b/launcher/DesktopServices.cpp index 2194d9379..81d97c2ef 100644 --- a/launcher/DesktopServices.cpp +++ b/launcher/DesktopServices.cpp @@ -84,9 +84,9 @@ bool isSnap() #endif } -bool isGameScope() +bool isSteamDeckGameScope() { - return qgetenv("XDG_CURRENT_DESKTOP") == "gamescope"; + return qgetenv("XDG_CURRENT_DESKTOP") == "gamescope" && qgetenv("STEAM_DECK") == "1"; } } // namespace DesktopServices diff --git a/launcher/DesktopServices.h b/launcher/DesktopServices.h index c788264aa..e82eeacdb 100644 --- a/launcher/DesktopServices.h +++ b/launcher/DesktopServices.h @@ -45,5 +45,5 @@ bool isSnap(); /** * Determine whether the launcher is running in a gamescope environment */ -bool isGameScope(); +bool isSteamDeckGameScope(); } // namespace DesktopServices diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp index 2c49cb26c..b22e4203c 100644 --- a/launcher/ui/InstanceWindow.cpp +++ b/launcher/ui/InstanceWindow.cpp @@ -119,7 +119,7 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget* parent) : QMainWin { auto base64State = APPLICATION->settings()->get("ConsoleWindowState").toString().toUtf8(); restoreState(QByteArray::fromBase64(base64State)); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } else { diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index a67ecdd0e..fc5ef12e5 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -232,7 +232,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi // add a close button at the end of the main toolbar when running on gamescope / steam deck // this is only needed on gamescope because it defaults to an X11/XWayland session and // does not implement decorations - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { ui->mainToolBar->addAction(ui->actionCloseWindow); showFullScreen(); setFixedSize(this->width(), this->height()); diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp index f1d6132dd..3eb17d470 100644 --- a/launcher/ui/dialogs/AboutDialog.cpp +++ b/launcher/ui/dialogs/AboutDialog.cpp @@ -181,7 +181,7 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDia connect(ui->closeButton, &QPushButton::clicked, this, &AboutDialog::close); connect(ui->aboutQt, &QPushButton::clicked, &QApplication::aboutQt); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp index 481c4ac91..f07eba0c6 100644 --- a/launcher/ui/dialogs/ExportInstanceDialog.cpp +++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp @@ -91,7 +91,7 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } diff --git a/launcher/ui/dialogs/ExportPackDialog.cpp b/launcher/ui/dialogs/ExportPackDialog.cpp index a87120234..0d4a6aa7a 100644 --- a/launcher/ui/dialogs/ExportPackDialog.cpp +++ b/launcher/ui/dialogs/ExportPackDialog.cpp @@ -124,7 +124,7 @@ ExportPackDialog::ExportPackDialog(MinecraftInstancePtr instance, QWidget* paren m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp index 9db72b397..8ce9b6e65 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.cpp +++ b/launcher/ui/dialogs/ExportToModListDialog.cpp @@ -69,7 +69,7 @@ ExportToModListDialog::ExportToModListDialog(QString name, QList mods, QWi ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Save")); triggerImp(); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 9608eac21..8e10c12d7 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -128,7 +128,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* current) { validate(current); }); pageCast(container->selectedPage())->selectSearch(); validate(container->selectedPage()); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } diff --git a/launcher/ui/dialogs/NewInstanceDialog.cpp b/launcher/ui/dialogs/NewInstanceDialog.cpp index d1b589cfe..8db9209a0 100644 --- a/launcher/ui/dialogs/NewInstanceDialog.cpp +++ b/launcher/ui/dialogs/NewInstanceDialog.cpp @@ -136,7 +136,7 @@ NewInstanceDialog::NewInstanceDialog(const QString& initialGroup, connect(m_container, &PageContainer::selectedPageChanged, this, &NewInstanceDialog::selectedPageChanged); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } else { diff --git a/launcher/ui/dialogs/NewsDialog.cpp b/launcher/ui/dialogs/NewsDialog.cpp index d38a53cb7..cc1bc9936 100644 --- a/launcher/ui/dialogs/NewsDialog.cpp +++ b/launcher/ui/dialogs/NewsDialog.cpp @@ -24,7 +24,7 @@ NewsDialog::NewsDialog(QList entries, QWidget* parent) : QDialog(p ui->currentArticleContentBrowser->setText(article_entry->content); ui->currentArticleContentBrowser->flush(); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index c9de2ff21..44d9164cb 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -275,7 +275,7 @@ ModDownloadDialog::ModDownloadDialog(QWidget* parent, const std::shared_ptrwidth(), this->height()); } else if (!geometrySaveKey().isEmpty()) @@ -321,7 +321,7 @@ ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent, initializeContainer(); connectButtons(); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } else if (!geometrySaveKey().isEmpty()) @@ -349,7 +349,7 @@ TexturePackDownloadDialog::TexturePackDownloadDialog(QWidget* parent, initializeContainer(); connectButtons(); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } else if (!geometrySaveKey().isEmpty()) @@ -377,7 +377,7 @@ ShaderPackDownloadDialog::ShaderPackDownloadDialog(QWidget* parent, initializeContainer(); connectButtons(); - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { showFullScreen(); setFixedSize(this->width(), this->height()); } else if (!geometrySaveKey().isEmpty()) diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index 38c9496eb..4bc938702 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -91,7 +91,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList* vlist, QString title, if (!cancelable) { m_buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); } - if (DesktopServices::isGameScope()) { + if (DesktopServices::isSteamDeckGameScope()) { this->showFullScreen(); this->setFixedSize(this->width(), this->height()); }