Qt: Move shader settings into main settings window

This commit is contained in:
Vicki Pfau 2017-07-07 12:17:47 -07:00
parent 780f36c837
commit f920afdfe2
6 changed files with 47 additions and 23 deletions

View File

@ -168,6 +168,7 @@ Misc:
- GBA Timer: Improve accuracy of timers - GBA Timer: Improve accuracy of timers
- Qt: Minor test fixes - Qt: Minor test fixes
- PSP2: Update toolchain to use vita.cmake - PSP2: Update toolchain to use vita.cmake
- Qt: Move shader settings into main settings window
0.6 beta 1: (2017-06-29) 0.6 beta 1: (2017-06-29)
- Initial beta for 0.6 - Initial beta for 0.6

View File

@ -11,6 +11,7 @@
#include "GBAApp.h" #include "GBAApp.h"
#include "GBAKeyEditor.h" #include "GBAKeyEditor.h"
#include "InputController.h" #include "InputController.h"
#include "ShaderSelector.h"
#include "ShortcutView.h" #include "ShortcutView.h"
#include <mgba/core/serialize.h> #include <mgba/core/serialize.h>
@ -185,6 +186,20 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
m_ui.tabs->addItem(tr("Shortcuts")); 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) { void SettingsView::selectBios(QLineEdit* bios) {
QString filename = GBAApp::app()->getOpenFileName(this, tr("Select BIOS")); QString filename = GBAApp::app()->getOpenFileName(this, tr("Select BIOS"));
if (!filename.isEmpty()) { if (!filename.isEmpty()) {

View File

@ -17,12 +17,16 @@ namespace QGBA {
class ConfigController; class ConfigController;
class InputController; class InputController;
class ShortcutController; class ShortcutController;
class ShaderSelector;
class SettingsView : public QDialog { class SettingsView : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, QWidget* parent = nullptr); SettingsView(ConfigController* controller, InputController* inputController, ShortcutController* shortcutController, QWidget* parent = nullptr);
~SettingsView();
void setShaderSelector(ShaderSelector* shaderSelector);
signals: signals:
void biosLoaded(int platform, const QString&); void biosLoaded(int platform, const QString&);
@ -42,6 +46,7 @@ private:
ConfigController* m_controller; ConfigController* m_controller;
InputController* m_input; InputController* m_input;
ShaderSelector* m_shader = nullptr;
void saveSetting(const char* key, const QAbstractButton*); void saveSetting(const char* key, const QAbstractButton*);
void saveSetting(const char* key, const QComboBox*); void saveSetting(const char* key, const QComboBox*);

View File

@ -39,6 +39,9 @@ ShaderSelector::ShaderSelector(Display* display, ConfigController* config, QWidg
connect(m_ui.load, &QAbstractButton::clicked, this, &ShaderSelector::selectShader); connect(m_ui.load, &QAbstractButton::clicked, this, &ShaderSelector::selectShader);
connect(m_ui.unload, &QAbstractButton::clicked, this, &ShaderSelector::clearShader); connect(m_ui.unload, &QAbstractButton::clicked, this, &ShaderSelector::clearShader);
connect(m_ui.buttonBox, &QDialogButtonBox::clicked, this, &ShaderSelector::buttonPressed); connect(m_ui.buttonBox, &QDialogButtonBox::clicked, this, &ShaderSelector::buttonPressed);
connect(this, &ShaderSelector::saved, [this]() {
m_config->setOption("shader", m_shaderPath);
});
} }
ShaderSelector::~ShaderSelector() { ShaderSelector::~ShaderSelector() {
@ -86,7 +89,6 @@ void ShaderSelector::clearShader() {
m_display->clearShaders(); m_display->clearShaders();
refreshShaders(); refreshShaders();
m_shaderPath = ""; m_shaderPath = "";
m_config->setOption("shader", nullptr);
} }
void ShaderSelector::refreshShaders() { void ShaderSelector::refreshShaders() {
@ -115,6 +117,10 @@ void ShaderSelector::refreshShaders() {
disconnect(this, &ShaderSelector::reset, 0, 0); disconnect(this, &ShaderSelector::reset, 0, 0);
disconnect(this, &ShaderSelector::resetToDefault, 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 !defined(_WIN32) || defined(USE_EPOXY)
if (m_shaders->preprocessShader) { if (m_shaders->preprocessShader) {
m_ui.passes->addTab(makePage(static_cast<mGLES2Shader*>(m_shaders->preprocessShader), "default", 0), tr("Preprocessing")); m_ui.passes->addTab(makePage(static_cast<mGLES2Shader*>(m_shaders->preprocessShader), "default", 0), tr("Preprocessing"));
@ -264,7 +270,6 @@ void ShaderSelector::buttonPressed(QAbstractButton* button) {
emit reset(); emit reset();
break; break;
case QDialogButtonBox::Ok: case QDialogButtonBox::Ok:
m_config->setOption("shader", m_shaderPath);
emit saved(); emit saved();
close(); close();
break; break;

View File

@ -81,33 +81,36 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QGridLayout" name="gridLayout">
<item> <item row="0" column="0">
<widget class="QPushButton" name="unload"> <widget class="QPushButton" name="unload">
<property name="text"> <property name="text">
<string>Unload Shader</string> <string>Unload Shader</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QPushButton" name="load"> <widget class="QPushButton" name="load">
<property name="text"> <property name="text">
<string>Load New Shader</string> <string>Load New Shader</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -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_display, &Display::stopDrawing);
connect(this, &Window::shutdown, m_controller, &GameController::closeGame); connect(this, &Window::shutdown, m_controller, &GameController::closeGame);
connect(this, &Window::shutdown, m_logView, &QWidget::hide); 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::audioBufferSamplesChanged, m_controller, &GameController::setAudioBufferSamples);
connect(this, &Window::sampleRateChanged, m_controller, &GameController::setAudioSampleRate); connect(this, &Window::sampleRateChanged, m_controller, &GameController::setAudioSampleRate);
connect(this, &Window::fpsTargetChanged, m_controller, &GameController::setFPSTarget); connect(this, &Window::fpsTargetChanged, m_controller, &GameController::setFPSTarget);
@ -460,6 +459,9 @@ void Window::exportSharkport() {
void Window::openSettingsWindow() { void Window::openSettingsWindow() {
SettingsView* settingsWindow = new SettingsView(m_config, &m_inputController, m_shortcutController); 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::biosLoaded, m_controller, &GameController::loadBIOS);
connect(settingsWindow, &SettingsView::audioDriverChanged, m_controller, &GameController::reloadAudioDriver); connect(settingsWindow, &SettingsView::audioDriverChanged, m_controller, &GameController::reloadAudioDriver);
connect(settingsWindow, &SettingsView::displayDriverChanged, this, &Window::mustRestart); connect(settingsWindow, &SettingsView::displayDriverChanged, this, &Window::mustRestart);
@ -1296,13 +1298,6 @@ void Window::setupMenu(QMenuBar* menubar) {
} }
m_config->updateOption("frameskip"); 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(); avMenu->addSeparator();
ConfigOption* mute = m_config->addOption("mute"); ConfigOption* mute = m_config->addOption("mute");