Qt: Skeleton for audio settings

This commit is contained in:
Connor McLaughlin 2020-01-24 14:51:13 +10:00
parent c5faa36f43
commit 65ae85eb7b
7 changed files with 213 additions and 3 deletions

View File

@ -4,6 +4,9 @@ set(CMAKE_AUTOUIC ON)
add_executable(duckstation-qt
resources/icons.qrc
audiosettingswidget.cpp
audiosettingswidget.h
audiosettingswidget.ui
consolesettingswidget.cpp
consolesettingswidget.h
consolesettingswidget.ui

View File

@ -0,0 +1,14 @@
#include "audiosettingswidget.h"
#include "settingwidgetbinder.h"
AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
: QWidget(parent), m_host_interface(host_interface)
{
m_ui.setupUi(this);
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.audioBackend, "Audio/Backend",
&Settings::ParseAudioBackend, &Settings::GetAudioBackendName);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToOutput, "Audio/Sync");
}
AudioSettingsWidget::~AudioSettingsWidget() = default;

View File

@ -0,0 +1,21 @@
#pragma once
#include <QtWidgets/QWidget>
#include "ui_audiosettingswidget.h"
class QtHostInterface;
class AudioSettingsWidget : public QWidget
{
Q_OBJECT
public:
explicit AudioSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
~AudioSettingsWidget();
private:
Ui::AudioSettingsWidget m_ui;
QtHostInterface* m_host_interface;
};

View File

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AudioSettingsWidget</class>
<widget class="QWidget" name="AudioSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>308</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">
<property name="title">
<string>Configuration</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Backend:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="audioBackend"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Buffer Size:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="bufferSize">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QLabel" name="bufferSizeLabel">
<property name="text">
<string>2048 samples</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="syncToOutput">
<property name="text">
<string>Sync To Output</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Controls</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Volume:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="volume">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Mute</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="volumeLabel">
<property name="text">
<string>100%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</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

@ -35,6 +35,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="audiosettingswidget.cpp" />
<ClCompile Include="consolesettingswidget.cpp" />
<ClCompile Include="d3d11displaywindow.cpp" />
<ClCompile Include="gpusettingswidget.cpp" />
@ -53,6 +54,7 @@
<ClCompile Include="settingsdialog.cpp" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="audiosettingswidget.h" />
<QtMoc Include="portsettingswidget.h" />
<QtMoc Include="qtdisplaywindow.h" />
<QtMoc Include="gpusettingswidget.h" />
@ -85,6 +87,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<QtUi Include="audiosettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="consolesettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
@ -104,6 +109,7 @@
</QtResource>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(IntDir)moc_audiosettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_consolesettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_d3d11displaywindow.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistsettingswidget.cpp" />

View File

@ -1,4 +1,5 @@
#include "settingsdialog.h"
#include "audiosettingswidget.h"
#include "consolesettingswidget.h"
#include "gamelistsettingswidget.h"
#include "gpusettingswidget.h"
@ -17,7 +18,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer);
m_port_settings = new PortSettingsWidget(host_interface, m_ui.settingsContainer);
m_gpu_settings = new GPUSettingsWidget(host_interface, m_ui.settingsContainer);
m_audio_settings = new QWidget(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);

View File

@ -10,6 +10,7 @@ class HotkeySettingsWidget;
class ConsoleSettingsWidget;
class PortSettingsWidget;
class GPUSettingsWidget;
class AudioSettingsWidget;
class SettingsDialog : public QDialog
{
@ -35,7 +36,7 @@ public:
HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }
PortSettingsWidget* getPortSettingsWidget() const { return m_port_settings; }
GPUSettingsWidget* getGPUSettingsWidget() const { return m_gpu_settings; }
QWidget* getAudioSettingsWidget() const { return m_audio_settings; }
AudioSettingsWidget* getAudioSettingsWidget() const { return m_audio_settings; }
public Q_SLOTS:
void setCategory(Category category);
@ -53,5 +54,5 @@ private:
HotkeySettingsWidget* m_hotkey_settings = nullptr;
PortSettingsWidget* m_port_settings = nullptr;
GPUSettingsWidget* m_gpu_settings = nullptr;
QWidget* m_audio_settings = nullptr;
AudioSettingsWidget* m_audio_settings = nullptr;
};