mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-10-10 10:40:04 -05:00
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
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:
@@ -1,4 +1,5 @@
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-undo-redo.hpp"
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "macro-helpers.hpp"
|
||||
#include "macro-settings.hpp"
|
||||
@@ -111,9 +112,31 @@ void MacroActionEdit::ActionSelectionChanged(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();
|
||||
OBSDataAutoRelease oldData = obs_data_create();
|
||||
(*_entryData)->Save(oldData);
|
||||
|
||||
HeaderInfoChanged("");
|
||||
auto idx = _entryData->get()->GetIndex();
|
||||
auto macro = _entryData->get()->GetMacro();
|
||||
|
||||
const auto *rawPtr = (*_entryData).get();
|
||||
const auto &elseActions = macro->ElseActions();
|
||||
const bool isElse = std::any_of(elseActions.begin(), elseActions.end(),
|
||||
[rawPtr](const auto &a) {
|
||||
return a.get() == rawPtr;
|
||||
});
|
||||
const auto segmentType = isElse ? MacroEdit::SegmentType::ELSE_ACTION
|
||||
: MacroEdit::SegmentType::ACTION;
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
_entryData->reset();
|
||||
@@ -122,6 +145,16 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
||||
(*_entryData)->PostLoad();
|
||||
RunAndClearPostLoadSteps();
|
||||
}
|
||||
|
||||
OBSDataAutoRelease newData = obs_data_create();
|
||||
(*_entryData)->Save(newData);
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
} else {
|
||||
RegisterSegmentTypeChangeUndoRedo(macro, segmentType, idx,
|
||||
oldId, oldData, 0, id,
|
||||
newData, 0);
|
||||
}
|
||||
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
|
||||
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
||||
this, SLOT(HeaderInfoChanged(const QString &)));
|
||||
|
||||
Reference in New Issue
Block a user