Qt: Move post processing to its own setting category

This commit is contained in:
Connor McLaughlin 2020-09-13 22:24:20 +10:00
parent 6ababf7e53
commit 441f26706e
24 changed files with 555 additions and 150 deletions

View File

@ -389,6 +389,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
Settings::GetDisplayAspectRatioName(Settings::DEFAULT_DISPLAY_ASPECT_RATIO));
si.SetBoolValue("Display", "LinearFiltering", true);
si.SetBoolValue("Display", "IntegerScaling", false);
si.SetBoolValue("Display", "PostProcessing", false);
si.SetBoolValue("Display", "ShowOSDMessages", true);
si.SetBoolValue("Display", "ShowFPS", false);
si.SetBoolValue("Display", "ShowVPS", false);

View File

@ -129,6 +129,7 @@ void Settings::Load(SettingsInterface& si)
display_active_end_offset = static_cast<s16>(si.GetIntValue("Display", "ActiveEndOffset", 0));
display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
display_integer_scaling = si.GetBoolValue("Display", "IntegerScaling", false);
display_post_processing = si.GetBoolValue("Display", "PostProcessing", false);
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
display_show_vps = si.GetBoolValue("Display", "ShowVPS", false);
@ -239,6 +240,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetStringValue("Display", "AspectRatio", GetDisplayAspectRatioName(display_aspect_ratio));
si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
si.SetBoolValue("Display", "IntegerScaling", display_integer_scaling);
si.SetBoolValue("Display", "PostProcessing", display_post_processing);
si.SetBoolValue("Display", "ShowOSDMessages", display_show_osd_messages);
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
si.SetBoolValue("Display", "ShowVPS", display_show_vps);

View File

@ -106,6 +106,7 @@ struct Settings
DisplayAspectRatio display_aspect_ratio = DisplayAspectRatio::R4_3;
bool display_linear_filtering = true;
bool display_integer_scaling = false;
bool display_post_processing = false;
bool display_show_osd_messages = false;
bool display_show_fps = false;
bool display_show_vps = false;

View File

