2019-12-31 06:17:17 +00:00
|
|
|
#include "settingsdialog.h"
|
2020-04-30 14:59:31 +00:00
|
|
|
#include "advancedsettingswidget.h"
|
2020-01-24 04:51:13 +00:00
|
|
|
#include "audiosettingswidget.h"
|
2020-09-22 13:08:07 +00:00
|
|
|
#include "biossettingswidget.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "consolesettingswidget.h"
|
2020-05-20 13:26:24 +00:00
|
|
|
#include "controllersettingswidget.h"
|
2020-09-10 14:18:12 +00:00
|
|
|
#include "displaysettingswidget.h"
|
|
|
|
#include "enhancementsettingswidget.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "gamelistsettingswidget.h"
|
2020-03-22 03:16:32 +00:00
|
|
|
#include "generalsettingswidget.h"
|
2020-01-05 02:46:03 +00:00
|
|
|
#include "hotkeysettingswidget.h"
|
2020-05-20 13:26:24 +00:00
|
|
|
#include "memorycardsettingswidget.h"
|
2020-09-13 12:24:20 +00:00
|
|
|
#include "postprocessingsettingswidget.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "qthostinterface.h"
|
|
|
|
#include <QtWidgets/QTextEdit>
|
|
|
|
|
2020-03-22 12:19:46 +00:00
|
|
|
static constexpr char DEFAULT_SETTING_HELP_TEXT[] = "";
|
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
|
|
|
|
: QDialog(parent), m_host_interface(host_interface)
|
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
2020-07-28 09:32:07 +00:00
|
|
|
setCategoryHelpTexts();
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-03-22 12:40:45 +00:00
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
2020-03-22 03:17:03 +00:00
|
|
|
m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-09-22 13:08:07 +00:00
|
|
|
m_bios_settings = new BIOSSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-08-10 12:40:38 +00:00
|
|
|
m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2019-12-31 06:17:17 +00:00
|
|
|
m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer);
|
2020-01-05 02:46:03 +00:00
|
|
|
m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer);
|
2020-05-20 13:26:24 +00:00
|
|
|
m_controller_settings = new ControllerSettingsWidget(host_interface, m_ui.settingsContainer);
|
2020-08-15 10:38:54 +00:00
|
|
|
m_memory_card_settings = new MemoryCardSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-09-10 14:18:12 +00:00
|
|
|
m_display_settings = new DisplaySettingsWidget(host_interface, m_ui.settingsContainer, this);
|
|
|
|
m_enhancement_settings = new EnhancementSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-09-13 12:24:20 +00:00
|
|
|
m_post_processing_settings = new PostProcessingSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-06-06 15:30:05 +00:00
|
|
|
m_audio_settings = new AudioSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-04-30 14:59:31 +00:00
|
|
|
m_advanced_settings = new AdvancedSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-03-22 03:16:32 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::GeneralSettings), m_general_settings);
|
2020-09-22 13:08:07 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::BIOSSettings), m_bios_settings);
|
2020-03-22 03:16:32 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::ConsoleSettings), m_console_settings);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::GameListSettings), m_game_list_settings);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::HotkeySettings), m_hotkey_settings);
|
2020-05-20 13:26:24 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::ControllerSettings), m_controller_settings);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::MemoryCardSettings), m_memory_card_settings);
|
2020-09-10 14:18:12 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::DisplaySettings), m_display_settings);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::EnhancementSettings), m_enhancement_settings);
|
2020-09-13 12:24:20 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::PostProcessingSettings), m_post_processing_settings);
|
2020-03-22 03:16:32 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::AudioSettings), m_audio_settings);
|
2020-04-30 14:59:31 +00:00
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::AdvancedSettings), m_advanced_settings);
|
2019-12-31 06:17:17 +00:00
|
|
|
|
|
|
|
m_ui.settingsCategory->setCurrentRow(0);
|
|
|
|
m_ui.settingsContainer->setCurrentIndex(0);
|
2020-07-28 09:32:07 +00:00
|
|
|
m_ui.helpText->setText(m_category_help_text[0]);
|
2019-12-31 06:17:17 +00:00
|
|
|
connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsDialog::onCategoryCurrentRowChanged);
|
2020-10-02 15:13:18 +00:00
|
|
|
connect(m_ui.closeButton, &QPushButton::clicked, this, &SettingsDialog::accept);
|
2019-12-31 06:17:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SettingsDialog::~SettingsDialog() = default;
|
|
|
|
|
2020-07-28 09:32:07 +00:00
|
|
|
void SettingsDialog::setCategoryHelpTexts()
|
|
|
|
{
|
|
|
|
m_category_help_text[static_cast<int>(Category::GeneralSettings)] = tr(
|
|
|
|
"<strong>General Settings</strong><hr>These options control how the emulator looks and behaves.<br><br>Mouse over "
|
|
|
|
"an option for additional information.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::ConsoleSettings)] =
|
|
|
|
tr("<strong>Console Settings</strong><hr>These options determine the configuration of the simulated "
|
|
|
|
"console.<br><br>Mouse over an option for additional information.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::GameListSettings)] =
|
|
|
|
tr("<strong>Game List Settings</strong><hr>The list above shows the directories which will be searched by "
|
|
|
|
"DuckStation "
|
|
|
|
"to populate the game list. Search directories can be added, removed, and switched to recursive/non-recursive. "
|
|
|
|
"Additionally, the redump.org database can be downloaded or updated to provide titles for discs, as the discs "
|
|
|
|
"themselves do not provide title information.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::HotkeySettings)] = tr(
|
|
|
|
"<strong>Hotkey Settings</strong><hr>Binding a hotkey allows you to trigger events such as a resetting or taking "
|
|
|
|
"screenshots at the press of a key/controller button. Hotkey titles are self-explanatory. Clicking a binding will "
|
|
|
|
"start a countdown, in which case you should press the key or controller button/axis you wish to bind. If no "
|
|
|
|
"button is pressed and the timer lapses, the binding will be unchanged. To clear a binding, right-click the "
|
|
|
|
"button. To bind multiple buttons, hold Shift and click the button.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::ControllerSettings)] = tr(
|
|
|
|
"<strong>Controller Settings</strong><hr>This page lets you choose the type of controller you wish to simulate for "
|
|
|
|
"the console, and rebind the keys or host game controller buttons to your choosing. Clicking a binding will start "
|
|
|
|
"a countdown, in which case you should press the key or controller button/axis you wish to bind. (For rumble, "
|
|
|
|
"press any button/axis on the controller you wish to send rumble to.) If no button is pressed and the timer "
|
|
|
|
"lapses, the binding will be unchanged. To clear a binding, right-click the button. To bind multiple buttons, hold "
|
|
|
|
"Shift and click the button.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::MemoryCardSettings)] =
|
|
|
|
tr("<strong>Memory Card Settings</strong><hr>This page lets you control what mode the memory card emulation will "
|
|
|
|
"function in, and where the images for these cards will be stored on disk.");
|
2020-09-10 14:18:12 +00:00
|
|
|
m_category_help_text[static_cast<int>(Category::DisplaySettings)] =
|
|
|
|
tr("<strong>Display Settings</strong><hr>These options control the how the frames generated by the console are "
|
|
|
|
"displayed on the screen.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::EnhancementSettings)] =
|
|
|
|
tr("<strong>Enhancement Settings</strong><hr>These options control enhancements which can improve visuals compared "
|
|
|
|
"to the original console. Mouse over each option for additional information.");
|
2020-09-13 12:24:20 +00:00
|
|
|
m_category_help_text[static_cast<int>(Category::PostProcessingSettings)] =
|
|
|
|
tr("<strong>Post-Processing Settings</strong><hr>Post processing allows you to alter the appearance of the image "
|
|
|
|
"displayed on the screen with various filters. Shaders will be executed in sequence.");
|
2020-07-28 09:32:07 +00:00
|
|
|
m_category_help_text[static_cast<int>(Category::AudioSettings)] =
|
|
|
|
tr("<strong>Audio Settings</strong><hr>These options control the audio output of the console. Mouse over an option "
|
|
|
|
"for additional information.");
|
|
|
|
m_category_help_text[static_cast<int>(Category::AdvancedSettings)] = tr(
|
|
|
|
"<strong>Advanced Settings</strong><hr>These options control logging and internal behavior of the emulator. Mouse "
|
|
|
|
"over an option for additional information.");
|
|
|
|
}
|
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
void SettingsDialog::setCategory(Category category)
|
|
|
|
{
|
|
|
|
if (category >= Category::Count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_ui.settingsCategory->setCurrentRow(static_cast<int>(category));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::onCategoryCurrentRowChanged(int row)
|
|
|
|
{
|
2020-03-22 12:19:46 +00:00
|
|
|
Q_ASSERT(row < static_cast<int>(Category::Count));
|
2019-12-31 06:17:17 +00:00
|
|
|
m_ui.settingsContainer->setCurrentIndex(row);
|
2020-07-28 09:32:07 +00:00
|
|
|
m_ui.helpText->setText(m_category_help_text[row]);
|
2019-12-31 06:17:17 +00:00
|
|
|
}
|
2020-03-22 03:16:56 +00:00
|
|
|
|
2020-07-28 09:42:14 +00:00
|
|
|
void SettingsDialog::registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text)
|
2020-03-22 03:16:56 +00:00
|
|
|
{
|
|
|
|
// construct rich text with formatted description
|
|
|
|
QString full_text;
|
|
|
|
full_text += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td><strong>";
|
2020-07-28 09:42:14 +00:00
|
|
|
full_text += title;
|
2020-03-22 03:16:56 +00:00
|
|
|
full_text += "</strong></td><td align='right'><strong>";
|
|
|
|
full_text += tr("Recommended Value");
|
|
|
|
full_text += ": </strong>";
|
|
|
|
full_text += recommended_value;
|
|
|
|
full_text += "</td></table><hr>";
|
|
|
|
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;
|
2020-07-28 09:32:07 +00:00
|
|
|
m_ui.helpText->setText(m_category_help_text[m_ui.settingsCategory->currentRow()]);
|
2020-03-22 03:16:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return QDialog::eventFilter(object, event);
|
|
|
|
}
|