diff --git a/CHANGES b/CHANGES index 0eb203653..67f4ebb62 100644 --- a/CHANGES +++ b/CHANGES @@ -168,6 +168,7 @@ Misc: - GBA Timer: Improve accuracy of timers - Qt: Minor test fixes - PSP2: Update toolchain to use vita.cmake + - Qt: Move shader settings into main settings window 0.6 beta 1: (2017-06-29) - Initial beta for 0.6 diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 0afb035b2..d081d8a42 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -11,6 +11,7 @@ #include "GBAApp.h" #include "GBAKeyEditor.h" #include "InputController.h" +#include "ShaderSelector.h" #include "ShortcutView.h" #include @@ -185,6 +186,20 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC m_ui.tabs->addItem(tr("Shortcuts")); } +SettingsView::~SettingsView() { + if (m_shader) { + m_ui.stackedWidget->removeWidget(m_shader); + m_shader->setParent(nullptr); + } +} + +void SettingsView::setShaderSelector(ShaderSelector* shaderSelector) { + m_shader = shaderSelector; + m_ui.stackedWidget->addWidget(m_shader); + m_ui.tabs->addItem(tr("Shaders")); + connect(m_ui.buttonBox, &QDialogButtonBox::accepted, m_shader, &ShaderSelector::saved); +} + void SettingsView::selectBios(QLineEdit* bios) { QString filename = GBAApp::app()->getOpenFileName(this, tr("Select BIOS")); if (!filename.isEmpty()) { diff --git a/src/platform/qt/SettingsView.h b/src/platform/qt/SettingsView.h index 3e85fe8bd..6815eb74d 100644 --- a/src/platform/qt/SettingsView.h +++ b/src/platform/qt/SettingsView.h @@ -17,12 +17,16 @@ namespace QGBA { class ConfigController; class InputController; class ShortcutController; +class ShaderSelector; class SettingsView : public QDialog { Q_OBJECT public: SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, QWidget* parent = nullptr); + ~SettingsView(); + + void setShaderSelector(ShaderSelector* shaderSelector); signals: void biosLoaded(int platform, const QString&); @@ -42,6 +46,7 @@ private: ConfigController* m_controller; InputController* m_input; + ShaderSelector* m_shader = nullptr; void saveSetting(const char* key, const QAbstractButton*); void saveSetting(const char* key, const QComboBox*); diff --git a/src/platform/qt/ShaderSelector.cpp b/src/platform/qt/ShaderSelector.cpp index 9c3a9ce77..089fb2bd0 100644 --- a/src/platform/qt/ShaderSelector.cpp +++ b/src/platform/qt/ShaderSelector.cpp @@ -39,6 +39,9 @@ ShaderSelector::ShaderSelector(Display* display, ConfigController* config, QWidg connect(m_ui.load, &QAbstractButton::clicked, this, &ShaderSelector::selectShader); connect(m_ui.unload, &QAbstractButton::clicked, this, &ShaderSelector::clearShader); connect(m_ui.buttonBox, &QDialogButtonBox::clicked, this, &ShaderSelector::buttonPressed); + connect(this, &ShaderSelector::saved, [this]() { + m_config->setOption("shader", m_shaderPath); + }); } ShaderSelector::~ShaderSelector() { @@ -86,7 +89,6 @@ void ShaderSelector::clearShader() { m_display->clearShaders(); refreshShaders(); m_shaderPath = ""; - m_config->setOption("shader", nullptr); } void ShaderSelector::refreshShaders() { @@ -115,6 +117,10 @@ void ShaderSelector::refreshShaders() { disconnect(this, &ShaderSelector::reset, 0, 0); disconnect(this, &ShaderSelector::resetToDefault, 0, 0); + connect(this, &ShaderSelector::saved, [this]() { + m_config->setOption("shader", m_shaderPath); + }); + #if !defined(_WIN32) || defined(USE_EPOXY) if (m_shaders->preprocessShader) { m_ui.passes->addTab(makePage(static_cast(m_shaders->preprocessShader), "default", 0), tr("Preprocessing")); @@ -264,7 +270,6 @@ void ShaderSelector::buttonPressed(QAbstractButton* button) { emit reset(); break; case QDialogButtonBox::Ok: - m_config->setOption("shader", m_shaderPath); emit saved(); close(); break; diff --git a/src/platform/qt/ShaderSelector.ui b/src/platform/qt/ShaderSelector.ui index a2af540a2..5905e7a54 100644 --- a/src/platform/qt/ShaderSelector.ui +++ b/src/platform/qt/ShaderSelector.ui @@ -81,33 +81,36 @@ - - + + Unload Shader - + Load New Shader + + + + Qt::Horizontal + + + QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults + + + true + + + - - - - Qt::Horizontal - - - QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults - - - diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 6caed26dc..a8871a25e 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -177,7 +177,6 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) connect(this, &Window::shutdown, m_display, &Display::stopDrawing); connect(this, &Window::shutdown, m_controller, &GameController::closeGame); connect(this, &Window::shutdown, m_logView, &QWidget::hide); - connect(this, &Window::shutdown, m_shaderView, &QWidget::hide); connect(this, &Window::audioBufferSamplesChanged, m_controller, &GameController::setAudioBufferSamples); connect(this, &Window::sampleRateChanged, m_controller, &GameController::setAudioSampleRate); connect(this, &Window::fpsTargetChanged, m_controller, &GameController::setFPSTarget); @@ -460,6 +459,9 @@ void Window::exportSharkport() { void Window::openSettingsWindow() { SettingsView* settingsWindow = new SettingsView(m_config, &m_inputController, m_shortcutController); + if (m_display->supportsShaders()) { + settingsWindow->setShaderSelector(m_shaderView); + } connect(settingsWindow, &SettingsView::biosLoaded, m_controller, &GameController::loadBIOS); connect(settingsWindow, &SettingsView::audioDriverChanged, m_controller, &GameController::reloadAudioDriver); connect(settingsWindow, &SettingsView::displayDriverChanged, this, &Window::mustRestart); @@ -1296,13 +1298,6 @@ void Window::setupMenu(QMenuBar* menubar) { } m_config->updateOption("frameskip"); - QAction* shaderView = new QAction(tr("Shader options..."), avMenu); - connect(shaderView, &QAction::triggered, m_shaderView, &QWidget::show); - if (!m_display->supportsShaders()) { - shaderView->setEnabled(false); - } - addControlledAction(avMenu, shaderView, "shaderSelector"); - avMenu->addSeparator(); ConfigOption* mute = m_config->addOption("mute");