@ -57,6 +57,9 @@ set(SRCS
postprocessingchainconfigwidget.cpp
postprocessingchainconfigwidget.h
postprocessingchainconfigwidget.ui
postprocessingsettingswidget.cpp
postprocessingsettingswidget.h
postprocessingsettingswidget.ui
postprocessingshaderconfigwidget.cpp
postprocessingshaderconfigwidget.h
qtdisplaywidget.cpp

View File

@ -47,25 +47,6 @@ DisplaySettingsWidget::DisplaySettingsWidget(QtHostInterface* host_interface, QW
&DisplaySettingsWidget::onGPUAdapterIndexChanged);
populateGPUAdapters();
{
std::string post_chain = g_host_interface->GetStringSettingValue("Display", "PostProcessChain");
if (!post_chain.empty() && !m_ui.postChain->setConfigString(post_chain))
{
QMessageBox::critical(this, tr("Error"),
tr("The current post-processing chain is invalid, it has been reset. Any changes made will "
"overwrite the existing config."));
}
}
connect(m_ui.postChain, &PostProcessingChainConfigWidget::chainConfigStringChanged,
[this](const std::string& new_config) {
if (new_config.empty())
m_host_interface->RemoveSettingValue("Display", "PostProcessChain");
else
m_host_interface->SetStringSettingValue("Display", "PostProcessChain", new_config.c_str());
m_host_interface->applySettings();
});
dialog->registerWidgetHelp(
m_ui.renderer, tr("Renderer"), Settings::GetRendererDisplayName(Settings::DEFAULT_GPU_RENDERER),
tr("Chooses the backend to use for rendering the console/game visuals. <br>Depending on your system and hardware, "

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>448</width>
<height>720</height>
<height>430</height>
</rect>
</property>
<property name="windowTitle">
@ -153,30 +153,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Post-Processing Chain</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<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 row="0" column="0">
<widget class="PostProcessingChainConfigWidget" name="postChain" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -192,14 +168,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PostProcessingChainConfigWidget</class>
<extends>QWidget</extends>
<header>duckstation-qt/postprocessingchainconfigwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -58,6 +58,7 @@
<ClCompile Include="memorycardsettingswidget.cpp" />
<ClCompile Include="postprocessingchainconfigwidget.cpp" />
<ClCompile Include="postprocessingshaderconfigwidget.cpp" />
<ClCompile Include="postprocessingsettingswidget.cpp" />
<ClCompile Include="qthostinterface.cpp" />
<ClCompile Include="qtprogresscallback.cpp" />
<ClCompile Include="qtutils.cpp" />
@ -88,6 +89,7 @@
<QtMoc Include="gamepropertiesdialog.h" />
<QtMoc Include="postprocessingchainconfigwidget.h" />
<QtMoc Include="postprocessingshaderconfigwidget.h" />
<QtMoc Include="postprocessingsettingswidget.h" />
<QtMoc Include="mainwindow.h" />
<QtMoc Include="qthostinterface.h" />
<ClInclude Include="qtutils.h" />
@ -150,6 +152,9 @@
<QtUi Include="postprocessingchainconfigwidget.ui">
<FileType>Document</FileType>
</QtUi>
<QtUi Include="postprocessingsettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
</ItemGroup>
<ItemGroup>
<QtResource Include="resources\resources.qrc">
@ -178,6 +183,7 @@
<ClCompile Include="$(IntDir)moc_memorycardsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_postprocessingchainconfigwidget.cpp" />
<ClCompile Include="$(IntDir)moc_postprocessingshaderconfigwidget.cpp" />
<ClCompile Include="$(IntDir)moc_postprocessingsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_qtdisplaywidget.cpp" />
<ClCompile Include="$(IntDir)moc_qthostinterface.cpp" />
<ClCompile Include="$(IntDir)moc_qtprogresscallback.cpp" />

View File

@ -664,6 +664,8 @@ void MainWindow::connectSignals()
[this]() { doSettings(SettingsDialog::Category::DisplaySettings); });
connect(m_ui.actionEnhancementSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::EnhancementSettings); });
connect(m_ui.actionPostProcessingSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::PostProcessingSettings); });
connect(m_ui.actionAudioSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::AudioSettings); });
connect(m_ui.actionAdvancedSettings, &QAction::triggered,

View File

@ -122,6 +122,7 @@
<addaction name="actionMemoryCardSettings"/>
<addaction name="actionDisplaySettings"/>
<addaction name="actionEnhancementSettings"/>
<addaction name="actionPostProcessingSettings"/>
<addaction name="actionAudioSettings"/>
<addaction name="actionAdvancedSettings"/>
<addaction name="separator"/>
@ -359,6 +360,15 @@
<string>&amp;Enhancement Settings...</string>
</property>
</action>
<action name="actionPostProcessingSettings">
<property name="icon">
<iconset resource="resources/icons.qrc">
<normaloff>:/icons/applications-graphics.png</normaloff>:/icons/applications-graphics.png</iconset>
</property>
<property name="text">
<string>&amp;Post-Processing Settings...</string>
</property>
</action>
<action name="actionFullscreen">
<property name="icon">
<iconset resource="resources/icons.qrc">

View File

@ -10,25 +10,26 @@ PostProcessingChainConfigWidget::PostProcessingChainConfigWidget(QWidget* parent
{
m_ui.setupUi(this);
connectUi();
updateButtonStates();
updateButtonStates(std::nullopt);
}
PostProcessingChainConfigWidget::~PostProcessingChainConfigWidget() = default;
void PostProcessingChainConfigWidget::connectUi()
{
connect(m_ui.add, &QPushButton::clicked, this, &PostProcessingChainConfigWidget::onAddButtonClicked);
connect(m_ui.remove, &QPushButton::clicked, this, &PostProcessingChainConfigWidget::onRemoveButtonClicked);
connect(m_ui.clear, &QPushButton::clicked, this, &PostProcessingChainConfigWidget::onClearButtonClicked);
connect(m_ui.moveUp, &QPushButton::clicked, this, &PostProcessingChainConfigWidget::onMoveUpButtonClicked);
connect(m_ui.moveDown, &QPushButton::clicked, this, &PostProcessingChainConfigWidget::onMoveDownButtonClicked);
connect(m_ui.reload, &QPushButton::clicked, this, &PostProcessingChainConfigWidget::onReloadButtonClicked);
connect(m_ui.shaderSettings, &QPushButton::clicked, this,
connect(m_ui.add, &QToolButton::clicked, this, &PostProcessingChainConfigWidget::onAddButtonClicked);
connect(m_ui.remove, &QToolButton::clicked, this, &PostProcessingChainConfigWidget::onRemoveButtonClicked);
connect(m_ui.clear, &QToolButton::clicked, this, &PostProcessingChainConfigWidget::onClearButtonClicked);
connect(m_ui.moveUp, &QToolButton::clicked, this, &PostProcessingChainConfigWidget::onMoveUpButtonClicked);
connect(m_ui.moveDown, &QToolButton::clicked, this, &PostProcessingChainConfigWidget::onMoveDownButtonClicked);
// connect(m_ui.reload, &QToolButton::clicked, this, &PostProcessingChainConfigWidget::onReloadButtonClicked);
connect(m_ui.shaderSettings, &QToolButton::clicked, this,
&PostProcessingChainConfigWidget::onShaderConfigButtonClicked);
connect(m_ui.shaders, &QListWidget::itemSelectionChanged, this, &PostProcessingChainConfigWidget::updateButtonStates);
connect(m_ui.shaders, &QListWidget::itemSelectionChanged, this,
&PostProcessingChainConfigWidget::onSelectedShaderChanged);
m_ui.loadPreset->setEnabled(false);
m_ui.savePreset->setEnabled(false);
// m_ui.loadPreset->setEnabled(false);
// m_ui.savePreset->setEnabled(false);
}
bool PostProcessingChainConfigWidget::setConfigString(const std::string_view& config_string)
@ -40,6 +41,20 @@ bool PostProcessingChainConfigWidget::setConfigString(const std::string_view& co
return true;
}
void PostProcessingChainConfigWidget::setOptionsButtonVisible(bool visible)
{
if (visible)
{
m_ui.shaderSettings->setVisible(true);
m_ui.horizontalLayout->addWidget(m_ui.shaderSettings);
}
else
{
m_ui.shaderSettings->setVisible(false);
m_ui.horizontalLayout->removeWidget(m_ui.shaderSettings);
}
}
std::optional<u32> PostProcessingChainConfigWidget::getSelectedIndex() const
{
QList<QListWidgetItem*> selected_items = m_ui.shaders->selectedItems();
@ -59,7 +74,7 @@ void PostProcessingChainConfigWidget::updateList()
item->setData(Qt::UserRole, QVariant(i));
}
updateButtonStates();
updateButtonStates(std::nullopt);
}
void PostProcessingChainConfigWidget::configChanged()
@ -70,12 +85,11 @@ void PostProcessingChainConfigWidget::configChanged()
chainConfigStringChanged(m_chain.GetConfigString());
}
void PostProcessingChainConfigWidget::updateButtonStates()
void PostProcessingChainConfigWidget::updateButtonStates(std::optional<u32> index)
{
std::optional<u32> index = getSelectedIndex();
m_ui.remove->setEnabled(index.has_value());
m_ui.clear->setEnabled(!m_chain.IsEmpty());
m_ui.reload->setEnabled(!m_chain.IsEmpty());
// m_ui.reload->setEnabled(!m_chain.IsEmpty());
m_ui.shaderSettings->setEnabled(index.has_value() && (index.value() < m_chain.GetStageCount()) &&
m_chain.GetShaderStage(index.value()).HasOptions());
@ -106,6 +120,8 @@ void PostProcessingChainConfigWidget::onAddButtonClicked()
{
QAction* action = menu.addAction(QString::fromStdString(shader));
connect(action, &QAction::triggered, [this, &shader]() {
chainAboutToChange();
if (!m_chain.AddStage(shader))
{
QMessageBox::critical(this, tr("Error"), tr("Failed to add shader. The log may contain more information."));
@ -131,6 +147,7 @@ void PostProcessingChainConfigWidget::onRemoveButtonClicked()
u32 index = item->data(Qt::UserRole).toUInt();
if (index < m_chain.GetStageCount())
{
chainAboutToChange();
m_chain.RemoveStage(index);
updateList();
configChanged();
@ -142,6 +159,7 @@ void PostProcessingChainConfigWidget::onClearButtonClicked()
if (QMessageBox::question(this, tr("Question"), tr("Are you sure you want to clear all shader stages?"),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
chainAboutToChange();
m_chain.ClearStages();
updateList();
configChanged();
@ -153,6 +171,7 @@ void PostProcessingChainConfigWidget::onMoveUpButtonClicked()
std::optional<u32> index = getSelectedIndex();
if (index.has_value())
{
chainAboutToChange();
m_chain.MoveStageUp(index.value());
updateList();
configChanged();
@ -164,6 +183,7 @@ void PostProcessingChainConfigWidget::onMoveDownButtonClicked()
std::optional<u32> index = getSelectedIndex();
if (index.has_value())
{
chainAboutToChange();
m_chain.MoveStageDown(index.value());
updateList();
configChanged();
@ -175,8 +195,8 @@ void PostProcessingChainConfigWidget::onShaderConfigButtonClicked()
std::optional<u32> index = getSelectedIndex();
if (index.has_value() && index.value() < m_chain.GetStageCount())
{
PostProcessingShaderConfigWidget shader_config(this, &m_chain.GetShaderStage(index.value()));
connect(&shader_config, &PostProcessingShaderConfigWidget::configChanged, [this]() { configChanged(); });
PostProcessingShaderConfigDialog shader_config(this, &m_chain.GetShaderStage(index.value()));
connect(&shader_config, &PostProcessingShaderConfigDialog::configChanged, [this]() { configChanged(); });
shader_config.exec();
}
}
@ -185,3 +205,10 @@ void PostProcessingChainConfigWidget::onReloadButtonClicked()
{
QtHostInterface::GetInstance()->reloadPostProcessingShaders();
}
void PostProcessingChainConfigWidget::onSelectedShaderChanged()
{
std::optional<u32> index = getSelectedIndex();
selectedShaderChanged(index.has_value() ? static_cast<s32>(index.value()) : -1);
updateButtonStates(index);
}

View File

@ -19,9 +19,14 @@ public:
PostProcessingChainConfigWidget(QWidget* parent);
~PostProcessingChainConfigWidget();
ALWAYS_INLINE FrontendCommon::PostProcessingChain& getChain() { return m_chain; }
bool setConfigString(const std::string_view& config_string);
void setOptionsButtonVisible(bool visible);
Q_SIGNALS:
void selectedShaderChanged(qint32 index);
void chainAboutToChange();
void chainConfigStringChanged(const std::string& new_config_string);
private Q_SLOTS:
@ -32,13 +37,14 @@ private Q_SLOTS:
void onMoveDownButtonClicked();
void onShaderConfigButtonClicked();
void onReloadButtonClicked();
void updateButtonStates();
void onSelectedShaderChanged();
private:
void connectUi();
std::optional<u32> getSelectedIndex() const;
void updateList();
void configChanged();
void updateButtonStates(std::optional<u32> index);
Ui::PostProcessingChainConfigWidget m_ui;

View File

@ -6,18 +6,46 @@
<rect>
<x>0</x>
<y>0</y>
<width>497</width>
<height>151</height>
<width>721</width>
<height>194</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="shaders">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="add">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
@ -25,10 +53,19 @@
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="remove">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
@ -36,10 +73,19 @@
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/list-remove.png</normaloff>:/icons/list-remove.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="clear">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Clear</string>
</property>
@ -47,10 +93,19 @@
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/edit-clear-16.png</normaloff>:/icons/edit-clear-16.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveUp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Move Up</string>
</property>
@ -58,10 +113,19 @@
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/go-up-16.png</normaloff>:/icons/go-up-16.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveDown">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Move Down</string>
</property>
@ -69,69 +133,33 @@
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/go-down-16.png</normaloff>:/icons/go-down-16.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="shaderSettings">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Shader Settings...</string>
<string>Options...</string>
</property>
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/preferences-system@2x.png</normaloff>:/icons/preferences-system@2x.png</iconset>
<normaloff>:/icons/preferences-system.png</normaloff>:/icons/preferences-system.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="reload">
<property name="text">
<string>&amp;Reload Shaders</string>
</property>
<property name="icon">
<iconset resource="resources/icons.qrc">
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
</property>
</widget>
</item>
<item>
<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>
<widget class="QPushButton" name="loadPreset">
<property name="text">
<string>Load Preset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="savePreset">
<property name="text">
<string>Save Preset</string>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QListWidget" name="shaders">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<resources>

View File

@ -0,0 +1,103 @@
#include "postprocessingsettingswidget.h"
#include "qthostinterface.h"
#include "settingwidgetbinder.h"
#include <QtWidgets/QMessageBox>
PostProcessingSettingsWidget::PostProcessingSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
SettingsDialog* settings_dialog)
: QWidget(parent), m_host_interface(host_interface)
{
m_ui.setupUi(this);
m_ui.widget->setOptionsButtonVisible(false);
m_ui.reload->setEnabled(false);
m_ui.loadPreset->setEnabled(false);
m_ui.savePreset->setEnabled(false);
updateShaderConfigPanel(-1);
connectUi();
SettingWidgetBinder::BindWidgetToBoolSetting(host_interface, m_ui.enablePostProcessing, "Display", "PostProcessing",
false);
std::string post_chain = m_host_interface->GetStringSettingValue("Display", "PostProcessChain");
if (!post_chain.empty())
{
if (!m_ui.widget->setConfigString(post_chain))
{
QMessageBox::critical(this, tr("Error"),
tr("The current post-processing chain is invalid, it has been reset. Any changes made will "
"overwrite the existing config."));
}
else
{
m_ui.reload->setEnabled(true);
}
}
}
PostProcessingSettingsWidget::~PostProcessingSettingsWidget() = default;
void PostProcessingSettingsWidget::connectUi()
{
connect(m_ui.reload, &QPushButton::clicked, this, &PostProcessingSettingsWidget::onReloadClicked);
connect(m_ui.widget, &PostProcessingChainConfigWidget::chainAboutToChange, this,
&PostProcessingSettingsWidget::onChainAboutToChange);
connect(m_ui.widget, &PostProcessingChainConfigWidget::selectedShaderChanged, this,
&PostProcessingSettingsWidget::onChainSelectedShaderChanged);
connect(m_ui.widget, &PostProcessingChainConfigWidget::chainConfigStringChanged, this,
&PostProcessingSettingsWidget::onConfigChanged);
}
void PostProcessingSettingsWidget::onChainAboutToChange()
{
updateShaderConfigPanel(-1);
}
void PostProcessingSettingsWidget::onChainSelectedShaderChanged(qint32 index)
{
updateShaderConfigPanel(index);
}
void PostProcessingSettingsWidget::updateShaderConfigPanel(s32 index)
{
if (m_shader_config)
{
m_ui.scrollArea->setWidget(nullptr);
m_ui.scrollArea->setVisible(false);
delete m_shader_config;
m_shader_config = nullptr;
}
if (index < 0)
return;
FrontendCommon::PostProcessingShader& shader = m_ui.widget->getChain().GetShaderStage(static_cast<u32>(index));
if (!shader.HasOptions())
return;
m_shader_config = new PostProcessingShaderConfigWidget(m_ui.scrollArea, &shader);
connect(m_shader_config, &PostProcessingShaderConfigWidget::configChanged,
[this]() { onConfigChanged(m_ui.widget->getChain().GetConfigString()); });
m_ui.scrollArea->setWidget(m_shader_config);
m_ui.scrollArea->setVisible(true);
}
void PostProcessingSettingsWidget::onConfigChanged(const std::string& new_config)
{
if (new_config.empty())
{
m_host_interface->RemoveSettingValue("Display", "PostProcessChain");
m_ui.reload->setEnabled(false);
}
else
{
m_host_interface->SetStringSettingValue("Display", "PostProcessChain", new_config.c_str());
m_ui.reload->setEnabled(true);
}
m_host_interface->applySettings();
}
void PostProcessingSettingsWidget::onReloadClicked()
{
m_host_interface->reloadPostProcessingShaders();
}

View File

@ -0,0 +1,33 @@
#pragma once
#include "postprocessingchainconfigwidget.h"
#include "postprocessingshaderconfigwidget.h"
#include "ui_postprocessingsettingswidget.h"
#include <QtWidgets/QWidget>
class QtHostInterface;
class SettingsDialog;
class PostProcessingSettingsWidget : public QWidget
{
Q_OBJECT
public:
PostProcessingSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* settings_dialog);
~PostProcessingSettingsWidget();
private Q_SLOTS:
void onChainAboutToChange();
void onChainSelectedShaderChanged(qint32 index);
void onConfigChanged(const std::string& new_config);
void onReloadClicked();
private:
void connectUi();
void updateShaderConfigPanel(s32 index);
QtHostInterface* m_host_interface;
Ui::PostProcessingSettingsWidget m_ui;
PostProcessingShaderConfigWidget* m_shader_config = nullptr;
};

View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PostProcessingSettingsWidget</class>
<widget class="QWidget" name="PostProcessingSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>683</width>
<height>514</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
<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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="enablePostProcessing">
<property name="text">
<string>Enable Post Processing</string>
</property>
</widget>
</item>
<item>
<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>
<widget class="QPushButton" name="reload">
<property name="text">
<string>&amp;Reload Shaders</string>
</property>
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadPreset">
<property name="text">
<string>Load Preset</string>
</property>
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="savePreset">
<property name="text">
<string>Save Preset</string>
</property>
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Post Processing Chain</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<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 row="0" column="0">
<widget class="PostProcessingChainConfigWidget" name="widget" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>390</height>
</rect>
</property>
</widget>
</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>
<customwidgets>
<customwidget>
<class>PostProcessingChainConfigWidget</class>
<extends>QWidget</extends>
<header>duckstation-qt/postprocessingchainconfigwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="resources/resources.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -9,10 +9,8 @@ using FrontendCommon::PostProcessingShader;
PostProcessingShaderConfigWidget::PostProcessingShaderConfigWidget(QWidget* parent,
FrontendCommon::PostProcessingShader* shader)
: QDialog(parent), m_shader(shader)
: QWidget(parent), m_shader(shader)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("%1 Shader Options").arg(QString::fromStdString(m_shader->GetName())));
createUi();
}
@ -20,7 +18,8 @@ PostProcessingShaderConfigWidget::~PostProcessingShaderConfigWidget() = default;
void PostProcessingShaderConfigWidget::createUi()
{
QGridLayout* layout = new QGridLayout(this);
m_layout = new QGridLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0);
u32 row = 0;
for (PostProcessingShader::Option& option : m_shader->GetOptions())
@ -38,7 +37,7 @@ void PostProcessingShaderConfigWidget::createUi()
checkbox->setChecked(option.default_value[0].bool_value);
option.value = option.default_value;
});
layout->addWidget(checkbox, row, 0, 1, 3, Qt::AlignLeft);
m_layout->addWidget(checkbox, row, 0, 1, 3, Qt::AlignLeft);
row++;
}
else
@ -57,13 +56,13 @@ void PostProcessingShaderConfigWidget::createUi()
label = tr("%1 (%2)").arg(QString::fromStdString(option.ui_name)).arg(tr(suffixes[i]));
}
layout->addWidget(new QLabel(label, this), row, 0, 1, 1, Qt::AlignLeft);
m_layout->addWidget(new QLabel(label, this), row, 0, 1, 1, Qt::AlignLeft);
QSlider* slider = new QSlider(Qt::Horizontal, this);
layout->addWidget(slider, row, 1, 1, 1, Qt::AlignLeft);
m_layout->addWidget(slider, row, 1, 1, 1, Qt::AlignLeft);
QLabel* slider_label = new QLabel(this);
layout->addWidget(slider_label, row, 2, 1, 1, Qt::AlignLeft);
m_layout->addWidget(slider_label, row, 2, 1, 1, Qt::AlignLeft);
if (option.type == PostProcessingShader::Option::Type::Int)
{
@ -132,16 +131,7 @@ void PostProcessingShaderConfigWidget::createUi()
QPushButton* reset_button = new QPushButton(tr("Reset to Defaults"), this);
connect(reset_button, &QPushButton::clicked, this, &PostProcessingShaderConfigWidget::onResetToDefaultsClicked);
layout->addWidget(reset_button, row, 0, 1, 2);
QPushButton* close_button = new QPushButton(tr("Close"), this);
connect(close_button, &QPushButton::clicked, this, &PostProcessingShaderConfigWidget::onCloseClicked);
layout->addWidget(close_button, row, 2, 1, 2);
}
void PostProcessingShaderConfigWidget::onCloseClicked()
{
done(0);
m_layout->addWidget(reset_button, row, 0, 1, 1);
}
void PostProcessingShaderConfigWidget::onResetToDefaultsClicked()
@ -149,3 +139,34 @@ void PostProcessingShaderConfigWidget::onResetToDefaultsClicked()
resettingtoDefaults();
configChanged();
}
PostProcessingShaderConfigDialog::PostProcessingShaderConfigDialog(QWidget* parent,
FrontendCommon::PostProcessingShader* shader)
: QDialog(parent)
{
setWindowTitle(tr("%1 Shader Options").arg(QString::fromStdString(shader->GetName())));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QGridLayout* layout = new QGridLayout(this);
m_widget = new PostProcessingShaderConfigWidget(this, shader);
layout->addWidget(m_widget);
connect(m_widget, &PostProcessingShaderConfigWidget::configChanged, this,
&PostProcessingShaderConfigDialog::onConfigChanged);
QPushButton* close_button = new QPushButton(tr("Close"), this);
connect(close_button, &QPushButton::clicked, this, &PostProcessingShaderConfigDialog::onCloseClicked);
m_widget->getLayout()->addWidget(close_button, m_widget->getLayout()->rowCount() - 1, 2, 1, 2);
}
PostProcessingShaderConfigDialog::~PostProcessingShaderConfigDialog() = default;
void PostProcessingShaderConfigDialog::onConfigChanged()
{
configChanged();
}
void PostProcessingShaderConfigDialog::onCloseClicked()
{
done(0);
}

View File

@ -1,8 +1,11 @@
#pragma once
#include "frontend-common/postprocessing_shader.h"
#include <QtWidgets/QDialog>
#include <QtWidgets/QWidget>
class PostProcessingShaderConfigWidget : public QDialog
class QGridLayout;
class PostProcessingShaderConfigWidget : public QWidget
{
Q_OBJECT
@ -10,17 +13,38 @@ public:
PostProcessingShaderConfigWidget(QWidget* parent, FrontendCommon::PostProcessingShader* shader);
~PostProcessingShaderConfigWidget();
QGridLayout* getLayout() { return m_layout; }
Q_SIGNALS:
void configChanged();
void resettingtoDefaults();
private Q_SLOTS:
void onCloseClicked();
void onResetToDefaultsClicked();
private:
protected:
void createUi();
FrontendCommon::PostProcessingShader* m_shader;
QGridLayout* m_layout;
};
class PostProcessingShaderConfigDialog : public QDialog
{
Q_OBJECT
public:
PostProcessingShaderConfigDialog(QWidget* parent, FrontendCommon::PostProcessingShader* shader);
~PostProcessingShaderConfigDialog();
Q_SIGNALS:
void configChanged();
private Q_SLOTS:
void onConfigChanged();
void onCloseClicked();
private:
PostProcessingShaderConfigWidget* m_widget;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -6,6 +6,8 @@
<file>icons/antialias-icon@2x.png</file>
<file>icons/applications-development.png</file>
<file>icons/applications-development@2x.png</file>
<file>icons/applications-graphics.png</file>
<file>icons/applications-graphics@2x.png</file>
<file>icons/applications-internet.png</file>
<file>icons/applications-other.png</file>
<file>icons/applications-other@2x.png</file>

View File

@ -9,6 +9,7 @@
#include "generalsettingswidget.h"
#include "hotkeysettingswidget.h"
#include "memorycardsettingswidget.h"
#include "postprocessingsettingswidget.h"
#include "qthostinterface.h"
#include <QtWidgets/QTextEdit>
@ -30,6 +31,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_memory_card_settings = new MemoryCardSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_display_settings = new DisplaySettingsWidget(host_interface, m_ui.settingsContainer, this);
m_enhancement_settings = new EnhancementSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_post_processing_settings = new PostProcessingSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_audio_settings = new AudioSettingsWidget(host_interface, m_ui.settingsContainer, this);
m_advanced_settings = new AdvancedSettingsWidget(host_interface, m_ui.settingsContainer, this);
@ -41,6 +43,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::MemoryCardSettings), m_memory_card_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::DisplaySettings), m_display_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::EnhancementSettings), m_enhancement_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::PostProcessingSettings), m_post_processing_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::AudioSettings), m_audio_settings);
m_ui.settingsContainer->insertWidget(static_cast<int>(Category::AdvancedSettings), m_advanced_settings);
@ -88,6 +91,9 @@ void SettingsDialog::setCategoryHelpTexts()
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.");
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.");
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.");

