mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-13 04:37:14 -05:00
Improve file condition
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
* Add support for existence check * Add support for "is file" check * Add support for "is folder" check * Add more temp vars
This commit is contained in:
@@ -156,6 +156,42 @@ void MacroConditionFile::SetupTempVars()
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.content"));
|
||||
}
|
||||
|
||||
if (_fileType == FileType::REMOTE) {
|
||||
return;
|
||||
}
|
||||
|
||||
AddTempvar(
|
||||
"basename",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.file.basename"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.basename.description"));
|
||||
AddTempvar(
|
||||
"basenameComplete",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.basenameComplete"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.basenameComplete.description"));
|
||||
AddTempvar("suffix",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.file.suffix"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.suffix.description"));
|
||||
AddTempvar(
|
||||
"suffixComplete",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.file.suffixComplete"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.suffixComplete.description"));
|
||||
AddTempvar("filename",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.file.filename"));
|
||||
AddTempvar("absoluteFilePath",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.absoluteFilePath"));
|
||||
AddTempvar(
|
||||
"absolutePath",
|
||||
obs_module_text("AdvSceneSwitcher.tempVar.file.absolutePath"));
|
||||
AddTempvar("isAbsolutePath",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.file.isAbsolutePath"));
|
||||
}
|
||||
|
||||
bool MacroConditionFile::CheckCondition()
|
||||
@@ -175,10 +211,47 @@ bool MacroConditionFile::CheckCondition()
|
||||
case Condition::DATE_CHANGE:
|
||||
ret = CheckChangeDate();
|
||||
break;
|
||||
case Condition::IS_FILE: {
|
||||
QFileInfo info(QString::fromStdString(_file));
|
||||
ret = info.isFile();
|
||||
break;
|
||||
}
|
||||
case Condition::IS_FOLDER: {
|
||||
QFileInfo info(QString::fromStdString(_file));
|
||||
ret = info.isDir();
|
||||
break;
|
||||
}
|
||||
case Condition::EXISTS: {
|
||||
QFileInfo info(QString::fromStdString(_file));
|
||||
ret = info.exists();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (std::string(_file) != _lastFile) {
|
||||
QFileInfo info(QString::fromStdString(_file));
|
||||
_basename = info.baseName().toStdString();
|
||||
_basenameComplete = info.completeBaseName().toStdString();
|
||||
_suffix = info.suffix().toStdString();
|
||||
_suffixComplete = info.completeSuffix().toStdString();
|
||||
_filename = info.fileName().toStdString();
|
||||
_absoluteFilePath = info.absoluteFilePath().toStdString();
|
||||
_absolutePath = info.absolutePath().toStdString();
|
||||
_isAbsolutePath = info.isAbsolute();
|
||||
_lastFile = _file;
|
||||
}
|
||||
|
||||
SetTempVarValue("basename", _basename);
|
||||
SetTempVarValue("basenameComplete", _basenameComplete);
|
||||
SetTempVarValue("suffix", _suffix);
|
||||
SetTempVarValue("suffixComplete", _suffixComplete);
|
||||
SetTempVarValue("filename", _filename);
|
||||
SetTempVarValue("absoluteFilePath", _absoluteFilePath);
|
||||
SetTempVarValue("absolutePath", _absolutePath);
|
||||
SetTempVarValue("isAbsolutePath", _isAbsolutePath);
|
||||
|
||||
if (GetVariableValue().empty()) {
|
||||
SetVariableValue(ret ? "true" : "false");
|
||||
}
|
||||
@@ -237,6 +310,12 @@ static void populateConditions(QComboBox *list)
|
||||
"AdvSceneSwitcher.condition.file.type.contentChange"));
|
||||
list->addItem(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.file.type.dateChange"));
|
||||
list->addItem(
|
||||
obs_module_text("AdvSceneSwitcher.condition.file.type.exists"));
|
||||
list->addItem(
|
||||
obs_module_text("AdvSceneSwitcher.condition.file.type.isFile"));
|
||||
list->addItem(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.file.type.isFolder"));
|
||||
}
|
||||
|
||||
MacroConditionFileEdit::MacroConditionFileEdit(
|
||||
|
||||
Reference in New Issue
Block a user