mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-16 06:08:12 -05:00
Enable use of multi-line values for variables
This commit is contained in:
@@ -114,7 +114,7 @@ MacroActionVariableEdit::MacroActionVariableEdit(
|
||||
_variables(new VariableSelection(this)),
|
||||
_variables2(new VariableSelection(this)),
|
||||
_actions(new QComboBox()),
|
||||
_strValue(new QLineEdit()),
|
||||
_strValue(new ResizingPlainTextEdit(this, 5, 1, 1)),
|
||||
_numValue(new QDoubleSpinBox())
|
||||
{
|
||||
_numValue->setMinimum(-9999999999);
|
||||
@@ -127,7 +127,7 @@ MacroActionVariableEdit::MacroActionVariableEdit(
|
||||
this, SLOT(Variable2Changed(const QString &)));
|
||||
QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(ActionChanged(int)));
|
||||
QWidget::connect(_strValue, SIGNAL(editingFinished()), this,
|
||||
QWidget::connect(_strValue, SIGNAL(textChanged()), this,
|
||||
SLOT(StrValueChanged()));
|
||||
QWidget::connect(_numValue, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(NumValueChanged(double)));
|
||||
@@ -157,7 +157,7 @@ void MacroActionVariableEdit::UpdateEntryData()
|
||||
_variables->SetVariable(_entryData->_variableName);
|
||||
_variables2->SetVariable(_entryData->_variable2Name);
|
||||
_actions->setCurrentIndex(static_cast<int>(_entryData->_type));
|
||||
_strValue->setText(QString::fromStdString(_entryData->_strValue));
|
||||
_strValue->setPlainText(QString::fromStdString(_entryData->_strValue));
|
||||
_numValue->setValue(_entryData->_numValue);
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
@@ -200,7 +200,8 @@ void MacroActionVariableEdit::StrValueChanged()
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_strValue = _strValue->text().toStdString();
|
||||
_entryData->_strValue = _strValue->toPlainText().toStdString();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionVariableEdit::NumValueChanged(double val)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
class MacroActionVariable : public MacroAction {
|
||||
@@ -65,7 +66,7 @@ protected:
|
||||
VariableSelection *_variables;
|
||||
VariableSelection *_variables2;
|
||||
QComboBox *_actions;
|
||||
QLineEdit *_strValue;
|
||||
ResizingPlainTextEdit *_strValue;
|
||||
QDoubleSpinBox *_numValue;
|
||||
std::shared_ptr<MacroActionVariable> _entryData;
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ MacroConditionVariableEdit::MacroConditionVariableEdit(
|
||||
: QWidget(parent),
|
||||
_variables(new VariableSelection(this)),
|
||||
_conditions(new QComboBox()),
|
||||
_strValue(new QLineEdit()),
|
||||
_strValue(new ResizingPlainTextEdit(this, 5, 1, 1)),
|
||||
_numValue(new QDoubleSpinBox()),
|
||||
_regex(new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.condition.variable.regex")))
|
||||
@@ -147,7 +147,7 @@ MacroConditionVariableEdit::MacroConditionVariableEdit(
|
||||
this, SLOT(VariableChanged(const QString &)));
|
||||
QWidget::connect(_conditions, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(ConditionChanged(int)));
|
||||
QWidget::connect(_strValue, SIGNAL(editingFinished()), this,
|
||||
QWidget::connect(_strValue, SIGNAL(textChanged()), this,
|
||||
SLOT(StrValueChanged()));
|
||||
QWidget::connect(_numValue, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(NumValueChanged(double)));
|
||||
@@ -182,7 +182,7 @@ void MacroConditionVariableEdit::UpdateEntryData()
|
||||
|
||||
_variables->SetVariable(_entryData->_variableName);
|
||||
_conditions->setCurrentIndex(static_cast<int>(_entryData->_type));
|
||||
_strValue->setText(QString::fromStdString(_entryData->_strValue));
|
||||
_strValue->setPlainText(QString::fromStdString(_entryData->_strValue));
|
||||
_numValue->setValue(_entryData->_numValue);
|
||||
_regex->setChecked(_entryData->_regex);
|
||||
SetWidgetVisibility();
|
||||
@@ -216,7 +216,8 @@ void MacroConditionVariableEdit::StrValueChanged()
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_strValue = _strValue->text().toStdString();
|
||||
_entryData->_strValue = _strValue->toPlainText().toStdString();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroConditionVariableEdit::NumValueChanged(double val)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "macro.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "variable.hpp"
|
||||
|
||||
#include <QWidget>
|
||||
@@ -76,7 +77,7 @@ signals:
|
||||
protected:
|
||||
VariableSelection *_variables;
|
||||
QComboBox *_conditions;
|
||||
QLineEdit *_strValue;
|
||||
ResizingPlainTextEdit *_strValue;
|
||||
QDoubleSpinBox *_numValue;
|
||||
QCheckBox *_regex;
|
||||
std::shared_ptr<MacroConditionVariable> _entryData;
|
||||
|
||||
@@ -217,15 +217,16 @@ VariableSettingsDialog::VariableSettingsDialog(QWidget *parent,
|
||||
: ItemSettingsDialog(settings, switcher->variables,
|
||||
"AdvSceneSwitcher.variable.select",
|
||||
"AdvSceneSwitcher.variable.add", parent),
|
||||
_value(new QLineEdit()),
|
||||
_defaultValue(new QLineEdit()),
|
||||
_value(new ResizingPlainTextEdit(this)),
|
||||
_defaultValue(new ResizingPlainTextEdit(this)),
|
||||
_save(new QComboBox())
|
||||
{
|
||||
QWidget::connect(_save, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SaveActionChanged(int)));
|
||||
|
||||
_value->setText(QString::fromStdString(settings._value));
|
||||
_defaultValue->setText(QString::fromStdString(settings._defaultValue));
|
||||
_value->setPlainText(QString::fromStdString(settings._value));
|
||||
_defaultValue->setPlainText(
|
||||
QString::fromStdString(settings._defaultValue));
|
||||
populateSaveActionSelection(_save);
|
||||
_save->setCurrentIndex(static_cast<int>(settings._saveAction));
|
||||
|
||||
@@ -276,8 +277,9 @@ bool VariableSettingsDialog::AskForSettings(QWidget *parent, Variable &settings)
|
||||
}
|
||||
|
||||
settings._name = dialog._name->text().toStdString();
|
||||
settings._value = dialog._value->text().toStdString();
|
||||
settings._defaultValue = dialog._defaultValue->text().toStdString();
|
||||
settings._value = dialog._value->toPlainText().toStdString();
|
||||
settings._defaultValue =
|
||||
dialog._defaultValue->toPlainText().toStdString();
|
||||
settings._saveAction =
|
||||
static_cast<Variable::SaveAction>(dialog._save->currentIndex());
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "item-selection-helpers.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <QStringList>
|
||||
@@ -82,8 +83,8 @@ private slots:
|
||||
void SaveActionChanged(int);
|
||||
|
||||
private:
|
||||
QLineEdit *_value;
|
||||
QLineEdit *_defaultValue;
|
||||
ResizingPlainTextEdit *_value;
|
||||
ResizingPlainTextEdit *_defaultValue;
|
||||
QComboBox *_save;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user