mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-01-27 15:48:44 -05:00
UI: Add undo/redo to Paste Filters on audio mixer and scenes
Copy-Pasting filters on a scene or on a source via the audio mixer context menu would not add an undo/redo action. This commit factors the undo/redo logic out into a generic paste filters function that can be used for pasting filters everywhere.
This commit is contained in:
@@ -10107,6 +10107,26 @@ void OBSBasic::on_actionPasteDup_triggered()
|
||||
redo_data);
|
||||
}
|
||||
|
||||
void OBSBasic::SourcePasteFilters(OBSSource source, OBSSource dstSource)
|
||||
{
|
||||
if (source == dstSource)
|
||||
return;
|
||||
|
||||
OBSDataArrayAutoRelease undo_array =
|
||||
obs_source_backup_filters(dstSource);
|
||||
obs_source_copy_filters(dstSource, source);
|
||||
OBSDataArrayAutoRelease redo_array =
|
||||
obs_source_backup_filters(dstSource);
|
||||
|
||||
const char *srcName = obs_source_get_name(source);
|
||||
const char *dstName = obs_source_get_name(dstSource);
|
||||
QString text =
|
||||
QTStr("Undo.Filters.Paste.Multiple").arg(srcName, dstName);
|
||||
|
||||
CreateFilterPasteUndoRedoAction(text, dstSource, undo_array,
|
||||
redo_array);
|
||||
}
|
||||
|
||||
void OBSBasic::AudioMixerCopyFilters()
|
||||
{
|
||||
QAction *action = reinterpret_cast<QAction *>(sender());
|
||||
@@ -10126,10 +10146,7 @@ void OBSBasic::AudioMixerPasteFilters()
|
||||
OBSSourceAutoRelease source =
|
||||
obs_weak_source_get_source(copyFiltersSource);
|
||||
|
||||
if (source == dstSource)
|
||||
return;
|
||||
|
||||
obs_source_copy_filters(dstSource, source);
|
||||
SourcePasteFilters(source.Get(), dstSource);
|
||||
}
|
||||
|
||||
void OBSBasic::SceneCopyFilters()
|
||||
@@ -10145,10 +10162,7 @@ void OBSBasic::ScenePasteFilters()
|
||||
|
||||
OBSSource dstSource = GetCurrentSceneSource();
|
||||
|
||||
if (source == dstSource)
|
||||
return;
|
||||
|
||||
obs_source_copy_filters(dstSource, source);
|
||||
SourcePasteFilters(source.Get(), dstSource);
|
||||
}
|
||||
|
||||
void OBSBasic::on_actionCopyFilters_triggered()
|
||||
@@ -10206,22 +10220,7 @@ void OBSBasic::on_actionPasteFilters_triggered()
|
||||
OBSSceneItem sceneItem = GetCurrentSceneItem();
|
||||
OBSSource dstSource = obs_sceneitem_get_source(sceneItem);
|
||||
|
||||
if (source == dstSource)
|
||||
return;
|
||||
|
||||
OBSDataArrayAutoRelease undo_array =
|
||||
obs_source_backup_filters(dstSource);
|
||||
obs_source_copy_filters(dstSource, source);
|
||||
OBSDataArrayAutoRelease redo_array =
|
||||
obs_source_backup_filters(dstSource);
|
||||
|
||||
const char *srcName = obs_source_get_name(source);
|
||||
const char *dstName = obs_source_get_name(dstSource);
|
||||
QString text =
|
||||
QTStr("Undo.Filters.Paste.Multiple").arg(srcName, dstName);
|
||||
|
||||
CreateFilterPasteUndoRedoAction(text, dstSource, undo_array,
|
||||
redo_array);
|
||||
SourcePasteFilters(source.Get(), dstSource);
|
||||
}
|
||||
|
||||
static void ConfirmColor(SourceTree *sources, const QColor &color,
|
||||
|
||||
Reference in New Issue
Block a user