2021-12-13 12:12:54 +00:00
/* PCSX2 - PS2 Emulator for PCs
* Copyright ( C ) 2002 - 2022 PCSX2 Dev Team
*
* PCSX2 is free software : you can redistribute it and / or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found -
* ation , either version 3 of the License , or ( at your option ) any later version .
*
* PCSX2 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 PCSX2 .
* If not , see < http : //www.gnu.org/licenses/>.
*/
# include "PrecompiledHeader.h"
# include "InterfaceSettingsWidget.h"
2022-04-04 11:27:23 +00:00
# include "AutoUpdaterDialog.h"
2021-12-13 12:12:54 +00:00
# include "MainWindow.h"
# include "SettingWidgetBinder.h"
# include "SettingsDialog.h"
2023-04-25 10:24:22 +00:00
# include "QtHost.h"
2021-12-13 12:12:54 +00:00
2023-06-23 13:18:10 +00:00
const char * InterfaceSettingsWidget : : THEME_NAMES [ ] = {
2022-05-25 20:52:46 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Native " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2023-04-25 10:02:11 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Fusion [Light/Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-02-16 15:37:48 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Dark Fusion (Gray) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-02-16 15:37:48 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Dark Fusion (Blue) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-02-16 15:37:48 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Untouched Lagoon (Grayish Green/-Blue ) [Light] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-02-16 15:37:48 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Baby Pastel (Pink) [Light] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2023-03-31 15:39:45 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Pizza Time! (Brown-ish/Creamy White) [Light] " ) ,
2023-03-24 12:03:05 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-02-16 15:37:48 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " PCSX2 (White/Blue) [Light] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-05-25 20:52:46 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Scarlet Devil (Red/Purple) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-12-28 14:05:14 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Violet Angel (Blue/Purple) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2023-03-31 15:39:45 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Cobalt Sky (Blue) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-07-20 01:12:00 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Ruby (Black/Red) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
2022-12-28 14:05:14 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Sapphire (Black/Blue) [Dark] " ) ,
2023-03-18 21:14:55 +00:00
//: "Custom.qss" must be kept as-is.
2022-07-20 01:12:00 +00:00
QT_TRANSLATE_NOOP ( " InterfaceSettingsWidget " , " Custom.qss [Drop in PCSX2 Folder] " ) ,
2022-06-28 11:37:30 +00:00
nullptr } ;
2021-12-13 12:12:54 +00:00
2023-06-23 13:18:10 +00:00
const char * InterfaceSettingsWidget : : THEME_VALUES [ ] = {
2022-05-25 20:52:46 +00:00
" " ,
" fusion " ,
" darkfusion " ,
" darkfusionblue " ,
" UntouchedLagoon " ,
" BabyPastel " ,
2023-03-24 12:03:05 +00:00
" PizzaBrown " ,
2022-05-25 20:52:46 +00:00
" PCSX2Blue " ,
" ScarletDevilRed " ,
2022-12-28 14:05:14 +00:00
" VioletAngelPurple " ,
2023-02-24 03:35:33 +00:00
" CobaltSky " ,
2022-07-20 01:12:00 +00:00
" Ruby " ,
2022-12-28 14:05:14 +00:00
" Sapphire " ,
2022-07-20 01:12:00 +00:00
" Custom " ,
2022-06-28 11:37:30 +00:00
nullptr } ;
2021-12-13 12:12:54 +00:00
2022-02-15 14:29:18 +00:00
InterfaceSettingsWidget : : InterfaceSettingsWidget ( SettingsDialog * dialog , QWidget * parent )
2021-12-13 12:12:54 +00:00
: QWidget ( parent )
{
2022-02-15 14:29:18 +00:00
SettingsInterface * sif = dialog - > getSettingsInterface ( ) ;
2021-12-13 12:12:54 +00:00
m_ui . setupUi ( this ) ;
2022-10-02 13:05:05 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . inhibitScreensaver , " EmuCore " , " InhibitScreensaver " , true ) ;
2022-03-04 10:40:03 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . confirmShutdown , " UI " , " ConfirmShutdown " , true ) ;
2022-05-07 12:56:44 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . saveStateOnShutdown , " EmuCore " , " SaveStateOnShutdown " , false ) ;
2022-02-15 14:29:18 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pauseOnFocusLoss , " UI " , " PauseOnFocusLoss " , false ) ;
2023-03-22 13:25:31 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . backupSaveStates , " EmuCore " , " BackupSavestate " , true ) ;
2023-09-16 05:24:34 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . discordPresence , " EmuCore " , " EnableDiscordPresence " , false ) ;
2021-12-13 12:12:54 +00:00
2022-02-15 14:29:18 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . startFullscreen , " UI " , " StartFullscreen " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . doubleClickTogglesFullscreen , " UI " , " DoubleClickTogglesFullscreen " ,
2021-12-13 12:12:54 +00:00
true ) ;
2022-02-15 14:29:18 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . hideMouseCursor , " UI " , " HideMouseCursor " , false ) ;
2022-06-28 11:37:30 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . renderToSeparateWindow , " UI " , " RenderToSeparateWindow " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . hideMainWindow , " UI " , " HideMainWindowWhenRunning " , false ) ;
2022-06-28 12:16:45 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . disableWindowResizing , " UI " , " DisableWindowResize " , false ) ;
2022-06-28 11:37:30 +00:00
connect ( m_ui . renderToSeparateWindow , & QCheckBox : : stateChanged , this , & InterfaceSettingsWidget : : onRenderToSeparateWindowChanged ) ;
2021-12-13 12:12:54 +00:00
2022-02-15 14:29:18 +00:00
SettingWidgetBinder : : BindWidgetToEnumSetting ( sif , m_ui . theme , " UI " , " Theme " , THEME_NAMES , THEME_VALUES ,
2023-06-30 12:42:48 +00:00
QtHost : : GetDefaultThemeName ( ) , " InterfaceSettingsWidget " ) ;
2021-12-13 12:12:54 +00:00
connect ( m_ui . theme , QOverload < int > : : of ( & QComboBox : : currentIndexChanged ) , [ this ] ( ) { emit themeChanged ( ) ; } ) ;
2023-06-19 12:03:10 +00:00
populateLanguages ( ) ;
SettingWidgetBinder : : BindWidgetToStringSetting ( sif , m_ui . language , " UI " , " Language " , QtHost : : GetDefaultLanguage ( ) ) ;
connect ( m_ui . language , QOverload < int > : : of ( & QComboBox : : currentIndexChanged ) , [ this ] ( ) { emit languageChanged ( ) ; } ) ;
2022-11-23 13:20:49 +00:00
// Per-game settings is special, we don't want to bind it if we're editing per-game settings.
m_ui . perGameSettings - > setEnabled ( ! dialog - > isPerGameSettings ( ) ) ;
if ( ! dialog - > isPerGameSettings ( ) )
{
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . pauseOnStart , " UI " , " StartPaused " , false ) ;
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . perGameSettings , " EmuCore " , " EnablePerGameSettings " , true ) ;
connect ( m_ui . perGameSettings , & QCheckBox : : stateChanged , g_emu_thread , & EmuThread : : reloadGameSettings ) ;
}
2021-12-13 12:12:54 +00:00
2022-10-22 03:43:26 +00:00
if ( ! dialog - > isPerGameSettings ( ) & & AutoUpdaterDialog : : isSupported ( ) )
2021-12-13 12:12:54 +00:00
{
2022-02-15 14:29:18 +00:00
SettingWidgetBinder : : BindWidgetToBoolSetting ( sif , m_ui . autoUpdateEnabled , " AutoUpdater " , " CheckAtStartup " , true ) ;
2021-12-13 12:12:54 +00:00
dialog - > registerWidgetHelp ( m_ui . autoUpdateEnabled , tr ( " Enable Automatic Update Check " ) , tr ( " Checked " ) ,
tr ( " Automatically checks for updates to the program on startup. Updates can be deferred "
" until later or skipped entirely. " ) ) ;
2022-04-04 11:27:23 +00:00
m_ui . autoUpdateTag - > addItems ( AutoUpdaterDialog : : getTagList ( ) ) ;
SettingWidgetBinder : : BindWidgetToStringSetting ( sif , m_ui . autoUpdateTag , " AutoUpdater " , " UpdateTag " ,
AutoUpdaterDialog : : getDefaultTag ( ) ) ;
2021-12-13 12:12:54 +00:00
2023-03-18 21:14:55 +00:00
//: Variable %1 shows the version number and variable %2 shows a timestamp.
2022-04-04 11:27:23 +00:00
m_ui . autoUpdateCurrentVersion - > setText ( tr ( " %1 (%2) " ) . arg ( AutoUpdaterDialog : : getCurrentVersion ( ) ) . arg ( AutoUpdaterDialog : : getCurrentVersionDate ( ) ) ) ;
2023-01-26 15:25:37 +00:00
connect ( m_ui . checkForUpdates , & QPushButton : : clicked , this , [ ] ( ) { g_main_window - > checkForUpdates ( true , true ) ; } ) ;
2021-12-13 12:12:54 +00:00
}
else
{
m_ui . verticalLayout - > removeWidget ( m_ui . automaticUpdaterGroup ) ;
m_ui . automaticUpdaterGroup - > hide ( ) ;
}
2022-10-22 03:43:26 +00:00
if ( dialog - > isPerGameSettings ( ) )
{
// language/theme doesn't make sense to have in per-game settings
m_ui . verticalLayout - > removeWidget ( m_ui . preferencesGroup ) ;
m_ui . preferencesGroup - > hide ( ) ;
// start paused doesn't make sense, because settings are applied after ELF load.
m_ui . pauseOnStart - > setEnabled ( false ) ;
}
2022-11-23 13:20:49 +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. " ) ) ;
2021-12-13 12:12:54 +00:00
dialog - > registerWidgetHelp (
2022-03-04 10:40:03 +00:00
m_ui . confirmShutdown , tr ( " Confirm Shutdown " ) , tr ( " Checked " ) ,
tr ( " Determines whether a prompt will be displayed to confirm shutting down the virtual machine "
2021-12-13 12:12:54 +00:00
" when the hotkey is pressed. " ) ) ;
2023-02-14 10:30:34 +00:00
dialog - > registerWidgetHelp ( m_ui . saveStateOnShutdown , tr ( " Save State On Shutdown " ) , tr ( " Unchecked " ) ,
2021-12-13 12:12:54 +00:00
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 . pauseOnStart , tr ( " Pause On Start " ) , tr ( " Unchecked " ) ,
tr ( " Pauses the emulator when a game is started. " ) ) ;
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. " ) ) ;
2023-03-22 13:25:31 +00:00
dialog - > registerWidgetHelp ( m_ui . backupSaveStates , tr ( " Create Save State Backups " ) , tr ( " Checked " ) ,
2023-03-18 21:14:55 +00:00
//: Do not translate the ".backup" extension.
2022-10-01 13:46:53 +00:00
tr ( " Creates a backup copy of a save state if it already exists when the save is created. The backup copy has a .backup suffix. " ) ) ;
2021-12-13 12:12:54 +00:00
dialog - > registerWidgetHelp ( m_ui . startFullscreen , tr ( " Start Fullscreen " ) , tr ( " Unchecked " ) ,
tr ( " Automatically switches to fullscreen mode when a game is started. " ) ) ;
2023-03-22 13:25:31 +00:00
dialog - > registerWidgetHelp ( m_ui . hideMouseCursor , tr ( " Hide Cursor In Fullscreen " ) , tr ( " Unchecked " ) ,
2021-12-13 12:12:54 +00:00
tr ( " Hides the mouse pointer/cursor when the emulator is in fullscreen mode. " ) ) ;
dialog - > registerWidgetHelp (
2022-06-28 11:37:30 +00:00
m_ui . renderToSeparateWindow , tr ( " Render To Separate Window " ) , tr ( " Unchecked " ) ,
tr ( " Renders the game to a separate window, instead of the main window. If unchecked, the game will display over the top of the game list. " ) ) ;
dialog - > registerWidgetHelp (
m_ui . hideMainWindow , tr ( " Hide Main Window When Running " ) , tr ( " Unchecked " ) ,
tr ( " Hides the main window (with the game list) when a game is running, requires Render To Separate Window to be enabled. " ) ) ;
2022-11-23 13:20:49 +00:00
dialog - > registerWidgetHelp ( m_ui . perGameSettings , tr ( " Enable Per-Game Settings " ) , tr ( " Checked " ) ,
2023-03-13 00:34:20 +00:00
tr ( " When enabled, custom per-game settings will be applied. Disable to always use the global configuration. " ) ) ;
2022-10-01 12:28:48 +00:00
dialog - > registerWidgetHelp (
m_ui . discordPresence , tr ( " Enable Discord Presence " ) , tr ( " Unchecked " ) ,
tr ( " Shows the game you are currently playing as part of your profile in Discord. " ) ) ;
2023-04-01 10:25:09 +00:00
dialog - > registerWidgetHelp (
m_ui . doubleClickTogglesFullscreen , tr ( " Double-Click Toggles Fullscreen " ) , tr ( " Checked " ) ,
tr ( " Allows switching in and out of fullscreen mode by double-clicking the game window. " ) ) ;
dialog - > registerWidgetHelp (
m_ui . disableWindowResizing , tr ( " Disable Window Resizing " ) , tr ( " Unchecked " ) ,
tr ( " Prevents the main window from being resized. " ) ) ;
2022-06-28 11:37:30 +00:00
onRenderToSeparateWindowChanged ( ) ;
2021-12-13 12:12:54 +00:00
}
InterfaceSettingsWidget : : ~ InterfaceSettingsWidget ( ) = default ;
2022-06-28 11:37:30 +00:00
void InterfaceSettingsWidget : : onRenderToSeparateWindowChanged ( )
{
m_ui . hideMainWindow - > setEnabled ( m_ui . renderToSeparateWindow - > isChecked ( ) ) ;
}
2023-06-19 12:03:10 +00:00
void InterfaceSettingsWidget : : populateLanguages ( )
{
for ( const std : : pair < QString , QString > & it : QtHost : : GetAvailableLanguageList ( ) )
m_ui . language - > addItem ( it . first , it . second ) ;
}