mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Fix nested macro property selections not being saved
This commit is contained in:
parent
ae571583fc
commit
a1702dc798
|
|
@ -125,7 +125,6 @@ signals:
|
|||
void MacroRemoved(const QString &name);
|
||||
void MacroRenamed(const QString &oldName, const QString &newName);
|
||||
void MacroSegmentOrderChanged();
|
||||
void SegmentTempVarsChanged(MacroSegment *);
|
||||
void HighlightMacrosChanged(bool value);
|
||||
|
||||
void ConnectionAdded(const QString &);
|
||||
|
|
|
|||
|
|
@ -236,6 +236,11 @@ void MacroEdit::SetMacro(const std::shared_ptr<Macro> ¯o)
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Macro> MacroEdit::GetMacro() const
|
||||
{
|
||||
return _currentMacro;
|
||||
}
|
||||
|
||||
void MacroEdit::ClearSegmentWidgetCacheFor(Macro *macro) const
|
||||
{
|
||||
ui->conditionsList->ClearWidgetsFromCacheFor(macro);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class MacroEdit : public QWidget {
|
|||
public:
|
||||
MacroEdit(QWidget *parent, QStringList helpMsg = {});
|
||||
void SetMacro(const std::shared_ptr<Macro> &);
|
||||
std::shared_ptr<Macro> GetMacro() const;
|
||||
void ClearSegmentWidgetCacheFor(Macro *) const;
|
||||
void SetControlsDisabled(bool disable) const;
|
||||
void HighlightAction(int idx, QColor color = QColor(Qt::green)) const;
|
||||
|
|
@ -108,7 +109,6 @@ signals:
|
|||
void MacroRemoved(const QString &name);
|
||||
void MacroRenamed(const QString &oldName, const QString &newName);
|
||||
void MacroSegmentOrderChanged();
|
||||
void SegmentTempVarsChanged(MacroSegment *);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "temp-variable.hpp"
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "macro.hpp"
|
||||
#include "macro-edit.hpp"
|
||||
#include "macro-segment.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
|
|
@ -247,14 +247,30 @@ bool TempVariableRef::operator==(const TempVariableRef &other) const
|
|||
return segment == other._segment.lock();
|
||||
}
|
||||
|
||||
static MacroEdit *findMacroEditParent(QWidget *widget)
|
||||
{
|
||||
if (!widget) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto macroEdit = qobject_cast<MacroEdit *>(widget);
|
||||
if (macroEdit) {
|
||||
return macroEdit;
|
||||
}
|
||||
|
||||
return findMacroEditParent(widget->parentWidget());
|
||||
}
|
||||
|
||||
TempVariableSelection::TempVariableSelection(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
_selection(new FilterComboBox(
|
||||
this, obs_module_text("AdvSceneSwitcher.tempVar.select"))),
|
||||
_info(new AutoUpdateTooltipLabel(this, [this]() {
|
||||
return SetupInfoLabel();
|
||||
}))
|
||||
_info(new AutoUpdateTooltipLabel(
|
||||
this, [this]() { return SetupInfoLabel(); })),
|
||||
_macroEdit(findMacroEditParent(parent))
|
||||
{
|
||||
assert(_macroEdit);
|
||||
|
||||
QString path = GetThemeTypeName() == "Light"
|
||||
? ":/res/images/help.svg"
|
||||
: ":/res/images/help_light.svg";
|
||||
|
|
@ -272,10 +288,9 @@ TempVariableSelection::TempVariableSelection(QWidget *parent)
|
|||
SLOT(SelectionIdxChanged(int)));
|
||||
QWidget::connect(_selection, SIGNAL(highlighted(int)), this,
|
||||
SLOT(HighlightChanged(int)));
|
||||
QWidget::connect(GetSettingsWindow(),
|
||||
SIGNAL(MacroSegmentOrderChanged()), this,
|
||||
QWidget::connect(_macroEdit, SIGNAL(MacroSegmentOrderChanged()), this,
|
||||
SLOT(MacroSegmentsChanged()));
|
||||
QWidget::connect(GetSettingsWindow(),
|
||||
QWidget::connect(TempVarSignalManager::Instance(),
|
||||
SIGNAL(SegmentTempVarsChanged(MacroSegment *)), this,
|
||||
SLOT(SegmentTempVarsChanged(MacroSegment *)));
|
||||
|
||||
|
|
@ -335,13 +350,7 @@ void TempVariableSelection::HighlightChanged(int idx)
|
|||
|
||||
void TempVariableSelection::PopulateSelection()
|
||||
{
|
||||
auto advssWindow =
|
||||
qobject_cast<AdvSceneSwitcher *>(GetSettingsWindow());
|
||||
if (!advssWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto macro = advssWindow->GetSelectedMacro();
|
||||
auto macro = _macroEdit->GetMacro();
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -369,12 +378,6 @@ void TempVariableSelection::PopulateSelection()
|
|||
|
||||
void TempVariableSelection::HighlightSelection(const TempVariableRef &var)
|
||||
{
|
||||
auto advssWindow =
|
||||
qobject_cast<AdvSceneSwitcher *>(GetSettingsWindow());
|
||||
if (!advssWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto color = GetThemeTypeName() == "Dark" ? Qt::white : Qt::blue;
|
||||
|
||||
auto type = var.GetType();
|
||||
|
|
@ -382,13 +385,13 @@ void TempVariableSelection::HighlightSelection(const TempVariableRef &var)
|
|||
case TempVariableRef::SegmentType::NONE:
|
||||
return;
|
||||
case TempVariableRef::SegmentType::CONDITION:
|
||||
advssWindow->HighlightCondition(var.GetIdx(), color);
|
||||
_macroEdit->HighlightCondition(var.GetIdx(), color);
|
||||
return;
|
||||
case TempVariableRef::SegmentType::ACTION:
|
||||
advssWindow->HighlightAction(var.GetIdx(), color);
|
||||
_macroEdit->HighlightAction(var.GetIdx(), color);
|
||||
return;
|
||||
case TempVariableRef::SegmentType::ELSEACTION:
|
||||
advssWindow->HighlightElseAction(var.GetIdx(), color);
|
||||
_macroEdit->HighlightElseAction(var.GetIdx(), color);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -399,14 +402,7 @@ QString TempVariableSelection::SetupInfoLabel()
|
|||
{
|
||||
auto currentSelection = _selection->itemData(_selection->currentIndex())
|
||||
.value<TempVariableRef>();
|
||||
auto advssWindow =
|
||||
qobject_cast<AdvSceneSwitcher *>(GetSettingsWindow());
|
||||
if (!advssWindow) {
|
||||
_info->setToolTip("");
|
||||
_info->hide();
|
||||
return "";
|
||||
}
|
||||
auto macro = advssWindow->GetSelectedMacro();
|
||||
auto macro = _macroEdit->GetMacro();
|
||||
if (!macro) {
|
||||
_info->setToolTip("");
|
||||
_info->hide();
|
||||
|
|
@ -453,15 +449,20 @@ MacroSegment *TempVariableSelection::GetSegment() const
|
|||
return segmentWidget->Data().get();
|
||||
}
|
||||
|
||||
TempVarSignalManager::TempVarSignalManager() : QObject() {}
|
||||
|
||||
TempVarSignalManager *TempVarSignalManager::Instance()
|
||||
{
|
||||
static TempVarSignalManager manager;
|
||||
return &manager;
|
||||
}
|
||||
|
||||
void NotifyUIAboutTempVarChange(MacroSegment *segment)
|
||||
{
|
||||
obs_queue_task(
|
||||
OBS_TASK_UI,
|
||||
[](void *segment) {
|
||||
if (!SettingsWindowIsOpened()) {
|
||||
return;
|
||||
}
|
||||
AdvSceneSwitcher::window->SegmentTempVarsChanged(
|
||||
TempVarSignalManager::Instance()->SegmentTempVarsChanged(
|
||||
(MacroSegment *)segment);
|
||||
},
|
||||
segment, false);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
namespace advss {
|
||||
|
||||
class Macro;
|
||||
class MacroEdit;
|
||||
class MacroSegment;
|
||||
class TempVariableRef;
|
||||
class TempVariableSelection;
|
||||
|
|
@ -102,6 +103,19 @@ private:
|
|||
|
||||
FilterComboBox *_selection;
|
||||
AutoUpdateTooltipLabel *_info;
|
||||
MacroEdit *_macroEdit;
|
||||
};
|
||||
|
||||
class TempVarSignalManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static TempVarSignalManager *Instance();
|
||||
|
||||
signals:
|
||||
void SegmentTempVarsChanged(MacroSegment *);
|
||||
|
||||
private:
|
||||
TempVarSignalManager();
|
||||
};
|
||||
|
||||
void NotifyUIAboutTempVarChange(MacroSegment *);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user