mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-24 06:48:24 -05:00
Add group support to MacroSelection
This commit is contained in:
parent
21c34356ed
commit
5d49e8825b
|
|
@ -93,33 +93,46 @@ bool MacroActionMacro::PerformAction()
|
|||
return true;
|
||||
}
|
||||
|
||||
switch (_action) {
|
||||
case Action::PAUSE:
|
||||
macro->SetPaused();
|
||||
break;
|
||||
case Action::UNPAUSE:
|
||||
macro->SetPaused(false);
|
||||
break;
|
||||
case Action::TOGGLE_PAUSE:
|
||||
macro->SetPaused(!macro->Paused());
|
||||
break;
|
||||
case Action::RESET_COUNTER:
|
||||
macro->ResetRunCount();
|
||||
break;
|
||||
case Action::RUN_ACTIONS:
|
||||
RunActions(macro.get());
|
||||
break;
|
||||
case Action::STOP:
|
||||
macro->Stop();
|
||||
break;
|
||||
case Action::DISABLE_ACTION:
|
||||
case Action::ENABLE_ACTION:
|
||||
case Action::TOGGLE_ACTION:
|
||||
AdjustActionState(macro.get());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
const auto performActionForMacro = [this](Macro *macro) {
|
||||
switch (_action) {
|
||||
case Action::PAUSE:
|
||||
macro->SetPaused();
|
||||
break;
|
||||
case Action::UNPAUSE:
|
||||
macro->SetPaused(false);
|
||||
break;
|
||||
case Action::TOGGLE_PAUSE:
|
||||
macro->SetPaused(!macro->Paused());
|
||||
break;
|
||||
case Action::RESET_COUNTER:
|
||||
macro->ResetRunCount();
|
||||
break;
|
||||
case Action::RUN_ACTIONS:
|
||||
RunActions(macro);
|
||||
break;
|
||||
case Action::STOP:
|
||||
macro->Stop();
|
||||
break;
|
||||
case Action::DISABLE_ACTION:
|
||||
case Action::ENABLE_ACTION:
|
||||
case Action::TOGGLE_ACTION:
|
||||
AdjustActionState(macro);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
if (!IsGroupMacro(macro.get())) {
|
||||
performActionForMacro(macro.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
auto macros = GetGroupMacroEntries(macro.get());
|
||||
for (const auto ¯o : macros) {
|
||||
performActionForMacro(macro.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -404,6 +417,7 @@ MacroActionMacroEdit::MacroActionMacroEdit(
|
|||
populateActionTypes(_actionTypes);
|
||||
|
||||
_conditionMacros->HideSelectedMacro();
|
||||
_conditionMacros->HideGroups();
|
||||
|
||||
QWidget::connect(_macros, SIGNAL(currentTextChanged(const QString &)),
|
||||
this, SLOT(MacroChanged(const QString &)));
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@ MacroConditionMacroEdit::MacroConditionMacroEdit(
|
|||
_actionIndex(new MacroSegmentSelection(
|
||||
this, MacroSegmentSelection::Type::ACTION))
|
||||
{
|
||||
_macros->HideGroups();
|
||||
_count->setMaximum(10000000);
|
||||
populateTypeSelection(_types);
|
||||
populateCounterConditionSelection(_counterConditions);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ MacroSelection::MacroSelection(QWidget *parent)
|
|||
obs_module_text("AdvSceneSwitcher.selectMacro"))
|
||||
{
|
||||
for (const auto &m : GetTopLevelMacros()) {
|
||||
if (m->IsGroup()) {
|
||||
continue;
|
||||
}
|
||||
addItem(QString::fromStdString(m->Name()));
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +63,22 @@ void MacroSelection::HideSelectedMacro()
|
|||
qobject_cast<QListView *>(view())->setRowHidden(idx, true);
|
||||
}
|
||||
|
||||
void MacroSelection::HideGroups()
|
||||
{
|
||||
for (const auto ¯o : GetTopLevelMacros()) {
|
||||
if (!macro->IsGroup()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int idx = findText(QString::fromStdString(macro->Name()));
|
||||
if (idx == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
qobject_cast<QListView *>(view())->setRowHidden(idx, true);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroSelection::ShowAllMacros()
|
||||
{
|
||||
auto v = qobject_cast<QListView *>(view());
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public:
|
|||
MacroSelection(QWidget *parent);
|
||||
void SetCurrentMacro(const MacroRef &);
|
||||
void HideSelectedMacro(); // Macro currently being edited
|
||||
void HideGroups();
|
||||
void ShowAllMacros();
|
||||
|
||||
private slots:
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ MacroActionSequenceEdit::MacroActionSequenceEdit(
|
|||
_resetIndex(new VariableSpinBox()),
|
||||
_layout(new QHBoxLayout())
|
||||
{
|
||||
_macros->HideGroups();
|
||||
populateActionSelection(_actions);
|
||||
|
||||
_resetIndex->setMinimum(1);
|
||||
|
|
|
|||
|
|
@ -31,15 +31,16 @@ bool MacroActionTimer::PerformAction()
|
|||
if (!macro) {
|
||||
return true;
|
||||
}
|
||||
auto conditions = *GetMacroConditions(macro.get());
|
||||
for (auto condition : conditions) {
|
||||
|
||||
const auto updateCondition = [this](MacroCondition *condition) {
|
||||
if (condition->GetId() != id) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
auto timerCondition =
|
||||
dynamic_cast<MacroConditionTimer *>(condition.get());
|
||||
dynamic_cast<MacroConditionTimer *>(condition);
|
||||
if (!timerCondition) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_actionType) {
|
||||
|
|
@ -59,6 +60,23 @@ bool MacroActionTimer::PerformAction()
|
|||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const auto updateMacro = [&](Macro *macro) {
|
||||
auto conditions = *GetMacroConditions(macro);
|
||||
for (auto condition : conditions) {
|
||||
updateCondition(condition.get());
|
||||
}
|
||||
};
|
||||
|
||||
if (!IsGroupMacro(macro.get())) {
|
||||
updateMacro(macro.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
auto macros = GetGroupMacroEntries(macro.get());
|
||||
for (const auto ¯o : macros) {
|
||||
updateMacro(macro.get());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -131,7 +149,7 @@ void MacroActionTimer::ResolveVariablesToFixedValues()
|
|||
_duration.ResolveVariables();
|
||||
}
|
||||
|
||||
static inline void populateTypeSelection(QComboBox *list)
|
||||
static void populateTypeSelection(QComboBox *list)
|
||||
{
|
||||
for (const auto &[_, name] : timerActions) {
|
||||
list->addItem(obs_module_text(name.c_str()));
|
||||
|
|
@ -140,12 +158,11 @@ static inline void populateTypeSelection(QComboBox *list)
|
|||
|
||||
MacroActionTimerEdit::MacroActionTimerEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionTimer> entryData)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
_macros(new MacroSelection(parent)),
|
||||
_duration(new DurationSelection(this)),
|
||||
_timerAction(new QComboBox(this))
|
||||
{
|
||||
_macros = new MacroSelection(parent);
|
||||
_duration = new DurationSelection();
|
||||
_timerAction = new QComboBox();
|
||||
|
||||
populateTypeSelection(_timerAction);
|
||||
|
||||
QWidget::connect(_macros, SIGNAL(currentTextChanged(const QString &)),
|
||||
|
|
@ -155,15 +172,13 @@ MacroActionTimerEdit::MacroActionTimerEdit(
|
|||
QWidget::connect(_timerAction, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(ActionTypeChanged(int)));
|
||||
|
||||
_mainLayout = new QHBoxLayout;
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||
{"{{macros}}", _macros},
|
||||
{"{{duration}}", _duration},
|
||||
{"{{timerAction}}", _timerAction},
|
||||
};
|
||||
auto layout = new QHBoxLayout;
|
||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.action.timer.entry"),
|
||||
_mainLayout, widgetPlaceholders);
|
||||
setLayout(_mainLayout);
|
||||
layout,
|
||||
{{"{{macros}}", _macros},
|
||||
{"{{duration}}", _duration},
|
||||
{"{{timerAction}}", _timerAction}});
|
||||
setLayout(layout);
|
||||
|
||||
_entryData = entryData;
|
||||
UpdateEntryData();
|
||||
|
|
|
|||
|
|
@ -58,16 +58,14 @@ private slots:
|
|||
signals:
|
||||
void HeaderInfoChanged(const QString &);
|
||||
|
||||
protected:
|
||||
private:
|
||||
void SetWidgetVisibility();
|
||||
|
||||
MacroSelection *_macros;
|
||||
DurationSelection *_duration;
|
||||
QComboBox *_timerAction;
|
||||
std::shared_ptr<MacroActionTimer> _entryData;
|
||||
|
||||
private:
|
||||
QHBoxLayout *_mainLayout;
|
||||
std::shared_ptr<MacroActionTimer> _entryData;
|
||||
bool _loading = true;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user