UI: Add "Defaults" button to filters/properties windows

This adds a "Defaults" button in the source and filter properties, which
will clear and reset all settings.

Closes jp9000/obs-studio#875
This commit is contained in:
cg2121
2017-04-09 05:39:53 -05:00
committed by jp9000
parent 9ab0f26214
commit 2d84da2f7e
5 changed files with 52 additions and 26 deletions

View File

@@ -49,8 +49,9 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
int cy = (int)config_get_int(App()->GlobalConfig(), "PropertiesWindow",
"cy");
buttonBox->setStandardButtons(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
buttonBox->addButton(QTStr("OK"), QDialogButtonBox::AcceptRole);
buttonBox->addButton(QTStr("Cancel"), QDialogButtonBox::RejectRole);
buttonBox->addButton(QTStr("Defaults"), QDialogButtonBox::ResetRole);
buttonBox->setObjectName(QStringLiteral("buttonBox"));
if (cx > 400 && cy > 400)
@@ -158,9 +159,8 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
if (view->DeferUpdate())
view->UpdateSettings();
}
if (val == QDialogButtonBox::RejectRole) {
} else if (val == QDialogButtonBox::RejectRole) {
obs_data_t *settings = obs_source_get_settings(source);
obs_data_clear(settings);
obs_data_release(settings);
@@ -171,6 +171,16 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
obs_source_update(source, oldSettings);
close();
} else if (val == QDialogButtonBox::ResetRole) {
obs_data_t *settings = obs_source_get_settings(source);
obs_data_clear(settings);
obs_data_release(settings);
if (!view->DeferUpdate())
obs_source_update(source, nullptr);
view->RefreshProperties();
}
}