Skip to content

Commit

Permalink
Enable use of variables in find and replace options of variable action
Browse files Browse the repository at this point in the history
  • Loading branch information
WarmUpTill committed Nov 17, 2023
1 parent 54cd7f2 commit 74c3601
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
17 changes: 8 additions & 9 deletions src/macro-core/macro-action-variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ bool MacroActionVariable::Save(obs_data_t *obj) const
obs_data_set_int(obj, "subStringSize", _subStringSize);
obs_data_set_string(obj, "regexPattern", _regexPattern.c_str());
obs_data_set_int(obj, "regexMatchIdx", _regexMatchIdx);
obs_data_set_string(obj, "findStr", _findStr.c_str());
obs_data_set_string(obj, "replaceStr", _replaceStr.c_str());
_findStr.Save(obj, "findStr");
_replaceStr.Save(obj, "replaceStr");
_regex.Save(obj);
_mathExpression.Save(obj, "mathExpression");
obs_data_set_bool(obj, "useCustomPrompt", _useCustomPrompt);
Expand Down Expand Up @@ -318,8 +318,8 @@ bool MacroActionVariable::Load(obs_data_t *obj)
_regex.Load(obj);
_regexPattern = obs_data_get_string(obj, "regexPattern");
_regexMatchIdx = obs_data_get_int(obj, "regexMatchIdx");
_findStr = obs_data_get_string(obj, "findStr");
_replaceStr = obs_data_get_string(obj, "replaceStr");
_findStr.Load(obj, "findStr");
_replaceStr.Load(obj, "replaceStr");
_mathExpression.Load(obj, "mathExpression");
_useCustomPrompt = obs_data_get_bool(obj, "useCustomPrompt");
_inputPrompt.Load(obj, "inputPrompt");
Expand Down Expand Up @@ -444,8 +444,8 @@ MacroActionVariableEdit::MacroActionVariableEdit(
_regexPattern(new ResizingPlainTextEdit(this, 10, 1, 1)),
_regexMatchIdx(new QSpinBox()),
_findReplaceLayout(new QHBoxLayout()),
_findStr(new ResizingPlainTextEdit(this, 10, 1, 1)),
_replaceStr(new ResizingPlainTextEdit(this, 10, 1, 1)),
_findStr(new VariableTextEdit(this, 10, 1, 1)),
_replaceStr(new VariableTextEdit(this, 10, 1, 1)),
_mathExpression(new VariableLineEdit(this)),
_mathExpressionResult(new QLabel()),
_promptLayout(new QHBoxLayout()),
Expand Down Expand Up @@ -628,9 +628,8 @@ void MacroActionVariableEdit::UpdateEntryData()
_regexPattern->setPlainText(
QString::fromStdString(_entryData->_regexPattern));
_regexMatchIdx->setValue(_entryData->_regexMatchIdx + 1);
_findStr->setPlainText(QString::fromStdString(_entryData->_findStr));
_replaceStr->setPlainText(
QString::fromStdString(_entryData->_replaceStr));
_findStr->setPlainText(_entryData->_findStr);
_replaceStr->setPlainText(_entryData->_replaceStr);
_mathExpression->setText(_entryData->_mathExpression);
_useCustomPrompt->setChecked(_entryData->_useCustomPrompt);
_inputPrompt->setText(_entryData->_inputPrompt);
Expand Down
8 changes: 4 additions & 4 deletions src/macro-core/macro-action-variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class MacroActionVariable : public MacroAction {
RegexConfig _regex = RegexConfig::PartialMatchRegexConfig();
std::string _regexPattern = ".*";
int _regexMatchIdx = 0;
std::string _findStr = obs_module_text(
StringVariable _findStr = obs_module_text(
"AdvSceneSwitcher.action.variable.findAndReplace.find");
std::string _replaceStr = obs_module_text(
StringVariable _replaceStr = obs_module_text(
"AdvSceneSwitcher.action.variable.findAndReplace.replace");
StringVariable _mathExpression = obs_module_text(
"AdvSceneSwitcher.action.variable.mathExpression.example");
Expand Down Expand Up @@ -154,8 +154,8 @@ private slots:
ResizingPlainTextEdit *_regexPattern;
QSpinBox *_regexMatchIdx;
QHBoxLayout *_findReplaceLayout;
ResizingPlainTextEdit *_findStr;
ResizingPlainTextEdit *_replaceStr;
VariableTextEdit *_findStr;
VariableTextEdit *_replaceStr;
VariableLineEdit *_mathExpression;
QLabel *_mathExpressionResult;
QHBoxLayout *_promptLayout;
Expand Down

0 comments on commit 74c3601

Please sign in to comment.