Add undo / redo support for macros
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
WarmUpTill
2026-08-12 11:48:53 +02:00
committed by WarmUpTill
parent afd9154c84
commit 7ea944e1a3
17 changed files with 1768 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
#include "macro-condition-edit.hpp"
#include "macro-undo-redo.hpp"
#include "advanced-scene-switcher.hpp"
#include "condition-logic.hpp"
@@ -250,6 +251,19 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
return;
}
Macro *const parentMacro =
(*_entryData)->GetMacro()->GetNestedParentMacro();
OBSDataAutoRelease parentBeforeData;
if (parentMacro) {
parentBeforeData = obs_data_create();
parentMacro->Save(parentBeforeData);
}
const std::string oldId = (*_entryData)->GetId();
const int oldLogic = (int)(*_entryData)->GetLogicType();
OBSDataAutoRelease oldData = obs_data_create();
(*_entryData)->Save(oldData);
auto temp = DurationModifier();
_dur->SetValue(temp);
HeaderInfoChanged("");
@@ -267,6 +281,17 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
(*_entryData)->PostLoad();
RunAndClearPostLoadSteps();
}
OBSDataAutoRelease newData = obs_data_create();
(*_entryData)->Save(newData);
if (parentMacro) {
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
} else {
RegisterSegmentTypeChangeUndoRedo(
macro, MacroEdit::SegmentType::CONDITION, idx, oldId,
oldData, oldLogic, id, newData,
(int)(*_entryData)->GetLogicType());
}
auto widget =
MacroConditionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),