Qt: Split some console settings out into general settings

This commit is contained in:
Connor McLaughlin 2020-03-22 13:16:32 +10:00
parent bf2f9bd8d9
commit a4a5d3ef79
13 changed files with 252 additions and 131 deletions

View File

@ -15,6 +15,9 @@ add_executable(duckstation-qt
gamelistsettingswidget.ui
gamelistwidget.cpp
gamelistwidget.h
generalsettingswidget.cpp
generalsettingswidget.h
generalsettingswidget.ui
gpusettingswidget.cpp
gpusettingswidget.h
gpusettingswidget.ui

View File

@ -20,27 +20,11 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, "BIOS/Path");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableTTYOutput, "BIOS/PatchTTYEnable");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, "BIOS/PatchFastBoot");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, "Main/SpeedLimiterEnabled");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.increaseTimerResolution,
"Main/IncreaseTimerResolution");
SettingWidgetBinder::BindWidgetToNormalizedSetting(m_host_interface, m_ui.emulationSpeed, "Main/EmulationSpeed",
100.0f);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "Main/StartPaused");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startFullscreen, "Main/StartFullscreen");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, "Main/SaveStateOnExit");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, "Main/ConfirmPowerOff");
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU/ExecutionMode",
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromReadThread, "CDROM/ReadThread");
connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked);
connect(m_ui.enableSpeedLimiter, &QCheckBox::stateChanged, this,
&ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged);
connect(m_ui.emulationSpeed, &QSlider::valueChanged, this, &ConsoleSettingsWidget::onEmulationSpeedValueChanged);
onEnableSpeedLimiterStateChanged();
onEmulationSpeedValueChanged(m_ui.emulationSpeed->value());
}
ConsoleSettingsWidget::~ConsoleSettingsWidget() = default;
@ -56,13 +40,3 @@ void ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked()
m_host_interface->putSettingValue("BIOS/Path", path);
m_host_interface->applySettings();
}
void ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged()
{
m_ui.emulationSpeed->setDisabled(!m_ui.enableSpeedLimiter->isChecked());
}
void ConsoleSettingsWidget::onEmulationSpeedValueChanged(int value)
{
m_ui.emulationSpeedLabel->setText(tr("%1%").arg(value));
}

View File

@ -16,8 +16,6 @@ public:
private Q_SLOTS:
void onBrowseBIOSPathButtonClicked();
void onEnableSpeedLimiterStateChanged();
void onEmulationSpeedValueChanged(int value);
private:
Ui::ConsoleSettingsWidget m_ui;

View File

@ -80,103 +80,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Behaviour</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="emulationSpeed">
<property name="minimum">
<number>25</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
<property name="pageStep">
<number>25</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="emulationSpeedLabel">
<property name="text">
<string>100%</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="enableSpeedLimiter">
<property name="text">
<string>Enable Speed Limiter</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="increaseTimerResolution">
<property name="text">
<string>Increase Timer Resolution</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="pauseOnStart">
<property name="text">
<string>Pause On Start</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="startFullscreen">
<property name="text">
<string>Start Fullscreen</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="saveStateOnExit">
<property name="text">
<string>Save State On Exit</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="confirmPowerOff">
<property name="text">
<string>Confirm Power Off</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">

View File

@ -38,6 +38,7 @@
<ClCompile Include="audiosettingswidget.cpp" />
<ClCompile Include="consolesettingswidget.cpp" />
<ClCompile Include="d3d11displaywidget.cpp" />
<ClCompile Include="generalsettingswidget.cpp" />
<ClCompile Include="gpusettingswidget.cpp" />
<ClCompile Include="hotkeysettingswidget.cpp" />
<ClCompile Include="inputbindingwidgets.cpp" />
@ -58,6 +59,7 @@
<QtMoc Include="audiosettingswidget.h" />
<QtMoc Include="portsettingswidget.h" />
<QtMoc Include="qtdisplaywidget.h" />
<QtMoc Include="generalsettingswidget.h" />
<QtMoc Include="gpusettingswidget.h" />
<QtMoc Include="hotkeysettingswidget.h" />
<QtMoc Include="inputbindingwidgets.h" />
@ -104,6 +106,9 @@
<QtUi Include="gamelistsettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="generalsettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="mainwindow.ui">
<FileType>Document</FileType>
</QtUi>
@ -122,6 +127,7 @@
<ClCompile Include="$(IntDir)moc_d3d11displaywidget.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistwidget.cpp" />
<ClCompile Include="$(IntDir)moc_generalsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_gpusettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_hotkeysettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_inputbindingwidgets.cpp" />

View File

