2019-12-31 06:17:17 +00:00
|
|
|
#include "settingsdialog.h"
|
2020-01-24 04:51:13 +00:00
|
|
|
#include "audiosettingswidget.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "consolesettingswidget.h"
|
|
|
|
#include "gamelistsettingswidget.h"
|
2020-03-22 03:16:32 +00:00
|
|
|
#include "generalsettingswidget.h"
|
2020-01-03 07:51:58 +00:00
|
|
|
#include "gpusettingswidget.h"
|
2020-01-05 02:46:03 +00:00
|
|
|
#include "hotkeysettingswidget.h"
|
2020-01-02 06:13:03 +00:00
|
|
|
#include "portsettingswidget.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "qthostinterface.h"
|
|
|
|
#include <QtWidgets/QTextEdit>
|
|
|
|
|
2020-03-22 03:16:56 +00:00
|
|
|
static constexpr char DEFAULT_SETTING_HELP_TEXT[] = "Mouse over an option for additional information.";
|
|
|
|
|
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-03-22 03:17:03 +00:00
|
|
|
m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer, this);
|
2020-01-24 04:50:51 +00:00
|
|
|
m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer);
|
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-01-02 06:13:03 +00:00
|
|
|
m_port_settings = new PortSettingsWidget(host_interface, m_ui.settingsContainer);
|
2020-01-03 07:51:58 +00:00
|
|
|
m_gpu_settings = new GPUSettingsWidget(host_interface, m_ui.settingsContainer);
|
2020-01-24 04:51:13 +00:00
|
|
|
m_audio_settings = new AudioSettingsWidget(host_interface, m_ui.settingsContainer);
|
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);
|
|
|
|
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);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::PortSettings), m_port_settings);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::GPUSettings), m_gpu_settings);
|
|
|
|
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::AudioSettings), m_audio_settings);
|
2019-12-31 06:17:17 +00:00
|
|
|
|
|
|
|
m_ui.settingsCategory->setCurrentRow(0);
|
|
|
|
m_ui.settingsContainer->setCurrentIndex(0);
|
|
|
|
connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsDialog::onCategoryCurrentRowChanged);
|
2020-03-22 03:16:56 +00:00
|
|
|
|
|
|
|
m_ui.helpText->setText(tr(DEFAULT_SETTING_HELP_TEXT));
|
2019-12-31 06:17:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SettingsDialog::~SettingsDialog() = default;
|
|
|
|
|
|
|
|
void SettingsDialog::setCategory(Category category)
|
|
|
|
{
|
|
|
|
if (category >= Category::Count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_ui.settingsCategory->setCurrentRow(static_cast<int>(category));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::onCategoryCurrentRowChanged(int row)
|
|
|
|
{
|
|
|
|
m_ui.settingsContainer->setCurrentIndex(row);
|
|
|
|
}
|
2020-03-22 03:16:56 +00:00
|
|
|
|
|
|
|
void SettingsDialog::registerWidgetHelp(QObject* object, const char* title, const char* recommended_value,
|
|
|
|
const char* text)
|
|
|
|
{
|
|
|
|
// construct rich text with formatted description
|
|
|
|
QString full_text;
|
|
|
|
full_text += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td><strong>";
|
|
|
|
full_text += tr(title);
|
|
|
|
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;
|
|
|
|
m_ui.helpText->setText(tr(DEFAULT_SETTING_HELP_TEXT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return QDialog::eventFilter(object, event);
|
|
|
|
}
|