From 3232e3b164524ba27833337121cc869c2662d9c0 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 13 Sep 2020 20:21:33 +1000 Subject: [PATCH] Qt: Add reload button to postprocessing UI --- .../postprocessingchainconfigwidget.cpp | 8 ++++++++ .../postprocessingchainconfigwidget.h | 1 + .../postprocessingchainconfigwidget.ui | 11 +++++++++++ src/duckstation-qt/qthostinterface.cpp | 13 ++++++++++++- src/duckstation-qt/qthostinterface.h | 3 +++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/duckstation-qt/postprocessingchainconfigwidget.cpp b/src/duckstation-qt/postprocessingchainconfigwidget.cpp index df93e0fdd..ce4e13e26 100644 --- a/src/duckstation-qt/postprocessingchainconfigwidget.cpp +++ b/src/duckstation-qt/postprocessingchainconfigwidget.cpp @@ -1,6 +1,7 @@ #include "postprocessingchainconfigwidget.h" #include "frontend-common/postprocessing_chain.h" #include "postprocessingshaderconfigwidget.h" +#include "qthostinterface.h" #include #include #include @@ -21,6 +22,7 @@ void PostProcessingChainConfigWidget::connectUi() 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, &PostProcessingChainConfigWidget::onShaderConfigButtonClicked); connect(m_ui.shaders, &QListWidget::itemSelectionChanged, this, &PostProcessingChainConfigWidget::updateButtonStates); @@ -73,6 +75,7 @@ void PostProcessingChainConfigWidget::updateButtonStates() std::optional 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.shaderSettings->setEnabled(index.has_value() && (index.value() < m_chain.GetStageCount()) && m_chain.GetShaderStage(index.value()).HasOptions()); @@ -177,3 +180,8 @@ void PostProcessingChainConfigWidget::onShaderConfigButtonClicked() shader_config.exec(); } } + +void PostProcessingChainConfigWidget::onReloadButtonClicked() +{ + QtHostInterface::GetInstance()->reloadPostProcessingShaders(); +} diff --git a/src/duckstation-qt/postprocessingchainconfigwidget.h b/src/duckstation-qt/postprocessingchainconfigwidget.h index 3e15ca14a..99f787dbc 100644 --- a/src/duckstation-qt/postprocessingchainconfigwidget.h +++ b/src/duckstation-qt/postprocessingchainconfigwidget.h @@ -31,6 +31,7 @@ private Q_SLOTS: void onMoveUpButtonClicked(); void onMoveDownButtonClicked(); void onShaderConfigButtonClicked(); + void onReloadButtonClicked(); void updateButtonStates(); private: diff --git a/src/duckstation-qt/postprocessingchainconfigwidget.ui b/src/duckstation-qt/postprocessingchainconfigwidget.ui index 2f9647492..82b38784a 100644 --- a/src/duckstation-qt/postprocessingchainconfigwidget.ui +++ b/src/duckstation-qt/postprocessingchainconfigwidget.ui @@ -82,6 +82,17 @@ + + + + &Reload Shaders + + + + :/icons/view-refresh.png:/icons/view-refresh.png + + + diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index d2a15eb18..b781cdb6a 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -1024,7 +1024,7 @@ void QtHostInterface::setCheatEnabled(quint32 index, bool enabled) SetCheatCodeState(index, enabled, g_settings.auto_load_cheats); } -void QtHostInterface::applyCheat(u32 index) +void QtHostInterface::applyCheat(quint32 index) { if (!isOnWorkerThread()) { @@ -1035,6 +1035,17 @@ void QtHostInterface::applyCheat(u32 index) ApplyCheatCode(index); } +void QtHostInterface::reloadPostProcessingShaders() +{ + if (!isOnWorkerThread()) + { + QMetaObject::invokeMethod(this, "reloadPostProcessingShaders", Qt::QueuedConnection); + return; + } + + ReloadPostProcessingShaders(); +} + void QtHostInterface::loadState(const QString& filename) { if (!isOnWorkerThread()) diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 927b13249..5cdf1abf6 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -40,6 +40,8 @@ public: explicit QtHostInterface(QObject* parent = nullptr); ~QtHostInterface(); + ALWAYS_INLINE static QtHostInterface* GetInstance() { return static_cast(g_host_interface); } + const char* GetFrontendName() const override; bool Initialize() override; @@ -164,6 +166,7 @@ public Q_SLOTS: void loadCheatList(const QString& filename); void setCheatEnabled(quint32 index, bool enabled); void applyCheat(quint32 index); + void reloadPostProcessingShaders(); private Q_SLOTS: void doStopThread();