View File

@ -15,6 +15,7 @@ class ControllerSettingsWidget;
class MemoryCardSettingsWidget;
class DisplaySettingsWidget;
class EnhancementSettingsWidget;
class PostProcessingSettingsWidget;
class AudioSettingsWidget;
class AdvancedSettingsWidget;
@ -33,6 +34,7 @@ public:
MemoryCardSettings,
DisplaySettings,
EnhancementSettings,
PostProcessingSettings,
AudioSettings,
AdvancedSettings,
Count
@ -51,6 +53,7 @@ public:
EnhancementSettingsWidget* getEnhancementSettingsWidget() const { return m_enhancement_settings; }
AudioSettingsWidget* getAudioSettingsWidget() const { return m_audio_settings; }
AdvancedSettingsWidget* getAdvancedSettingsWidget() const { return m_advanced_settings; }
PostProcessingSettingsWidget* getPostProcessingSettingsWidget() { return m_post_processing_settings; }
void registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text);
bool eventFilter(QObject* object, QEvent* event) override;
@ -76,6 +79,7 @@ private:
MemoryCardSettingsWidget* m_memory_card_settings = nullptr;
DisplaySettingsWidget* m_display_settings = nullptr;
EnhancementSettingsWidget* m_enhancement_settings = nullptr;
PostProcessingSettingsWidget *m_post_processing_settings = nullptr;
AudioSettingsWidget* m_audio_settings = nullptr;
AdvancedSettingsWidget* m_advanced_settings = nullptr;

