mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-26 20:05:25 -05:00
Add support for variables in text edit widgets of actions and conditions
This commit is contained in:
parent
f106329892
commit
e4f9ccec3f
|
|
@ -56,7 +56,7 @@ bool MacroActionFile::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroAction::Save(obj);
|
||||
obs_data_set_string(obj, "file", _file.c_str());
|
||||
obs_data_set_string(obj, "text", _text.c_str());
|
||||
_text.Save(obj, "text");
|
||||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ bool MacroActionFile::Load(obs_data_t *obj)
|
|||
{
|
||||
MacroAction::Load(obj);
|
||||
_file = obs_data_get_string(obj, "file");
|
||||
_text = obs_data_get_string(obj, "text");
|
||||
_text.Load(obj, "text");
|
||||
_action = static_cast<FileAction>(obs_data_get_int(obj, "action"));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ MacroActionFileEdit::MacroActionFileEdit(
|
|||
: QWidget(parent)
|
||||
{
|
||||
_filePath = new FileSelection(FileSelection::Type::WRITE);
|
||||
_text = new ResizingPlainTextEdit(this);
|
||||
_text = new VariableTextEdit(this);
|
||||
_actions = new QComboBox();
|
||||
|
||||
populateActionSelection(_actions);
|
||||
|
|
@ -127,7 +127,7 @@ void MacroActionFileEdit::UpdateEntryData()
|
|||
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
||||
_filePath->SetPath(QString::fromStdString(_entryData->_file));
|
||||
_text->setPlainText(QString::fromStdString(_entryData->_text));
|
||||
_text->setPlainText(_entryData->_text);
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "file-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
|
|
@ -25,7 +25,8 @@ public:
|
|||
}
|
||||
|
||||
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
std::string _text = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
VariableResolvingString _text =
|
||||
obs_module_text("AdvSceneSwitcher.enterText");
|
||||
FileAction _action = FileAction::WRITE;
|
||||
|
||||
private:
|
||||
|
|
@ -58,7 +59,7 @@ signals:
|
|||
|
||||
protected:
|
||||
FileSelection *_filePath;
|
||||
ResizingPlainTextEdit *_text;
|
||||
VariableTextEdit *_text;
|
||||
QComboBox *_actions;
|
||||
std::shared_ptr<MacroActionFile> _entryData;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ bool MacroActionFilter::Save(obs_data_t *obj) const
|
|||
obs_data_set_string(obj, "source", GetWeakSourceName(_source).c_str());
|
||||
obs_data_set_string(obj, "filter", GetWeakSourceName(_filter).c_str());
|
||||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||
obs_data_set_string(obj, "settings", _settings.c_str());
|
||||
_settings.Save(obj, "settings");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ bool MacroActionFilter::Load(obs_data_t *obj)
|
|||
const char *filterName = obs_data_get_string(obj, "filter");
|
||||
_filter = GetWeakFilterByQString(_source, filterName);
|
||||
_action = static_cast<FilterAction>(obs_data_get_int(obj, "action"));
|
||||
_settings = obs_data_get_string(obj, "settings");
|
||||
_settings.Load(obj, "settings");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ MacroActionFilterEdit::MacroActionFilterEdit(
|
|||
_actions = new QComboBox();
|
||||
_getSettings = new QPushButton(
|
||||
obs_module_text("AdvSceneSwitcher.action.filter.getSettings"));
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_settings = new VariableTextEdit(this);
|
||||
|
||||
populateActionSelection(_actions);
|
||||
populateSourcesWithFilterSelection(_sources);
|
||||
|
|
@ -151,7 +151,7 @@ void MacroActionFilterEdit::UpdateEntryData()
|
|||
populateFilterSelection(_filters, _entryData->_source);
|
||||
_filters->setCurrentText(
|
||||
GetWeakSourceName(_entryData->_filter).c_str());
|
||||
_settings->setPlainText(QString::fromStdString(_entryData->_settings));
|
||||
_settings->setPlainText(_entryData->_settings);
|
||||
SetWidgetVisibility(_entryData->_action == FilterAction::SETTINGS);
|
||||
|
||||
adjustSize();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
OBSWeakSource _source;
|
||||
OBSWeakSource _filter;
|
||||
FilterAction _action = FilterAction::ENABLE;
|
||||
std::string _settings = "";
|
||||
VariableResolvingString _settings = "";
|
||||
|
||||
private:
|
||||
static bool _registered;
|
||||
|
|
@ -66,7 +66,7 @@ protected:
|
|||
QComboBox *_filters;
|
||||
QComboBox *_actions;
|
||||
QPushButton *_getSettings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
VariableTextEdit *_settings;
|
||||
std::shared_ptr<MacroActionFilter> _entryData;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ bool MacroActionHttp::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroAction::Save(obj);
|
||||
obs_data_set_string(obj, "url", _url.c_str());
|
||||
obs_data_set_string(obj, "data", _data.c_str());
|
||||
_data.Save(obj, "data");
|
||||
obs_data_set_int(obj, "method", static_cast<int>(_method));
|
||||
_timeout.Save(obj);
|
||||
return true;
|
||||
|
|
@ -91,7 +91,7 @@ bool MacroActionHttp::Load(obs_data_t *obj)
|
|||
{
|
||||
MacroAction::Load(obj);
|
||||
_url = obs_data_get_string(obj, "url");
|
||||
_data = obs_data_get_string(obj, "data");
|
||||
_data.Load(obj, "data");
|
||||
_method = static_cast<Method>(obs_data_get_int(obj, "method"));
|
||||
_timeout.Load(obj);
|
||||
return true;
|
||||
|
|
@ -114,7 +114,7 @@ MacroActionHttpEdit::MacroActionHttpEdit(
|
|||
: QWidget(parent),
|
||||
_url(new QLineEdit()),
|
||||
_methods(new QComboBox()),
|
||||
_data(new ResizingPlainTextEdit(this)),
|
||||
_data(new VariableTextEdit(this)),
|
||||
_timeout(new DurationSelection(this, false))
|
||||
{
|
||||
populateMethodSelection(_methods);
|
||||
|
|
@ -161,7 +161,7 @@ void MacroActionHttpEdit::UpdateEntryData()
|
|||
}
|
||||
|
||||
_url->setText(QString::fromStdString(_entryData->_url));
|
||||
_data->setPlainText(QString::fromStdString(_entryData->_data));
|
||||
_data->setPlainText(_entryData->_data);
|
||||
_methods->setCurrentIndex(static_cast<int>(_entryData->_method));
|
||||
_timeout->SetDuration(_entryData->_timeout);
|
||||
SetWidgetVisibility();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "duration-control.hpp"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
|
@ -26,7 +26,8 @@ public:
|
|||
};
|
||||
|
||||
std::string _url = obs_module_text("AdvSceneSwitcher.enterURL");
|
||||
std::string _data = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
VariableResolvingString _data =
|
||||
obs_module_text("AdvSceneSwitcher.enterText");
|
||||
Method _method = Method::GET;
|
||||
Duration _timeout;
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ private:
|
|||
|
||||
QLineEdit *_url;
|
||||
QComboBox *_methods;
|
||||
ResizingPlainTextEdit *_data;
|
||||
VariableTextEdit *_data;
|
||||
DurationSelection *_timeout;
|
||||
bool _loading = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ bool MacroActionSceneTransform::_registered = MacroActionFactory::Register(
|
|||
|
||||
bool MacroActionSceneTransform::PerformAction()
|
||||
{
|
||||
ApplySettings(_settings); // Resolves variables
|
||||
|
||||
auto items = _source.GetSceneItems(_scene);
|
||||
for (auto &item : items) {
|
||||
obs_sceneitem_defer_update_begin(item);
|
||||
|
|
@ -36,7 +38,7 @@ bool MacroActionSceneTransform::Save(obs_data_t *obj) const
|
|||
MacroAction::Save(obj);
|
||||
_scene.Save(obj);
|
||||
_source.Save(obj);
|
||||
saveTransformState(obj, _info, _crop);
|
||||
_settings.Save(obj, "settings");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +54,14 @@ bool MacroActionSceneTransform::Load(obs_data_t *obj)
|
|||
MacroAction::Load(obj);
|
||||
_scene.Load(obj);
|
||||
_source.Load(obj);
|
||||
loadTransformState(obj, _info, _crop);
|
||||
_settings.Load(obj, "settings");
|
||||
|
||||
// Convert old data format
|
||||
// TODO: Remove in future version
|
||||
if (!obs_data_has_user_value(obj, "settings")) {
|
||||
loadTransformState(obj, _info, _crop);
|
||||
_settings = ConvertSettings();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +73,7 @@ std::string MacroActionSceneTransform::GetShortDesc() const
|
|||
return _scene.ToString() + " - " + _source.ToString();
|
||||
}
|
||||
|
||||
std::string MacroActionSceneTransform::GetSettings()
|
||||
std::string MacroActionSceneTransform::ConvertSettings()
|
||||
{
|
||||
auto data = obs_data_create();
|
||||
saveTransformState(data, _info, _crop);
|
||||
|
|
@ -73,7 +82,7 @@ std::string MacroActionSceneTransform::GetSettings()
|
|||
return json;
|
||||
}
|
||||
|
||||
void MacroActionSceneTransform::SetSettings(std::string &settings)
|
||||
void MacroActionSceneTransform::ApplySettings(const std::string &settings)
|
||||
{
|
||||
auto data = obs_data_create_from_json(settings.c_str());
|
||||
if (!data) {
|
||||
|
|
@ -111,7 +120,7 @@ MacroActionSceneTransformEdit::MacroActionSceneTransformEdit(
|
|||
_sources = new SceneItemSelectionWidget(parent);
|
||||
_getSettings = new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.action.sceneTransform.getTransform"));
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_settings = new VariableTextEdit(this);
|
||||
|
||||
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
|
||||
this, SLOT(SceneChanged(const SceneSelection &)));
|
||||
|
|
@ -160,7 +169,7 @@ void MacroActionSceneTransformEdit::UpdateEntryData()
|
|||
|
||||
_scenes->SetScene(_entryData->_scene);
|
||||
_sources->SetSceneItem(_entryData->_source);
|
||||
_settings->setPlainText(formatJsonString(_entryData->GetSettings()));
|
||||
_settings->setPlainText(_entryData->_settings);
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
|
|
@ -213,8 +222,7 @@ void MacroActionSceneTransformEdit::SettingsChanged()
|
|||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto json = _settings->toPlainText().toStdString();
|
||||
_entryData->SetSettings(json);
|
||||
_entryData->_settings = _settings->toPlainText().toStdString();
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "macro-action-edit.hpp"
|
||||
#include "scene-selection.hpp"
|
||||
#include "scene-item-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
|
|
@ -19,15 +19,18 @@ public:
|
|||
{
|
||||
return std::make_shared<MacroActionSceneTransform>(m);
|
||||
}
|
||||
std::string GetSettings();
|
||||
void SetSettings(std::string &);
|
||||
|
||||
SceneSelection _scene;
|
||||
SceneItemSelection _source;
|
||||
VariableResolvingString _settings = "";
|
||||
|
||||
private:
|
||||
void ApplySettings(const std::string &);
|
||||
std::string ConvertSettings();
|
||||
|
||||
struct obs_transform_info _info = {};
|
||||
struct obs_sceneitem_crop _crop = {};
|
||||
|
||||
private:
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
|
|
@ -61,7 +64,7 @@ protected:
|
|||
SceneSelectionWidget *_scenes;
|
||||
SceneItemSelectionWidget *_sources;
|
||||
QPushButton *_getSettings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
VariableTextEdit *_settings;
|
||||
std::shared_ptr<MacroActionSceneTransform> _entryData;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ bool MacroActionSource::Save(obs_data_t *obj) const
|
|||
MacroAction::Save(obj);
|
||||
obs_data_set_string(obj, "source", GetWeakSourceName(_source).c_str());
|
||||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||
obs_data_set_string(obj, "settings", _settings.c_str());
|
||||
_button.Save(obj);
|
||||
_settings.Save(obj, "settings");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +128,8 @@ bool MacroActionSource::Load(obs_data_t *obj)
|
|||
const char *sourceName = obs_data_get_string(obj, "source");
|
||||
_source = GetWeakSourceByName(sourceName);
|
||||
_action = static_cast<SourceAction>(obs_data_get_int(obj, "action"));
|
||||
_settings = obs_data_get_string(obj, "settings");
|
||||
_button.Load(obj);
|
||||
_settings.Load(obj, "settings");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ MacroActionSourceEdit::MacroActionSourceEdit(
|
|||
_settingsButtons = new QComboBox();
|
||||
_getSettings = new QPushButton(
|
||||
obs_module_text("AdvSceneSwitcher.action.source.getSettings"));
|
||||
_settings = new ResizingPlainTextEdit(this);
|
||||
_settings = new VariableTextEdit(this);
|
||||
_warning = new QLabel(
|
||||
obs_module_text("AdvSceneSwitcher.action.source.warning"));
|
||||
|
||||
|
|
@ -235,9 +235,9 @@ void MacroActionSourceEdit::UpdateEntryData()
|
|||
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
|
||||
_sources->setCurrentText(
|
||||
GetWeakSourceName(_entryData->_source).c_str());
|
||||
_settings->setPlainText(QString::fromStdString(_entryData->_settings));
|
||||
_settingsButtons->setCurrentText(
|
||||
QString::fromStdString(_entryData->_button.ToString()));
|
||||
_settings->setPlainText(_entryData->_settings);
|
||||
SetWidgetVisibility();
|
||||
|
||||
adjustSize();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
|
|
@ -39,8 +39,8 @@ public:
|
|||
}
|
||||
|
||||
OBSWeakSource _source;
|
||||
std::string _settings = "";
|
||||
SourceSettingButton _button;
|
||||
VariableResolvingString _settings = "";
|
||||
SourceAction _action = SourceAction::ENABLE;
|
||||
|
||||
private:
|
||||
|
|
@ -78,7 +78,7 @@ protected:
|
|||
QComboBox *_actions;
|
||||
QComboBox *_settingsButtons;
|
||||
QPushButton *_getSettings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
VariableTextEdit *_settings;
|
||||
QLabel *_warning;
|
||||
std::shared_ptr<MacroActionSource> _entryData;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ bool MacroActionWebsocket::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroAction::Save(obj);
|
||||
obs_data_set_int(obj, "type", static_cast<int>(_type));
|
||||
obs_data_set_string(obj, "message", _message.c_str());
|
||||
_message.Save(obj, "message");
|
||||
obs_data_set_string(obj, "connection", _connection.c_str());
|
||||
return true;
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ bool MacroActionWebsocket::Load(obs_data_t *obj)
|
|||
{
|
||||
MacroAction::Load(obj);
|
||||
_type = static_cast<Type>(obs_data_get_int(obj, "type"));
|
||||
_message = obs_data_get_string(obj, "message");
|
||||
_message.Load(obj, "message");
|
||||
_connection = obs_data_get_string(obj, "connection");
|
||||
return true;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ MacroActionWebsocketEdit::MacroActionWebsocketEdit(
|
|||
QWidget *parent, std::shared_ptr<MacroActionWebsocket> entryData)
|
||||
: QWidget(parent),
|
||||
_actions(new QComboBox(this)),
|
||||
_message(new ResizingPlainTextEdit(this)),
|
||||
_message(new VariableTextEdit(this)),
|
||||
_connection(new ConnectionSelection(this)),
|
||||
_editLayout(new QHBoxLayout())
|
||||
{
|
||||
|
|
@ -155,7 +155,7 @@ void MacroActionWebsocketEdit::UpdateEntryData()
|
|||
}
|
||||
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_type));
|
||||
_message->setPlainText(QString::fromStdString(_entryData->_message));
|
||||
_message->setPlainText(_entryData->_message);
|
||||
_connection->SetConnection(_entryData->_connection);
|
||||
|
||||
if (_entryData->_type == MacroActionWebsocket::Type::REQUEST) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "connection-manager.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
|
@ -28,7 +28,8 @@ public:
|
|||
};
|
||||
|
||||
Type _type = Type::REQUEST;
|
||||
std::string _message = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
VariableResolvingString _message =
|
||||
obs_module_text("AdvSceneSwitcher.enterText");
|
||||
std::string _connection;
|
||||
|
||||
private:
|
||||
|
|
@ -69,7 +70,7 @@ private:
|
|||
void SetupEventEdit();
|
||||
|
||||
QComboBox *_actions;
|
||||
ResizingPlainTextEdit *_message;
|
||||
VariableTextEdit *_message;
|
||||
ConnectionSelection *_connection;
|
||||
QHBoxLayout *_editLayout;
|
||||
bool _loading = true;
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ bool MacroConditionFile::Save(obs_data_t *obj) const
|
|||
MacroCondition::Save(obj);
|
||||
_regex.Save(obj);
|
||||
obs_data_set_string(obj, "file", _file.c_str());
|
||||
obs_data_set_string(obj, "text", _text.c_str());
|
||||
_text.Save(obj, "text");
|
||||
obs_data_set_int(obj, "fileType", static_cast<int>(_fileType));
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
||||
obs_data_set_bool(obj, "useTime", _useTime);
|
||||
|
|
@ -173,7 +173,7 @@ bool MacroConditionFile::Load(obs_data_t *obj)
|
|||
obs_data_get_bool(obj, "useRegex"));
|
||||
}
|
||||
_file = obs_data_get_string(obj, "file");
|
||||
_text = obs_data_get_string(obj, "text");
|
||||
_text.Load(obj, "text");
|
||||
_fileType = static_cast<FileType>(obs_data_get_int(obj, "fileType"));
|
||||
_condition =
|
||||
static_cast<ConditionType>(obs_data_get_int(obj, "condition"));
|
||||
|
|
@ -210,7 +210,7 @@ MacroConditionFileEdit::MacroConditionFileEdit(
|
|||
_fileTypes(new QComboBox()),
|
||||
_conditions(new QComboBox()),
|
||||
_filePath(new FileSelection()),
|
||||
_matchText(new ResizingPlainTextEdit(this)),
|
||||
_matchText(new VariableTextEdit(this)),
|
||||
_regex(new RegexConfigWidget(parent)),
|
||||
_checkModificationDate(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.fileTab.checkfileContentTime"))),
|
||||
|
|
@ -281,7 +281,7 @@ void MacroConditionFileEdit::UpdateEntryData()
|
|||
_fileTypes->setCurrentIndex(static_cast<int>(_entryData->_fileType));
|
||||
_conditions->setCurrentIndex(static_cast<int>(_entryData->_condition));
|
||||
_filePath->SetPath(QString::fromStdString(_entryData->_file));
|
||||
_matchText->setPlainText(QString::fromStdString(_entryData->_text));
|
||||
_matchText->setPlainText(_entryData->_text);
|
||||
_regex->SetRegexConfig(_entryData->_regex);
|
||||
_checkModificationDate->setChecked(_entryData->_useTime);
|
||||
_checkFileContent->setChecked(_entryData->_onlyMatchIfChanged);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "file-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
|
|
@ -36,7 +36,8 @@ public:
|
|||
};
|
||||
|
||||
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
std::string _text = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
VariableResolvingString _text =
|
||||
obs_module_text("AdvSceneSwitcher.enterText");
|
||||
FileType _fileType = FileType::LOCAL;
|
||||
ConditionType _condition = ConditionType::MATCH;
|
||||
RegexConfig _regex;
|
||||
|
|
@ -89,7 +90,7 @@ protected:
|
|||
QComboBox *_fileTypes;
|
||||
QComboBox *_conditions;
|
||||
FileSelection *_filePath;
|
||||
ResizingPlainTextEdit *_matchText;
|
||||
VariableTextEdit *_matchText;
|
||||
RegexConfigWidget *_regex;
|
||||
QCheckBox *_checkModificationDate;
|
||||
QCheckBox *_checkFileContent;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ bool MacroConditionFilter::Save(obs_data_t *obj) const
|
|||
obs_data_set_string(obj, "source", GetWeakSourceName(_source).c_str());
|
||||
obs_data_set_string(obj, "filter", GetWeakSourceName(_filter).c_str());
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
||||
obs_data_set_string(obj, "settings", _settings.c_str());
|
||||
_settings.Save(obj, "settings");
|
||||
_regex.Save(obj);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ bool MacroConditionFilter::Load(obs_data_t *obj)
|
|||
_filter = GetWeakFilterByQString(_source, filterName);
|
||||
_condition = static_cast<FilterCondition>(
|
||||
obs_data_get_int(obj, "condition"));
|
||||
_settings = obs_data_get_string(obj, "settings");
|
||||
_settings.Load(obj, "settings");
|
||||
_regex.Load(obj);
|
||||
// TOOD: remove in future version
|
||||
if (obs_data_has_user_value(obj, "regex")) {
|
||||
|
|
@ -103,7 +103,7 @@ MacroConditionFilterEdit::MacroConditionFilterEdit(
|
|||
_conditions(new QComboBox()),
|
||||
_getSettings(new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.filter.getSettings"))),
|
||||
_settings(new ResizingPlainTextEdit(this)),
|
||||
_settings(new VariableTextEdit(this)),
|
||||
_regex(new RegexConfigWidget(parent))
|
||||
{
|
||||
_filters->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
|
|
@ -249,7 +249,7 @@ void MacroConditionFilterEdit::UpdateEntryData()
|
|||
_filters->setCurrentText(
|
||||
GetWeakSourceName(_entryData->_filter).c_str());
|
||||
_conditions->setCurrentIndex(static_cast<int>(_entryData->_condition));
|
||||
_settings->setPlainText(QString::fromStdString(_entryData->_settings));
|
||||
_settings->setPlainText(_entryData->_settings);
|
||||
_regex->SetRegexConfig(_entryData->_regex);
|
||||
SetSettingsSelectionVisible(_entryData->_condition ==
|
||||
FilterCondition::SETTINGS);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
OBSWeakSource _source;
|
||||
OBSWeakSource _filter;
|
||||
FilterCondition _condition = FilterCondition::ENABLED;
|
||||
std::string _settings = "";
|
||||
VariableResolvingString _settings = "";
|
||||
RegexConfig _regex;
|
||||
|
||||
private:
|
||||
|
|
@ -68,7 +68,7 @@ protected:
|
|||
QComboBox *_filters;
|
||||
QComboBox *_conditions;
|
||||
QPushButton *_getSettings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
VariableTextEdit *_settings;
|
||||
RegexConfigWidget *_regex;
|
||||
|
||||
std::shared_ptr<MacroConditionFilter> _entryData;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ bool MacroConditionSceneTransform::Save(obs_data_t *obj) const
|
|||
MacroCondition::Save(obj);
|
||||
_scene.Save(obj);
|
||||
_source.Save(obj);
|
||||
obs_data_set_string(obj, "settings", _settings.c_str());
|
||||
_settings.Save(obj, "settings");
|
||||
_regex.Save(obj);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ bool MacroConditionSceneTransform::Load(obs_data_t *obj)
|
|||
MacroCondition::Load(obj);
|
||||
_scene.Load(obj);
|
||||
_source.Load(obj);
|
||||
_settings = obs_data_get_string(obj, "settings");
|
||||
_settings.Load(obj, "settings");
|
||||
_regex.Load(obj);
|
||||
// TOOD: remove in future version
|
||||
if (obs_data_has_user_value(obj, "regex")) {
|
||||
|
|
@ -77,7 +77,7 @@ MacroConditionSceneTransformEdit::MacroConditionSceneTransformEdit(
|
|||
parent, true, SceneItemSelectionWidget::Placeholder::ANY)),
|
||||
_getSettings(new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.sceneTransform.getTransform"))),
|
||||
_settings(new ResizingPlainTextEdit(this)),
|
||||
_settings(new VariableTextEdit(this)),
|
||||
_regex(new RegexConfigWidget(parent))
|
||||
{
|
||||
QWidget::connect(_scenes, SIGNAL(SceneChanged(const SceneSelection &)),
|
||||
|
|
@ -136,7 +136,7 @@ void MacroConditionSceneTransformEdit::UpdateEntryData()
|
|||
_scenes->SetScene(_entryData->_scene);
|
||||
_sources->SetSceneItem(_entryData->_source);
|
||||
_regex->SetRegexConfig(_entryData->_regex);
|
||||
_settings->setPlainText(QString::fromStdString(_entryData->_settings));
|
||||
_settings->setPlainText(_entryData->_settings);
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "macro.hpp"
|
||||
#include "scene-selection.hpp"
|
||||
#include "scene-item-selection.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
|
@ -24,7 +24,7 @@ public:
|
|||
SceneSelection _scene;
|
||||
SceneItemSelection _source;
|
||||
RegexConfig _regex;
|
||||
std::string _settings = "";
|
||||
VariableResolvingString _settings = "";
|
||||
|
||||
private:
|
||||
static bool _registered;
|
||||
|
|
@ -62,7 +62,7 @@ protected:
|
|||
SceneSelectionWidget *_scenes;
|
||||
SceneItemSelectionWidget *_sources;
|
||||
QPushButton *_getSettings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
VariableTextEdit *_settings;
|
||||
RegexConfigWidget *_regex;
|
||||
|
||||
std::shared_ptr<MacroConditionSceneTransform> _entryData;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ bool MacroConditionSource::Save(obs_data_t *obj) const
|
|||
MacroCondition::Save(obj);
|
||||
obs_data_set_string(obj, "source", GetWeakSourceName(_source).c_str());
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
||||
obs_data_set_string(obj, "settings", _settings.c_str());
|
||||
_settings.Save(obj, "settings");
|
||||
_regex.Save(obj);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ bool MacroConditionSource::Load(obs_data_t *obj)
|
|||
_source = GetWeakSourceByName(sourceName);
|
||||
_condition = static_cast<SourceCondition>(
|
||||
obs_data_get_int(obj, "condition"));
|
||||
_settings = obs_data_get_string(obj, "settings");
|
||||
_settings.Load(obj, "settings");
|
||||
_regex.Load(obj);
|
||||
// TOOD: remove in future version
|
||||
if (obs_data_has_user_value(obj, "regex")) {
|
||||
|
|
@ -96,7 +96,7 @@ MacroConditionSourceEdit::MacroConditionSourceEdit(
|
|||
_conditions(new QComboBox()),
|
||||
_getSettings(new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.filter.getSettings"))),
|
||||
_settings(new ResizingPlainTextEdit(this)),
|
||||
_settings(new VariableTextEdit(this)),
|
||||
_regex(new RegexConfigWidget(parent))
|
||||
{
|
||||
populateConditionSelection(_conditions);
|
||||
|
|
@ -221,7 +221,7 @@ void MacroConditionSourceEdit::UpdateEntryData()
|
|||
_sources->setCurrentText(
|
||||
GetWeakSourceName(_entryData->_source).c_str());
|
||||
_conditions->setCurrentIndex(static_cast<int>(_entryData->_condition));
|
||||
_settings->setPlainText(QString::fromStdString(_entryData->_settings));
|
||||
_settings->setPlainText(_entryData->_settings);
|
||||
_regex->SetRegexConfig(_entryData->_regex);
|
||||
SetSettingsSelectionVisible(_entryData->_condition ==
|
||||
SourceCondition::SETTINGS);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
OBSWeakSource _source = nullptr;
|
||||
SourceCondition _condition = SourceCondition::ACTIVE;
|
||||
std::string _settings = "";
|
||||
VariableResolvingString _settings = "";
|
||||
RegexConfig _regex;
|
||||
|
||||
private:
|
||||
|
|
@ -65,7 +65,7 @@ protected:
|
|||
QComboBox *_sources;
|
||||
QComboBox *_conditions;
|
||||
QPushButton *_getSettings;
|
||||
ResizingPlainTextEdit *_settings;
|
||||
VariableTextEdit *_settings;
|
||||
RegexConfigWidget *_regex;
|
||||
|
||||
std::shared_ptr<MacroConditionSource> _entryData;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ bool MacroConditionWebsocket::CheckCondition()
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
if (msg == _message) {
|
||||
if (msg == std::string(_message)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ bool MacroConditionWebsocket::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroCondition::Save(obj);
|
||||
obs_data_set_int(obj, "type", static_cast<int>(_type));
|
||||
obs_data_set_string(obj, "message", _message.c_str());
|
||||
_message.Save(obj, "message");
|
||||
_regex.Save(obj);
|
||||
obs_data_set_string(obj, "connection", _connection.c_str());
|
||||
return true;
|
||||
|
|
@ -81,7 +81,7 @@ bool MacroConditionWebsocket::Load(obs_data_t *obj)
|
|||
{
|
||||
MacroCondition::Load(obj);
|
||||
_type = static_cast<Type>(obs_data_get_int(obj, "type"));
|
||||
_message = obs_data_get_string(obj, "message");
|
||||
_message.Load(obj, "message");
|
||||
_regex.Load(obj);
|
||||
// TOOD: remove in future version
|
||||
if (obs_data_has_user_value(obj, "useRegex")) {
|
||||
|
|
@ -111,7 +111,7 @@ MacroConditionWebsocketEdit::MacroConditionWebsocketEdit(
|
|||
QWidget *parent, std::shared_ptr<MacroConditionWebsocket> entryData)
|
||||
: QWidget(parent),
|
||||
_conditions(new QComboBox(this)),
|
||||
_message(new ResizingPlainTextEdit(this)),
|
||||
_message(new VariableTextEdit(this)),
|
||||
_regex(new RegexConfigWidget(parent)),
|
||||
_connection(new ConnectionSelection(this)),
|
||||
_editLayout(new QHBoxLayout())
|
||||
|
|
@ -182,7 +182,7 @@ void MacroConditionWebsocketEdit::UpdateEntryData()
|
|||
}
|
||||
|
||||
_conditions->setCurrentIndex(static_cast<int>(_entryData->_type));
|
||||
_message->setPlainText(QString::fromStdString(_entryData->_message));
|
||||
_message->setPlainText(_entryData->_message);
|
||||
_regex->SetRegexConfig(_entryData->_regex);
|
||||
_connection->SetConnection(_entryData->_connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "connection-manager.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
|
@ -25,7 +25,8 @@ public:
|
|||
};
|
||||
|
||||
Type _type = Type::REQUEST;
|
||||
std::string _message = obs_module_text("AdvSceneSwitcher.enterText");
|
||||
VariableResolvingString _message =
|
||||
obs_module_text("AdvSceneSwitcher.enterText");
|
||||
RegexConfig _regex;
|
||||
std::string _connection;
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ private:
|
|||
void SetupEventEdit();
|
||||
|
||||
QComboBox *_conditions;
|
||||
ResizingPlainTextEdit *_message;
|
||||
VariableTextEdit *_message;
|
||||
RegexConfigWidget *_regex;
|
||||
ConnectionSelection *_connection;
|
||||
QHBoxLayout *_editLayout;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user