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

View File

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

View File

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

View File

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