2023-09-02 07:27:34 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2020-03-22 03:16:32 +00:00
|
|
|
#include "generalsettingswidget.h"
|
2020-08-06 12:08:22 +00:00
|
|
|
#include "autoupdaterdialog.h"
|
2022-08-18 11:21:22 +00:00
|
|
|
#include "generalsettingswidget.h"
|
2020-12-21 16:47:48 +00:00
|
|
|
#include "mainwindow.h"
|
2020-11-03 11:21:11 +00:00
|
|
|
#include "qtutils.h"
|
2020-12-21 16:47:48 +00:00
|
|
|
#include "scmversion/scmversion.h"
|
2023-11-06 13:01:38 +00:00
|
|
|
#include "settingswindow.h"
|
2020-03-22 03:16:32 +00:00
|
|
|
#include "settingwidgetbinder.h"
|
|
|
|
|
2023-09-02 07:27:34 +00:00
|
|
|
const char* GeneralSettingsWidget::THEME_NAMES[] = {
|
|
|
|
QT_TRANSLATE_NOOP("MainWindow", "Native"),
|
|
|
|
QT_TRANSLATE_NOOP("MainWindow", "Fusion"),
|
|
|
|
QT_TRANSLATE_NOOP("MainWindow", "Dark Fusion (Gray)"),
|
|
|
|
QT_TRANSLATE_NOOP("MainWindow", "Dark Fusion (Blue)"),
|
|
|
|
QT_TRANSLATE_NOOP("MainWindow", "QDarkStyle"),
|
|
|
|
nullptr,
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* GeneralSettingsWidget::THEME_VALUES[] = {
|
|
|
|
"", "fusion", "darkfusion", "darkfusionblue", "qdarkstyle", nullptr,
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* GeneralSettingsWidget::DEFAULT_THEME_NAME = "darkfusion";
|
|
|
|
|
2023-11-06 13:01:38 +00:00
|
|
|
GeneralSettingsWidget::GeneralSettingsWidget(SettingsWindow* dialog, QWidget* parent)
|
2022-07-11 13:03:29 +00:00
|
|
|
: QWidget(parent), m_dialog(dialog)
|
2020-03-22 03:16:32 +00:00
|
|
|
{
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingsInterface* sif = dialog->getSettingsInterface();
|
2020-03-22 03:16:32 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
m_ui.setupUi(this);
|
2020-08-22 06:44:06 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.inhibitScreensaver, "Main", "InhibitScreensaver", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.pauseOnFocusLoss, "Main", "PauseOnFocusLoss", false);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.pauseOnStart, "Main", "StartPaused", false);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.saveStateOnExit, "Main", "SaveStateOnExit", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.confirmPowerOff, "Main", "ConfirmPowerOff", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.loadDevicesFromSaveStates, "Main", "LoadDevicesFromSaveStates",
|
2020-12-04 14:16:22 +00:00
|
|
|
false);
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.applyGameSettings, "Main", "ApplyGameSettings", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.autoLoadCheats, "Main", "AutoLoadCheats", true);
|
|
|
|
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.startFullscreen, "Main", "StartFullscreen", false);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.doubleClickTogglesFullscreen, "Main",
|
|
|
|
"DoubleClickTogglesFullscreen", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.renderToSeparateWindow, "Main", "RenderToSeparateWindow",
|
2020-07-21 09:49:04 +00:00
|
|
|
false);
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.hideMainWindow, "Main", "HideMainWindowWhenRunning", false);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.disableWindowResizing, "Main", "DisableWindowResize", false);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.hideMouseCursor, "Main", "HideCursorInFullscreen", true);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.createSaveStateBackups, "Main", "CreateSaveStateBackups",
|
2022-08-18 11:21:22 +00:00
|
|
|
Settings::DEFAULT_SAVE_STATE_BACKUPS);
|
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.compressSaveStates, "Main", "CompressSaveStates",
|
|
|
|
Settings::DEFAULT_SAVE_STATE_COMPRESSION);
|
2023-11-28 16:08:19 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableDiscordPresence, "Main", "EnableDiscordPresence", false);
|
2022-07-11 13:03:29 +00:00
|
|
|
connect(m_ui.renderToSeparateWindow, &QCheckBox::stateChanged, this,
|
|
|
|
&GeneralSettingsWidget::onRenderToSeparateWindowChanged);
|
2020-03-22 03:16:39 +00:00
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
onRenderToSeparateWindowChanged();
|
2020-03-22 03:16:32 +00:00
|
|
|
|
2022-07-22 14:16:28 +00:00
|
|
|
if (m_dialog->isPerGameSettings())
|
|
|
|
{
|
|
|
|
m_ui.applyGameSettings->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2020-05-26 16:06:56 +00:00
|
|
|
dialog->registerWidgetHelp(
|
2020-07-28 09:42:14 +00:00
|
|
|
m_ui.confirmPowerOff, tr("Confirm Power Off"), tr("Checked"),
|
|
|
|
tr("Determines whether a prompt will be displayed to confirm shutting down the emulator/game "
|
|
|
|
"when the hotkey is pressed."));
|
|
|
|
dialog->registerWidgetHelp(m_ui.saveStateOnExit, tr("Save State On Exit"), tr("Checked"),
|
|
|
|
tr("Automatically saves the emulator state when powering down or exiting. You can then "
|
|
|
|
"resume directly from where you left off next time."));
|
|
|
|
dialog->registerWidgetHelp(m_ui.startFullscreen, tr("Start Fullscreen"), tr("Unchecked"),
|
|
|
|
tr("Automatically switches to fullscreen mode when a game is started."));
|
2022-07-11 13:03:29 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.hideMouseCursor, tr("Hide Cursor In Fullscreen"), tr("Checked"),
|
2020-12-06 14:06:32 +00:00
|
|
|
tr("Hides the mouse pointer/cursor when the emulator is in fullscreen mode."));
|
2021-06-20 05:41:01 +00:00
|
|
|
dialog->registerWidgetHelp(
|
|
|
|
m_ui.inhibitScreensaver, tr("Inhibit Screensaver"), tr("Checked"),
|
|
|
|
tr("Prevents the screen saver from activating and the host from sleeping while emulation is running."));
|
2020-03-22 03:17:03 +00:00
|
|
|
dialog->registerWidgetHelp(
|
2022-07-11 13:03:29 +00:00
|
|
|
m_ui.renderToSeparateWindow, tr("Render To Separate Window"), tr("Checked"),
|
2020-07-28 09:42:14 +00:00
|
|
|
tr("Renders the display of the simulated console to the main window of the application, over "
|
2022-07-11 13:03:29 +00:00
|
|
|
"the game list. If checked, the display will render in a separate window."));
|
2020-07-28 09:42:14 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.pauseOnStart, tr("Pause On Start"), tr("Unchecked"),
|
|
|
|
tr("Pauses the emulator when a game is started."));
|
2020-12-04 16:45:12 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.pauseOnFocusLoss, tr("Pause On Focus Loss"), tr("Unchecked"),
|
|
|
|
tr("Pauses the emulator when you minimize the window or switch to another application, "
|
|
|
|
"and unpauses when you switch back."));
|
2020-07-28 09:42:14 +00:00
|
|
|
dialog->registerWidgetHelp(
|
|
|
|
m_ui.loadDevicesFromSaveStates, tr("Load Devices From Save States"), tr("Unchecked"),
|
|
|
|
tr("When enabled, memory cards and controllers will be overwritten when save states are loaded. This can "
|
|
|
|
"result in lost saves, and controller type mismatches. For deterministic save states, enable this option, "
|
|
|
|
"otherwise leave disabled."));
|
2020-08-20 14:08:40 +00:00
|
|
|
dialog->registerWidgetHelp(
|
|
|
|
m_ui.applyGameSettings, tr("Apply Per-Game Settings"), tr("Checked"),
|
|
|
|
tr("When enabled, per-game settings will be applied, and incompatible enhancements will be disabled. You should "
|
|
|
|
"leave this option enabled except when testing enhancements with incompatible games."));
|
2021-01-28 11:03:51 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.autoLoadCheats, tr("Automatically Load Cheats"), tr("Unchecked"),
|
|
|
|
tr("Automatically loads and applies cheats on game start."));
|
2023-11-28 16:08:19 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.enableDiscordPresence, tr("Enable Discord Presence"), tr("Unchecked"),
|
|
|
|
tr("Shows the game you are currently playing as part of your profile in Discord."));
|
2020-04-30 15:01:53 +00:00
|
|
|
|
2022-07-22 15:49:53 +00:00
|
|
|
if (!m_dialog->isPerGameSettings() && AutoUpdaterDialog::isSupported())
|
2020-08-06 12:08:22 +00:00
|
|
|
{
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.autoUpdateEnabled, "AutoUpdater", "CheckAtStartup", true);
|
2020-12-21 16:47:48 +00:00
|
|
|
dialog->registerWidgetHelp(m_ui.autoUpdateEnabled, tr("Enable Automatic Update Check"), tr("Checked"),
|
2020-08-06 12:08:22 +00:00
|
|
|
tr("Automatically checks for updates to the program on startup. Updates can be deferred "
|
|
|
|
"until later or skipped entirely."));
|
2020-12-21 16:47:48 +00:00
|
|
|
|
|
|
|
m_ui.autoUpdateTag->addItems(AutoUpdaterDialog::getTagList());
|
2022-07-11 13:03:29 +00:00
|
|
|
SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.autoUpdateTag, "AutoUpdater", "UpdateTag",
|
2020-12-21 16:47:48 +00:00
|
|
|
AutoUpdaterDialog::getDefaultTag());
|
|
|
|
|
|
|
|
m_ui.autoUpdateCurrentVersion->setText(tr("%1 (%2)").arg(g_scm_tag_str).arg(g_scm_date_str));
|
2022-10-03 13:20:03 +00:00
|
|
|
connect(m_ui.checkForUpdates, &QPushButton::clicked, []() { g_main_window->checkForUpdates(true); });
|
2020-08-06 12:08:22 +00:00
|
|
|
}
|
2020-12-21 16:47:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ui.verticalLayout->removeWidget(m_ui.automaticUpdaterGroup);
|
|
|
|
m_ui.automaticUpdaterGroup->hide();
|
|
|
|
}
|
2020-03-22 03:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GeneralSettingsWidget::~GeneralSettingsWidget() = default;
|
2022-07-11 13:03:29 +00:00
|
|
|
|
|
|
|
void GeneralSettingsWidget::onRenderToSeparateWindowChanged()
|
|
|
|
{
|
|
|
|
m_ui.hideMainWindow->setEnabled(m_ui.renderToSeparateWindow->isChecked());
|
|
|
|
}
|