mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-03 07:45:50 -05:00
Add support for variables in various path selections
This commit is contained in:
parent
b607940c8c
commit
2806fd6cdb
|
|
@ -55,7 +55,7 @@ void MacroActionFile::LogAction() const
|
|||
bool MacroActionFile::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroAction::Save(obj);
|
||||
obs_data_set_string(obj, "file", _file.c_str());
|
||||
_file.Save(obj, "file");
|
||||
_text.Save(obj, "text");
|
||||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||
return true;
|
||||
|
|
@ -64,7 +64,7 @@ bool MacroActionFile::Save(obs_data_t *obj) const
|
|||
bool MacroActionFile::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroAction::Load(obj);
|
||||
_file = obs_data_get_string(obj, "file");
|
||||
_file.Load(obj, "file");
|
||||
_text.Load(obj, "text");
|
||||
_action = static_cast<FileAction>(obs_data_get_int(obj, "action"));
|
||||
return true;
|
||||
|
|
@ -72,7 +72,7 @@ bool MacroActionFile::Load(obs_data_t *obj)
|
|||
|
||||
std::string MacroActionFile::GetShortDesc() const
|
||||
{
|
||||
return _file;
|
||||
return _file.UnresolvedValue();
|
||||
}
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
return std::make_shared<MacroActionFile>(m);
|
||||
}
|
||||
|
||||
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
StringVariable _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
StringVariable _text = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
FileAction _action = FileAction::WRITE;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ bool MacroActionPluginState::Save(obs_data_t *obj) const
|
|||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||
obs_data_set_int(obj, "value", _value);
|
||||
obs_data_set_string(obj, "scene", GetWeakSourceName(_scene).c_str());
|
||||
obs_data_set_string(obj, "settingsPath", _settingsPath.c_str());
|
||||
_settingsPath.Save(obj, "settingsPath");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ bool MacroActionPluginState::Load(obs_data_t *obj)
|
|||
_value = obs_data_get_int(obj, "value");
|
||||
const char *sceneName = obs_data_get_string(obj, "scene");
|
||||
_scene = GetWeakSourceByName(sceneName);
|
||||
_settingsPath = obs_data_get_string(obj, "settingsPath");
|
||||
_settingsPath.Load(obj, "settingsPath");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ void MacroActionPluginStateEdit::UpdateEntryData()
|
|||
populateValueSelection(_values, _entryData->_action);
|
||||
_values->setCurrentIndex(_entryData->_value);
|
||||
_scenes->setCurrentText(GetWeakSourceName(_entryData->_scene).c_str());
|
||||
_settings->SetPath(QString::fromStdString(_entryData->_settingsPath));
|
||||
_settings->SetPath(_entryData->_settingsPath);
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
PluginStateAction _action = PluginStateAction::STOP;
|
||||
int _value = 0;
|
||||
std::string _settingsPath;
|
||||
StringVariable _settingsPath;
|
||||
OBSWeakSource _scene;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ bool MacroActionRun::PerformAction()
|
|||
|
||||
void MacroActionRun::LogAction() const
|
||||
{
|
||||
vblog(LOG_INFO, "run \"%s\"", _procConfig.Path().c_str());
|
||||
vblog(LOG_INFO, "run \"%s\"", _procConfig.UnresolvedPath().c_str());
|
||||
}
|
||||
|
||||
bool MacroActionRun::Save(obs_data_t *obj) const
|
||||
|
|
@ -46,7 +46,7 @@ bool MacroActionRun::Load(obs_data_t *obj)
|
|||
|
||||
std::string MacroActionRun::GetShortDesc() const
|
||||
{
|
||||
return _procConfig.Path();
|
||||
return _procConfig.UnresolvedPath();
|
||||
}
|
||||
|
||||
MacroActionRunEdit::MacroActionRunEdit(
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ bool MacroConditionFile::MatchFileContent(QString &filedata)
|
|||
|
||||
bool MacroConditionFile::CheckRemoteFileContent()
|
||||
{
|
||||
std::string data = getRemoteData(_file);
|
||||
std::string path = _file;
|
||||
std::string data = getRemoteData(path);
|
||||
SetVariableValue(data);
|
||||
QString qdata = QString::fromStdString(data);
|
||||
return MatchFileContent(qdata);
|
||||
|
|
@ -99,7 +100,8 @@ bool MacroConditionFile::CheckChangeContent()
|
|||
QString filedata;
|
||||
switch (_fileType) {
|
||||
case FileType::LOCAL: {
|
||||
QFile file(QString::fromStdString(_file));
|
||||
std::string path = _file;
|
||||
QFile file(QString::fromStdString(path));
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -107,7 +109,8 @@ bool MacroConditionFile::CheckChangeContent()
|
|||
file.close();
|
||||
} break;
|
||||
case FileType::REMOTE: {
|
||||
std::string data = getRemoteData(_file);
|
||||
std::string path = _file;
|
||||
std::string data = getRemoteData(path);
|
||||
QString filedata = QString::fromStdString(data);
|
||||
} break;
|
||||
default:
|
||||
|
|
@ -166,7 +169,7 @@ bool MacroConditionFile::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroCondition::Save(obj);
|
||||
_regex.Save(obj);
|
||||
obs_data_set_string(obj, "file", _file.c_str());
|
||||
_file.Save(obj, "file");
|
||||
_text.Save(obj, "text");
|
||||
obs_data_set_int(obj, "fileType", static_cast<int>(_fileType));
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
||||
|
|
@ -184,7 +187,7 @@ bool MacroConditionFile::Load(obs_data_t *obj)
|
|||
_regex.CreateBackwardsCompatibleRegex(
|
||||
obs_data_get_bool(obj, "useRegex"));
|
||||
}
|
||||
_file = obs_data_get_string(obj, "file");
|
||||
_file.Load(obj, "file");
|
||||
_text.Load(obj, "text");
|
||||
_fileType = static_cast<FileType>(obs_data_get_int(obj, "fileType"));
|
||||
_condition =
|
||||
|
|
@ -196,7 +199,7 @@ bool MacroConditionFile::Load(obs_data_t *obj)
|
|||
|
||||
std::string MacroConditionFile::GetShortDesc() const
|
||||
{
|
||||
return _file;
|
||||
return _file.UnresolvedValue();
|
||||
}
|
||||
|
||||
static void populateFileTypes(QComboBox *list)
|
||||
|
|
@ -292,7 +295,7 @@ void MacroConditionFileEdit::UpdateEntryData()
|
|||
|
||||
_fileTypes->setCurrentIndex(static_cast<int>(_entryData->_fileType));
|
||||
_conditions->setCurrentIndex(static_cast<int>(_entryData->_condition));
|
||||
_filePath->SetPath(QString::fromStdString(_entryData->_file));
|
||||
_filePath->SetPath(_entryData->_file);
|
||||
_matchText->setPlainText(_entryData->_text);
|
||||
_regex->SetRegexConfig(_entryData->_regex);
|
||||
_checkModificationDate->setChecked(_entryData->_useTime);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
DATE_CHANGE,
|
||||
};
|
||||
|
||||
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
StringVariable _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
StringVariable _text = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
FileType _fileType = FileType::LOCAL;
|
||||
ConditionType _condition = ConditionType::MATCH;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ bool MacroConditionRun::Load(obs_data_t *obj)
|
|||
|
||||
std::string MacroConditionRun::GetShortDesc() const
|
||||
{
|
||||
return _procConfig.Path();
|
||||
return _procConfig.UnresolvedPath();
|
||||
}
|
||||
|
||||
MacroConditionRunEdit::MacroConditionRunEdit(
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@
|
|||
bool ProcessConfig::Save(obs_data_t *obj) const
|
||||
{
|
||||
auto data = obs_data_create();
|
||||
obs_data_set_string(data, "path", _path.c_str());
|
||||
obs_data_set_string(data, "workingDirectory",
|
||||
_workingDirectory.c_str());
|
||||
_path.Save(data, "path");
|
||||
_workingDirectory.Save(data, "workingDirectory");
|
||||
_args.Save(data, "args", "arg");
|
||||
obs_data_set_obj(obj, "processConfig", data);
|
||||
obs_data_release(data);
|
||||
|
|
@ -29,8 +28,8 @@ bool ProcessConfig::Load(obs_data_t *obj)
|
|||
}
|
||||
|
||||
auto data = obs_data_get_obj(obj, "processConfig");
|
||||
_path = obs_data_get_string(data, "path");
|
||||
_workingDirectory = obs_data_get_string(data, "workingDirectory");
|
||||
_path.Load(data, "path");
|
||||
_workingDirectory.Load(data, "workingDirectory");
|
||||
_args.Load(data, "args", "arg");
|
||||
obs_data_release(data);
|
||||
return true;
|
||||
|
|
@ -101,12 +100,12 @@ ProcessConfigEdit::ProcessConfigEdit(QWidget *parent)
|
|||
void ProcessConfigEdit::SetProcessConfig(const ProcessConfig &conf)
|
||||
{
|
||||
_conf = conf;
|
||||
_filePath->SetPath(QString::fromStdString(conf._path));
|
||||
_filePath->SetPath(conf._path);
|
||||
_argList->SetStringList(conf._args);
|
||||
_workingDirectory->SetPath(
|
||||
QString::fromStdString(conf._workingDirectory));
|
||||
ShowAdvancedSettings(!_conf._args.empty() ||
|
||||
!_conf._workingDirectory.empty());
|
||||
_workingDirectory->SetPath(conf._workingDirectory);
|
||||
ShowAdvancedSettings(
|
||||
!_conf._args.empty() ||
|
||||
!_conf._workingDirectory.UnresolvedValue().empty());
|
||||
}
|
||||
|
||||
void ProcessConfigEdit::PathChanged(const QString &text)
|
||||
|
|
|
|||
|
|
@ -15,13 +15,14 @@ public:
|
|||
bool Save(obs_data_t *obj) const;
|
||||
bool Load(obs_data_t *obj);
|
||||
|
||||
std::string Path() const { return _path; }
|
||||
std::string WorkingDir() const { return _workingDirectory; }
|
||||
std::string Path() { return _path; }
|
||||
std::string UnresolvedPath() const { return _path.UnresolvedValue(); }
|
||||
std::string WorkingDir() { return _workingDirectory; }
|
||||
QStringList Args(); // Resolves variables
|
||||
|
||||
private:
|
||||
std::string _path = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
std::string _workingDirectory = "";
|
||||
StringVariable _path = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
StringVariable _workingDirectory = "";
|
||||
StringList _args;
|
||||
|
||||
friend class ProcessConfigEdit;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user