mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-21 12:03:43 -05:00
Show "Macro Schedule" tab when date / timer condition is created
This commit is contained in:
parent
4cedb29123
commit
49a681bcfe
|
|
@ -1,5 +1,6 @@
|
|||
#include "macro-condition-edit.hpp"
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "macro-signals.hpp"
|
||||
#include "macro-settings.hpp"
|
||||
#include "macro.hpp"
|
||||
#include "path-helpers.hpp"
|
||||
|
|
@ -274,6 +275,9 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
|||
SetupVarMappings((*_entryData).get());
|
||||
_dur->setVisible(MacroConditionFactory::UsesDurationModifier(id));
|
||||
SetFocusPolicyOfWidgets();
|
||||
|
||||
emit MacroSignalManager::Instance()->ConditionTypeCreated(
|
||||
QString::fromStdString(id));
|
||||
}
|
||||
|
||||
void MacroConditionEdit::DurationChanged(const Duration &seconds)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ signals:
|
|||
void Remove(const QString &);
|
||||
void SegmentOrderChanged();
|
||||
void HighlightChanged(bool value);
|
||||
void ConditionTypeCreated(const QString &typeId);
|
||||
|
||||
private:
|
||||
MacroSignalManager(QObject *parent = nullptr);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "calendar/calendar-event.hpp"
|
||||
#include "macro-schedule-entry-dialog.hpp"
|
||||
|
||||
#include "macro-condition.hpp"
|
||||
#include "macro-helpers.hpp"
|
||||
#include "macro-signals.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
|
|
@ -40,22 +41,42 @@ static bool enoughMacros()
|
|||
return (int)GetAllMacros().size() >= MACRO_COUNT_THRESHOLD;
|
||||
}
|
||||
|
||||
static const QStringList schedulingConditionIds = {"date", "timer"};
|
||||
|
||||
static bool anyMacroHasSchedulingCondition()
|
||||
{
|
||||
for (const auto ¯o : GetAllMacros()) {
|
||||
auto conditions = GetMacroConditions(macro.get());
|
||||
if (!conditions) {
|
||||
continue;
|
||||
}
|
||||
for (const auto &condition : *conditions) {
|
||||
if (schedulingConditionIds.contains(
|
||||
QString::fromStdString(
|
||||
condition->GetId()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void setupTab(QTabWidget *tab)
|
||||
{
|
||||
if (!GetScheduleEntries().empty()) {
|
||||
if (!GetScheduleEntries().empty() || anyMacroHasSchedulingCondition()) {
|
||||
setTabVisible(tab, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!enoughMacros()) {
|
||||
} else {
|
||||
setTabVisible(tab, false);
|
||||
}
|
||||
|
||||
QWidget::connect(MacroSignalManager::Instance(),
|
||||
&MacroSignalManager::Add, tab, [tab](const QString &) {
|
||||
if (enoughMacros()) {
|
||||
setTabVisible(tab, true);
|
||||
&MacroSignalManager::ConditionTypeCreated, tab,
|
||||
[tab](const QString &typeId) {
|
||||
if (!schedulingConditionIds.contains(typeId)) {
|
||||
return;
|
||||
}
|
||||
setTabVisible(tab, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user