* Add variable support to process condition
* Display unresolved variable value in Window action
* Add tooltips to indicate that variables are supported
This commit is contained in:
WarmUpTill 2025-05-26 19:37:35 +02:00 committed by WarmUpTill
parent c05dd40c4c
commit 406e3c1855
4 changed files with 35 additions and 87 deletions

View File

@ -169,6 +169,9 @@ MacroActionWindowEdit::MacroActionWindowEdit(
{
populateActionSelection(_actions);
_windows->setToolTip(
obs_module_text("AdvSceneSwitcher.tooltip.availableVariables"));
auto focusLimitation = new QLabel(obs_module_text(
"AdvSceneSwitcher.action.window.type.setFocusWindow.limitation"));
_infoLayout->addWidget(focusLimitation);
@ -207,19 +210,17 @@ void MacroActionWindowEdit::UpdateEntryData()
if (!_entryData) {
return;
}
_actions->setCurrentIndex(static_cast<int>(_entryData->_action));
_windows->setCurrentText(QString::fromStdString(_entryData->_window));
_windows->setCurrentText(
QString::fromStdString(_entryData->_window.UnresolvedValue()));
_regex->SetRegexConfig(_entryData->_regex);
SetWidgetVisibility();
}
void MacroActionWindowEdit::WindowChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_window = text.toStdString();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
@ -227,11 +228,7 @@ void MacroActionWindowEdit::WindowChanged(const QString &text)
void MacroActionWindowEdit::RegexChanged(const RegexConfig &regex)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_regex = regex;
adjustSize();
updateGeometry();
@ -248,11 +245,7 @@ void MacroActionWindowEdit::SetWidgetVisibility()
void MacroActionWindowEdit::ActionChanged(int value)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_action = static_cast<MacroActionWindow::Action>(value);
SetWidgetVisibility();
}

View File

@ -60,7 +60,7 @@ bool MacroConditionProcess::CheckCondition()
bool MacroConditionProcess::Save(obs_data_t *obj) const
{
MacroCondition::Save(obj);
obs_data_set_string(obj, "process", _process.c_str());
_process.Save(obj, "process");
obs_data_set_bool(obj, "focus", _checkFocus);
_regex.Save(obj);
obs_data_set_int(obj, "version", 1);
@ -70,7 +70,7 @@ bool MacroConditionProcess::Save(obs_data_t *obj) const
bool MacroConditionProcess::Load(obs_data_t *obj)
{
MacroCondition::Load(obj);
_process = obs_data_get_string(obj, "process");
_process.Load(obj, "process");
_checkFocus = obs_data_get_bool(obj, "focus");
// Fall back to partial match regex as default for old version
if (!obs_data_has_user_value(obj, "version")) {
@ -104,6 +104,8 @@ MacroConditionProcessEdit::MacroConditionProcessEdit(
{
_processSelection->setEditable(true);
_processSelection->setMaxVisibleItems(20);
_processSelection->setToolTip(
obs_module_text("AdvSceneSwitcher.tooltip.availableVariables"));
QWidget::connect(_processSelection,
SIGNAL(currentTextChanged(const QString &)), this,
@ -118,7 +120,7 @@ MacroConditionProcessEdit::MacroConditionProcessEdit(
PopulateProcessSelection(_processSelection);
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
const std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{processes}}", _processSelection},
{"{{regex}}", _regex},
{"{{focused}}", _focused},
@ -146,11 +148,7 @@ MacroConditionProcessEdit::MacroConditionProcessEdit(
void MacroConditionProcessEdit::ProcessChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_process = text.toStdString();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
@ -167,11 +165,7 @@ void MacroConditionProcessEdit::showEvent(QShowEvent *event)
void MacroConditionProcessEdit::RegexChanged(const RegexConfig &conf)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_regex = conf;
adjustSize();
updateGeometry();
@ -179,11 +173,7 @@ void MacroConditionProcessEdit::RegexChanged(const RegexConfig &conf)
void MacroConditionProcessEdit::FocusChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_checkFocus = state;
SetWidgetVisibility();
}
@ -202,6 +192,7 @@ void MacroConditionProcessEdit::SetWidgetVisibility()
}
SetLayoutVisible(_focusLayout, _entryData->_checkFocus);
adjustSize();
updateGeometry();
}
void MacroConditionProcessEdit::UpdateEntryData()
@ -210,7 +201,8 @@ void MacroConditionProcessEdit::UpdateEntryData()
return;
}
_processSelection->setCurrentText(_entryData->_process.c_str());
_processSelection->setCurrentText(
_entryData->_process.UnresolvedValue().c_str());
_regex->SetRegexConfig(_entryData->_regex);
_focused->setChecked(_entryData->_checkFocus);
SetWidgetVisibility();

View File

@ -1,8 +1,8 @@
#pragma once
#include "macro-condition-edit.hpp"
#include "regex-config.hpp"
#include "variable-string.hpp"
#include <QComboBox>
#include <QCheckBox>
namespace advss {
@ -20,7 +20,7 @@ public:
return std::make_shared<MacroConditionProcess>(m);
}
std::string _process;
StringVariable _process;
bool _checkFocus = true;
RegexConfig _regex = RegexConfig::PartialMatchRegexConfig();

View File

@ -210,6 +210,9 @@ MacroConditionWindowEdit::MacroConditionWindowEdit(
_text->setToolTip(obs_module_text(
"AdvSceneSwitcher.condition.window.entry.text.note"));
_windowSelection->setToolTip(
obs_module_text("AdvSceneSwitcher.tooltip.availableVariables"));
QWidget::connect(_windowSelection,
SIGNAL(currentTextChanged(const QString &)), this,
SLOT(WindowChanged(const QString &)));
@ -314,11 +317,7 @@ MacroConditionWindowEdit::MacroConditionWindowEdit(
void MacroConditionWindowEdit::WindowChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_window = text.toStdString();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));
@ -326,11 +325,7 @@ void MacroConditionWindowEdit::WindowChanged(const QString &text)
void MacroConditionWindowEdit::WindowRegexChanged(const RegexConfig &conf)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_windowRegex = conf;
adjustSize();
updateGeometry();
@ -338,11 +333,7 @@ void MacroConditionWindowEdit::WindowRegexChanged(const RegexConfig &conf)
void MacroConditionWindowEdit::CheckTitleChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
const QSignalBlocker b1(_windowSelection);
const QSignalBlocker b2(_windowRegex);
if (!state) {
@ -357,22 +348,14 @@ void MacroConditionWindowEdit::CheckTitleChanged(int state)
void MacroConditionWindowEdit::CheckTextChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_checkText = state;
SetWidgetVisibility();
}
void MacroConditionWindowEdit::WindowTextChanged()
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_text = _text->toPlainText().toStdString();
adjustSize();
updateGeometry();
@ -380,11 +363,7 @@ void MacroConditionWindowEdit::WindowTextChanged()
void MacroConditionWindowEdit::TextRegexChanged(const RegexConfig &conf)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_textRegex = conf;
adjustSize();
updateGeometry();
@ -392,42 +371,26 @@ void MacroConditionWindowEdit::TextRegexChanged(const RegexConfig &conf)
void MacroConditionWindowEdit::FullscreenChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_fullscreen = state;
}
void MacroConditionWindowEdit::MaximizedChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_maximized = state;
}
void MacroConditionWindowEdit::FocusedChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_focus = state;
SetWidgetVisibility();
}
void MacroConditionWindowEdit::WindowFocusChanged(int state)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_windowFocusChanged = state;
SetWidgetVisibility();
}