View File

@ -130,6 +130,15 @@
<normaloff>:/icons/antialias-icon.png</normaloff>:/icons/antialias-icon.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Post-Processing Settings</string>
</property>
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/applications-graphics.png</normaloff>:/icons/applications-graphics.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Audio Settings</string>

View File

@ -687,7 +687,7 @@ void CommonHostInterface::OnSystemCreated()
{
HostInterface::OnSystemCreated();
if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain))
if (g_settings.display_post_processing && !m_display->SetPostProcessingChain(g_settings.display_post_process_chain))
AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
@ -1967,10 +1967,18 @@ void CommonHostInterface::CheckForSettingsChanges(const Settings& old_settings)
UpdateSpeedLimiterState();
}
if (g_settings.display_post_process_chain != old_settings.display_post_process_chain)
if (g_settings.display_post_processing != old_settings.display_post_processing ||
g_settings.display_post_process_chain != old_settings.display_post_process_chain)
{
if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain))
AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
if (g_settings.display_post_processing)
{
if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain))
AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
else
{
m_display->SetPostProcessingChain({});
}
}
}
@ -2273,7 +2281,7 @@ void CommonHostInterface::ApplyCheatCode(u32 index)
void CommonHostInterface::ReloadPostProcessingShaders()
{
if (!m_display)
if (!m_display || !g_settings.display_post_processing)
return;
if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain))