mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-11 19:58:49 -05:00
Add support to resolve variables on action queue add
This commit is contained in:
@@ -14,9 +14,11 @@ bool MacroActionFile::_registered = MacroActionFactory::Register(
|
||||
{MacroActionFile::Create, MacroActionFileEdit::Create,
|
||||
"AdvSceneSwitcher.action.file"});
|
||||
|
||||
const static std::map<FileAction, std::string> actionTypes = {
|
||||
{FileAction::WRITE, "AdvSceneSwitcher.action.file.type.write"},
|
||||
{FileAction::APPEND, "AdvSceneSwitcher.action.file.type.append"},
|
||||
static const std::map<MacroActionFile::Action, std::string> actionTypes = {
|
||||
{MacroActionFile::Action::WRITE,
|
||||
"AdvSceneSwitcher.action.file.type.write"},
|
||||
{MacroActionFile::Action::APPEND,
|
||||
"AdvSceneSwitcher.action.file.type.append"},
|
||||
};
|
||||
|
||||
bool MacroActionFile::PerformAction()
|
||||
@@ -25,10 +27,10 @@ bool MacroActionFile::PerformAction()
|
||||
QFile file(path);
|
||||
bool open = false;
|
||||
switch (_action) {
|
||||
case FileAction::WRITE:
|
||||
case Action::WRITE:
|
||||
open = file.open(QIODevice::WriteOnly);
|
||||
break;
|
||||
case FileAction::APPEND:
|
||||
case Action::APPEND:
|
||||
open = file.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||
break;
|
||||
default:
|
||||
@@ -67,7 +69,7 @@ bool MacroActionFile::Load(obs_data_t *obj)
|
||||
MacroAction::Load(obj);
|
||||
_file.Load(obj, "file");
|
||||
_text.Load(obj, "text");
|
||||
_action = static_cast<FileAction>(obs_data_get_int(obj, "action"));
|
||||
_action = static_cast<Action>(obs_data_get_int(obj, "action"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,21 +78,36 @@ std::string MacroActionFile::GetShortDesc() const
|
||||
return _file.UnresolvedValue();
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionFile::Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionFile>(m);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionFile::Copy() const
|
||||
{
|
||||
return std::make_shared<MacroActionFile>(*this);
|
||||
}
|
||||
|
||||
void MacroActionFile::ResolveVariablesToFixedValues()
|
||||
{
|
||||
_file.ResolveVariables();
|
||||
_text.ResolveVariables();
|
||||
}
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (auto entry : actionTypes) {
|
||||
list->addItem(obs_module_text(entry.second.c_str()));
|
||||
for (const auto &[_, name] : actionTypes) {
|
||||
list->addItem(obs_module_text(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
MacroActionFileEdit::MacroActionFileEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionFile> entryData)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
_filePath(new FileSelection(FileSelection::Type::WRITE)),
|
||||
_text(new VariableTextEdit(this)),
|
||||
_actions(new QComboBox())
|
||||
{
|
||||
_filePath = new FileSelection(FileSelection::Type::WRITE);
|
||||
_text = new VariableTextEdit(this);
|
||||
_actions = new QComboBox();
|
||||
|
||||
populateActionSelection(_actions);
|
||||
|
||||
QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -166,7 +183,7 @@ void MacroActionFileEdit::ActionChanged(int value)
|
||||
}
|
||||
|
||||
auto lock = LockContext();
|
||||
_entryData->_action = static_cast<FileAction>(value);
|
||||
_entryData->_action = static_cast<MacroActionFile::Action>(value);
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user