@ -0,0 +1,39 @@
#include "generalsettingswidget.h"
#include "settingwidgetbinder.h"
static constexpr char BIOS_IMAGE_FILTER[] = "Binary Images (*.bin);;All Files (*.*)";
GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
: QWidget(parent), m_host_interface(host_interface)
{
m_ui.setupUi(this);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, "Main/SpeedLimiterEnabled");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.increaseTimerResolution,
"Main/IncreaseTimerResolution");
SettingWidgetBinder::BindWidgetToNormalizedSetting(m_host_interface, m_ui.emulationSpeed, "Main/EmulationSpeed",
100.0f);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "Main/StartPaused");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startFullscreen, "Main/StartFullscreen");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.saveStateOnExit, "Main/SaveStateOnExit");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.confirmPowerOff, "Main/ConfirmPowerOff");
connect(m_ui.enableSpeedLimiter, &QCheckBox::stateChanged, this,
&GeneralSettingsWidget::onEnableSpeedLimiterStateChanged);
connect(m_ui.emulationSpeed, &QSlider::valueChanged, this, &GeneralSettingsWidget::onEmulationSpeedValueChanged);
onEnableSpeedLimiterStateChanged();
onEmulationSpeedValueChanged(m_ui.emulationSpeed->value());
}
GeneralSettingsWidget::~GeneralSettingsWidget() = default;
void GeneralSettingsWidget::onEnableSpeedLimiterStateChanged()
{
m_ui.emulationSpeed->setDisabled(!m_ui.enableSpeedLimiter->isChecked());
}
void GeneralSettingsWidget::onEmulationSpeedValueChanged(int value)
{
m_ui.emulationSpeedLabel->setText(tr("%1%").arg(value));
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <QtWidgets/QWidget>
#include "ui_generalsettingswidget.h"
class QtHostInterface;
class GeneralSettingsWidget : public QWidget
{
Q_OBJECT
public:
explicit GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
~GeneralSettingsWidget();
private Q_SLOTS:
void onEnableSpeedLimiterStateChanged();
void onEmulationSpeedValueChanged(int value);
private:
Ui::GeneralSettingsWidget m_ui;
QtHostInterface* m_host_interface;
};

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralSettingsWidget</class>
<widget class="QWidget" name="GeneralSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Behaviour</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="emulationSpeed">
<property name="minimum">
<number>25</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
<property name="pageStep">
<number>25</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>25</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="emulationSpeedLabel">
<property name="text">
<string>100%</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="enableSpeedLimiter">
<property name="text">
<string>Enable Speed Limiter</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="increaseTimerResolution">
<property name="text">
<string>Increase Timer Resolution</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="pauseOnStart">
<property name="text">
<string>Pause On Start</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="startFullscreen">
<property name="text">
<string>Start Fullscreen</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="saveStateOnExit">
<property name="text">
<string>Save State On Exit</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="confirmPowerOff">
<property name="text">
<string>Confirm Power Off</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="resources/icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -443,6 +443,8 @@ void MainWindow::connectSignals()
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::close);
connect(m_ui.actionFullscreen, &QAction::triggered, this, &MainWindow::toggleFullscreen);
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::Count); });
connect(m_ui.actionGeneralSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::GeneralSettings); });
connect(m_ui.actionConsoleSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::ConsoleSettings); });
connect(m_ui.actionGameListSettings, &QAction::triggered,

View File

@ -85,6 +85,7 @@
</property>
<addaction name="actionFullscreen"/>
<addaction name="separator"/>
<addaction name="actionGeneralSettings"/>
<addaction name="actionConsoleSettings"/>
<addaction name="actionGameListSettings"/>
<addaction name="actionHotkeySettings"/>
@ -345,6 +346,15 @@
<string>Game List Settings...</string>
</property>
</action>
<action name="actionGeneralSettings">
<property name="icon">
<iconset resource="resources/icons.qrc">
<normaloff>:/icons/applications-system.png</normaloff>:/icons/applications-system.png</iconset>
</property>
<property name="text">
<string>General Settings...</string>
</property>
</action>
<action name="actionAddGameDirectory">
<property name="icon">
<iconset resource="resources/icons.qrc">

View File

@ -2,6 +2,7 @@
#include "audiosettingswidget.h"
#include "consolesettingswidget.h"
#include "gamelistsettingswidget.h"
#include "generalsettingswidget.h"
#include "gpusettingswidget.h"
#include "hotkeysettingswidget.h"
#include "portsettingswidget.h"
@ -13,6 +14,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
{
m_ui.setupUi(this);
m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer);
m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer);
m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer);
m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer);
@ -20,12 +22,13 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_gpu_settings = new GPUSettingsWidget(host_interface, m_ui.settingsContainer);
m_audio_settings = new AudioSettingsWidget(host_interface, m_ui.settingsContainer);
m_ui.settingsContainer->insertWidget(0, m_console_settings);
m_ui.settingsContainer->insertWidget(1, m_game_list_settings);
m_ui.settingsContainer->insertWidget(2, m_hotkey_settings);
m_ui.settingsContainer->insertWidget(3, m_port_settings);
m_ui.settingsContainer->insertWidget(4, m_gpu_settings);
m_ui.settingsContainer->insertWidget(5, m_audio_settings);
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);
m_ui.settingsCategory->setCurrentRow(0);
m_ui.settingsContainer->setCurrentIndex(0);

View File

@ -5,6 +5,7 @@
class QtHostInterface;
class GeneralSettingsWidget;
class GameListSettingsWidget;
class HotkeySettingsWidget;
class ConsoleSettingsWidget;
@ -19,6 +20,7 @@ class SettingsDialog : public QDialog
public:
enum class Category
{
GeneralSettings,
ConsoleSettings,
GameListSettings,
HotkeySettings,
@ -31,6 +33,7 @@ public:
SettingsDialog(QtHostInterface* host_interface, QWidget* parent = nullptr);
~SettingsDialog();
GeneralSettingsWidget* getGeneralSettingsWidget() const { return m_general_settings; }
ConsoleSettingsWidget* getConsoleSettingsWidget() const { return m_console_settings; }
GameListSettingsWidget* getGameListSettingsWidget() const { return m_game_list_settings; }
HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }
@ -49,6 +52,7 @@ private:
QtHostInterface* m_host_interface;
GeneralSettingsWidget* m_general_settings = nullptr;
ConsoleSettingsWidget* m_console_settings = nullptr;
GameListSettingsWidget* m_game_list_settings = nullptr;
HotkeySettingsWidget* m_hotkey_settings = nullptr;

View File

@ -40,6 +40,15 @@
<height>32</height>
</size>
</property>
<item>
<property name="text">
<string>General Settings</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/applications-system.png</normaloff>:/icons/applications-system.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Console Settings</string>