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:
parent
9ab0f26214
commit
2d84da2f7e
@ -71,6 +71,7 @@ PasteDuplicate="Paste (Duplicate)"
|
||||
RemuxRecordings="Remux Recordings"
|
||||
Next="Next"
|
||||
Back="Back"
|
||||
Defaults="Defaults"
|
||||
|
||||
# warning if program already open
|
||||
AlreadyRunning.Title="OBS is already running"
|
||||
|
@ -412,12 +412,9 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="close">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Reset|QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -446,21 +443,5 @@
|
||||
<include location="obs.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>close</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>OBSBasicFilters</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>811</x>
|
||||
<y>701</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>722</x>
|
||||
<y>727</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -87,6 +87,15 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_)
|
||||
SLOT(EffectFilterNameEdited(QWidget*,
|
||||
QAbstractItemDelegate::EndEditHint)));
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Close),
|
||||
SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Reset)->setText(
|
||||
QTStr("Defaults"));
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset),
|
||||
SIGNAL(clicked()), this, SLOT(ResetFilters()));
|
||||
|
||||
uint32_t flags = obs_source_get_output_flags(source);
|
||||
bool audio = (flags & OBS_SOURCE_AUDIO) != 0;
|
||||
bool audioOnly = (flags & OBS_SOURCE_VIDEO) == 0;
|
||||
@ -573,6 +582,7 @@ void OBSBasicFilters::on_moveAsyncFilterDown_clicked()
|
||||
void OBSBasicFilters::on_asyncFilters_GotFocus()
|
||||
{
|
||||
UpdatePropertiesView(ui->asyncFilters->currentRow(), true);
|
||||
isAsync = true;
|
||||
}
|
||||
|
||||
void OBSBasicFilters::on_asyncFilters_currentRowChanged(int row)
|
||||
@ -614,6 +624,7 @@ void OBSBasicFilters::on_moveEffectFilterDown_clicked()
|
||||
void OBSBasicFilters::on_effectFilters_GotFocus()
|
||||
{
|
||||
UpdatePropertiesView(ui->effectFilters->currentRow(), false);
|
||||
isAsync = false;
|
||||
}
|
||||
|
||||
void OBSBasicFilters::on_effectFilters_currentRowChanged(int row)
|
||||
@ -739,3 +750,23 @@ void OBSBasicFilters::EffectFilterNameEdited(QWidget *editor,
|
||||
FilterNameEdited(editor, ui->effectFilters);
|
||||
UNUSED_PARAMETER(endHint);
|
||||
}
|
||||
|
||||
void OBSBasicFilters::ResetFilters()
|
||||
{
|
||||
QListWidget *list = isAsync ? ui->asyncFilters : ui->effectFilters;
|
||||
int row = list->currentRow();
|
||||
|
||||
OBSSource filter = GetFilter(row, isAsync);
|
||||
|
||||
if (!filter)
|
||||
return;
|
||||
|
||||
obs_data_t *settings = obs_source_get_settings(filter);
|
||||
obs_data_clear(settings);
|
||||
obs_data_release(settings);
|
||||
|
||||
if (!view->DeferUpdate())
|
||||
obs_source_update(filter, nullptr);
|
||||
|
||||
view->RefreshProperties();
|
||||
}
|
||||
|
@ -68,12 +68,15 @@ private:
|
||||
|
||||
void FilterNameEdited(QWidget *editor, QListWidget *list);
|
||||
|
||||
bool isAsync;
|
||||
|
||||
private slots:
|
||||
void AddFilter(OBSSource filter);
|
||||
void RemoveFilter(OBSSource filter);
|
||||
void ReorderFilters();
|
||||
void RenameAsyncFilter();
|
||||
void RenameEffectFilter();
|
||||
void ResetFilters();
|
||||
|
||||
void AddFilterFromAction();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user