mirror of https://github.com/stenzek/duckstation
Qt: Move post processing to its own setting category
parent
6ababf7e53
commit
441f26706e
@ -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();
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
};
|
||||||
@ -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>&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>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Loading…
Reference in New Issue