/* 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 . */ #include "PrecompiledHeader.h" #include "QtHost.h" #include "SettingsDialog.h" #include "AdvancedSystemSettingsWidget.h" #include "BIOSSettingsWidget.h" #include "EmulationSettingsWidget.h" #include "GameFixSettingsWidget.h" #include "GameListSettingsWidget.h" #include "GraphicsSettingsWidget.h" #include "HotkeySettingsWidget.h" #include "InterfaceSettingsWidget.h" #include "SystemSettingsWidget.h" #include #include static constexpr char DEFAULT_SETTING_HELP_TEXT[] = ""; SettingsDialog::SettingsDialog(QWidget* parent /* = nullptr */) : QDialog(parent) { m_ui.setupUi(this); setCategoryHelpTexts(); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_interface_settings = new InterfaceSettingsWidget(m_ui.settingsContainer, this); m_game_list_settings = new GameListSettingsWidget(m_ui.settingsContainer, this); m_bios_settings = new BIOSSettingsWidget(m_ui.settingsContainer, this); m_emulation_settings = new EmulationSettingsWidget(m_ui.settingsContainer, this); m_system_settings = new SystemSettingsWidget(m_ui.settingsContainer, this); m_advanced_system_settings = new AdvancedSystemSettingsWidget(m_ui.settingsContainer, this); m_game_fix_settings_widget = new GameFixSettingsWidget(m_ui.settingsContainer, this); m_graphics_settings = new GraphicsSettingsWidget(m_ui.settingsContainer, this); m_ui.settingsContainer->insertWidget(static_cast(Category::InterfaceSettings), m_interface_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::GameListSettings), m_game_list_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::BIOSSettings), m_bios_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::EmulationSettings), m_emulation_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::SystemSettings), m_system_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::AdvancedSystemSettings), m_advanced_system_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::GameFixSettings), m_game_fix_settings_widget); m_ui.settingsContainer->insertWidget(static_cast(Category::GraphicsSettings), m_graphics_settings); m_ui.settingsCategory->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_ui.settingsCategory->setCurrentRow(0); m_ui.settingsContainer->setCurrentIndex(0); m_ui.helpText->setText(m_category_help_text[0]); connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsDialog::onCategoryCurrentRowChanged); connect(m_ui.closeButton, &QPushButton::clicked, this, &SettingsDialog::accept); connect(m_ui.restoreDefaultsButton, &QPushButton::clicked, this, &SettingsDialog::onRestoreDefaultsClicked); } SettingsDialog::~SettingsDialog() = default; void SettingsDialog::setCategoryHelpTexts() { m_category_help_text[static_cast(Category::InterfaceSettings)] = tr("Interface Settings
These options control how the software looks and behaves.

Mouse " "over " "an option for additional information."); m_category_help_text[static_cast(Category::SystemSettings)] = tr("System Settings
These options determine the configuration of the simulated " "console.

Mouse over an option for additional information."); m_category_help_text[static_cast(Category::GameListSettings)] = tr("Game List Settings
The list above shows the directories which will be searched by " "PCSX2 to populate the game list. Search directories can be added, removed, and switched to " "recursive/non-recursive."); m_category_help_text[static_cast(Category::AudioSettings)] = tr("Audio Settings
These options control the audio output of the console. Mouse over an option " "for additional information."); } void SettingsDialog::setCategory(Category category) { if (category >= Category::Count) return; m_ui.settingsCategory->setCurrentRow(static_cast(category)); } void SettingsDialog::onCategoryCurrentRowChanged(int row) { Q_ASSERT(row < static_cast(Category::Count)); m_ui.settingsContainer->setCurrentIndex(row); m_ui.helpText->setText(m_category_help_text[row]); } void SettingsDialog::onRestoreDefaultsClicked() { if (QMessageBox::question(this, tr("Confirm Restore Defaults"), tr("Are you sure you want to restore the default settings? Any preferences will be lost."), QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes) { return; } // TODO } void SettingsDialog::registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text) { // construct rich text with formatted description QString full_text; full_text += "
"; full_text += title; full_text += ""; full_text += tr("Recommended Value"); full_text += ": "; full_text += recommended_value; full_text += "

"; full_text += text; m_widget_help_text_map[object] = std::move(full_text); object->installEventFilter(this); } bool SettingsDialog::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::Enter) { auto iter = m_widget_help_text_map.constFind(object); if (iter != m_widget_help_text_map.end()) { m_current_help_widget = object; m_ui.helpText->setText(iter.value()); } } else if (event->type() == QEvent::Leave) { if (m_current_help_widget) { m_current_help_widget = nullptr; m_ui.helpText->setText(m_category_help_text[m_ui.settingsCategory->currentRow()]); } } return QDialog::eventFilter(object, event); }