Qt: save shader settings when OK/Apply clicked

This commit is contained in:
Adam Higerd 2024-11-19 16:41:42 -06:00 committed by Vicki Pfau
parent cca3267ef6
commit f930184efb
4 changed files with 11 additions and 4 deletions

View File

@ -423,8 +423,11 @@ void SettingsView::setShaderSelector(ShaderSelector* shaderSelector) {
} }
if (!m_shader) { if (!m_shader) {
m_ui.stackedWidget->removeWidget(m_dummyShader); m_ui.stackedWidget->removeWidget(m_dummyShader);
} else {
QObject::disconnect(m_shader, nullptr, this, nullptr);
} }
m_shader = shaderSelector; m_shader = shaderSelector;
QObject::connect(this, &SettingsView::saveSettingsRequested, m_shader, &ShaderSelector::saveSettings);
if (shaderSelector) { if (shaderSelector) {
addPage(tr("Shaders"), m_shader, Page::SHADERS); addPage(tr("Shaders"), m_shader, Page::SHADERS);
} else { } else {
@ -683,6 +686,8 @@ void SettingsView::updateConfig() {
saveSetting("gb.colors", gbColors); saveSetting("gb.colors", gbColors);
#endif #endif
emit saveSettingsRequested();
m_controller->write(); m_controller->write();
emit pathsChanged(); emit pathsChanged();

View File

@ -61,6 +61,7 @@ signals:
void pathsChanged(); void pathsChanged();
void languageChanged(); void languageChanged();
void libraryCleared(); void libraryCleared();
void saveSettingsRequested();
public slots: public slots:
void selectPage(Page); void selectPage(Page);

View File

@ -49,6 +49,10 @@ ShaderSelector::~ShaderSelector() {
clear(); clear();
} }
void ShaderSelector::saveSettings() {
emit saved();
}
void ShaderSelector::clear() { void ShaderSelector::clear() {
m_ui.shaderName->setText(tr("No shader active")); m_ui.shaderName->setText(tr("No shader active"));
m_ui.description->clear(); m_ui.description->clear();
@ -269,10 +273,6 @@ void ShaderSelector::buttonPressed(QAbstractButton* button) {
case QDialogButtonBox::Reset: case QDialogButtonBox::Reset:
emit reset(); emit reset();
break; break;
case QDialogButtonBox::Ok:
emit saved();
close();
break;
case QDialogButtonBox::RestoreDefaults: case QDialogButtonBox::RestoreDefaults:
emit resetToDefault(); emit resetToDefault();
break; break;

View File

@ -28,6 +28,7 @@ public:
~ShaderSelector(); ~ShaderSelector();
public slots: public slots:
void saveSettings();
void refreshShaders(); void refreshShaders();
void clear(); void clear();