Add warning if temp vars are not available for "Run" action

This commit is contained in:
WarmUpTill 2024-09-06 20:07:48 +02:00 committed by WarmUpTill
parent 3a87a8d155
commit 790ac50385
3 changed files with 27 additions and 16 deletions

View File

@ -1774,6 +1774,9 @@ AdvSceneSwitcher.tempVar.run.process.stream.output="Process standard output stre
AdvSceneSwitcher.tempVar.run.process.stream.output.description="Full standard output stream, usually numbered 1 and what you see in CLI after running the command."
AdvSceneSwitcher.tempVar.run.process.stream.error="Process standard error stream"
AdvSceneSwitcher.tempVar.run.process.stream.error.description="Full standard error stream, usually numbered 2."
AdvSceneSwitcher.tempVar.run.process.none.description="Full standard error stream, usually numbered 2."
AdvSceneSwitcher.tempVar.run.process.none="No variables available for the \"Run\" action!"
AdvSceneSwitcher.tempVar.run.process.none.description="When not waiting for the action to finish no variables will be available.\nThe option to wait for the action to complete can be found in the advanced settings."
AdvSceneSwitcher.tempVar.recording.durationSeconds="Recording duration"
AdvSceneSwitcher.tempVar.recording.durationSeconds.description="Recording duration in seconds.\nThis value does not change while the recording is paused and will be reset to zero if the recording is stopped."

View File

@ -43,6 +43,16 @@ void MacroActionRun::SetupTempVars()
{
MacroAction::SetupTempVars();
if (!_wait) {
AddTempvar(
"process.none",
obs_module_text(
"AdvSceneSwitcher.tempVar.run.process.none"),
obs_module_text(
"AdvSceneSwitcher.tempVar.run.process.none.description"));
return;
}
AddTempvar(
"process.id",
obs_module_text("AdvSceneSwitcher.tempVar.run.process.id"),
@ -122,6 +132,12 @@ void MacroActionRun::ResolveVariablesToFixedValues()
_timeout.ResolveVariables();
}
void MacroActionRun::SetWaitEnabled(bool value)
{
_wait = value;
SetupTempVars();
}
MacroActionRunEdit::MacroActionRunEdit(
QWidget *parent, std::shared_ptr<MacroActionRun> entryData)
: QWidget(parent),
@ -167,7 +183,7 @@ void MacroActionRunEdit::UpdateEntryData()
return;
}
_procConfig->SetProcessConfig(_entryData->_procConfig);
_wait->setChecked(_entryData->_wait);
_wait->setChecked(_entryData->IsWaitEnabled());
_timeout->SetDuration(_entryData->_timeout);
}
@ -178,29 +194,19 @@ void MacroActionRunEdit::ProcessConfigAdvancedSettingsShown()
void MacroActionRunEdit::WaitChanged(int value)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
_entryData->_wait = value;
GUARD_LOADING_AND_LOCK();
_entryData->SetWaitEnabled(value);
}
void MacroActionRunEdit::TimeoutChanged(const Duration &timeout)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_timeout = timeout;
}
void MacroActionRunEdit::ProcessConfigChanged(const ProcessConfig &conf)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_procConfig = conf;
adjustSize();
updateGeometry();

View File

@ -20,15 +20,17 @@ public:
static std::shared_ptr<MacroAction> Create(Macro *m);
std::shared_ptr<MacroAction> Copy() const;
void ResolveVariablesToFixedValues();
void SetWaitEnabled(bool value);
bool IsWaitEnabled() const { return _wait; }
ProcessConfig _procConfig;
bool _wait = false;
Duration _timeout = 1;
private:
void SetupTempVars();
void SetTempVarValues();
bool _wait = false;
static bool _registered;
static const std::string id;
};