mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-20 00:05:41 -05:00
Add support for "None" transition type to scene item visibility action
This commit is contained in:
@@ -2546,6 +2546,7 @@ AdvSceneSwitcher.selectCurrentScene="Current Scene"
|
||||
AdvSceneSwitcher.selectPreviewScene="Preview Scene"
|
||||
AdvSceneSwitcher.selectAnyScene="Any Scene"
|
||||
AdvSceneSwitcher.currentTransition="Current Transition"
|
||||
AdvSceneSwitcher.noneTransition="None"
|
||||
AdvSceneSwitcher.anyTransition="Any Transition"
|
||||
AdvSceneSwitcher.selectTransition="--select transition--"
|
||||
AdvSceneSwitcher.selectWindow="--select window--"
|
||||
|
||||
@@ -135,7 +135,7 @@ QStringList GetSourceNames()
|
||||
}
|
||||
|
||||
void PopulateTransitionSelection(QComboBox *sel, bool addCurrent, bool addAny,
|
||||
bool addSelect)
|
||||
bool addSelect, bool addNone)
|
||||
{
|
||||
|
||||
obs_frontend_source_list *transitions = new obs_frontend_source_list();
|
||||
@@ -168,6 +168,11 @@ void PopulateTransitionSelection(QComboBox *sel, bool addCurrent, bool addAny,
|
||||
addSelect ? 1 : 0,
|
||||
obs_module_text("AdvSceneSwitcher.anyTransition"));
|
||||
}
|
||||
if (addNone) {
|
||||
sel->insertItem(
|
||||
addSelect ? 1 : 0,
|
||||
obs_module_text("AdvSceneSwitcher.noneTransition"));
|
||||
}
|
||||
}
|
||||
|
||||
void PopulateWindowSelection(QComboBox *sel, bool addSelect)
|
||||
|
||||
@@ -19,7 +19,8 @@ EXPORT QStringList GetSourceNames();
|
||||
|
||||
EXPORT void PopulateTransitionSelection(QComboBox *sel, bool addCurrent = true,
|
||||
bool addAny = false,
|
||||
bool addSelect = true);
|
||||
bool addSelect = true,
|
||||
bool addNone = false);
|
||||
EXPORT void PopulateWindowSelection(QComboBox *sel, bool addSelect = true);
|
||||
void PopulateAudioSelection(QComboBox *sel, bool addSelect = true);
|
||||
void PopulateVideoSelection(QComboBox *sel, bool addMainOutput = false,
|
||||
|
||||
@@ -348,7 +348,7 @@ MacroActionSceneVisibilityEdit::MacroActionSceneVisibilityEdit(
|
||||
},
|
||||
SceneItemSelectionWidget::NameClashMode::ALL)),
|
||||
_updateTransition(new QCheckBox(this)),
|
||||
_transitions(new TransitionSelectionWidget(this, true, false)),
|
||||
_transitions(new TransitionSelectionWidget(this, true, false, true)),
|
||||
_updateDuration(new QCheckBox(this)),
|
||||
_duration(new DurationSelection(this, false)),
|
||||
_durationLayout(new QHBoxLayout),
|
||||
@@ -482,10 +482,11 @@ void MacroActionSceneVisibilityEdit::ActionChanged(int value)
|
||||
|
||||
void MacroActionSceneVisibilityEdit::SetWidgetVisibility()
|
||||
{
|
||||
const auto transitionType = _entryData->_transition.GetType();
|
||||
const bool hideDurationSelection =
|
||||
_entryData->_updateTransition &&
|
||||
_entryData->_transition.GetType() !=
|
||||
TransitionSelection::Type::CURRENT &&
|
||||
transitionType != TransitionSelection::Type::CURRENT &&
|
||||
transitionType != TransitionSelection::Type::NONE &&
|
||||
IsFixedLengthTransition(
|
||||
_entryData->_transition.GetTransition());
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ OBSWeakSource TransitionSelection::GetTransition() const
|
||||
obs_source_release(source);
|
||||
return weakSource;
|
||||
}
|
||||
case Type::NONE:
|
||||
return nullptr;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -63,6 +65,8 @@ std::string TransitionSelection::ToString() const
|
||||
return obs_module_text("AdvSceneSwitcher.currentTransition");
|
||||
case Type::ANY:
|
||||
return obs_module_text("AdvSceneSwitcher.anyTransition");
|
||||
case Type::NONE:
|
||||
return obs_module_text("AdvSceneSwitcher.noneTransition");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -70,14 +74,16 @@ std::string TransitionSelection::ToString() const
|
||||
}
|
||||
|
||||
TransitionSelectionWidget::TransitionSelectionWidget(QWidget *parent,
|
||||
bool current, bool any)
|
||||
bool current, bool any,
|
||||
bool none)
|
||||
: FilterComboBox(parent,
|
||||
obs_module_text("AdvSceneSwitcher.selectTransition")),
|
||||
_addCurrent(current),
|
||||
_addAny(any)
|
||||
_addAny(any),
|
||||
_addNone(none)
|
||||
{
|
||||
setDuplicatesEnabled(true);
|
||||
PopulateTransitionSelection(this, current, any, false);
|
||||
PopulateTransitionSelection(this, current, any, false, none);
|
||||
|
||||
QWidget::connect(this, SIGNAL(currentTextChanged(const QString &)),
|
||||
this, SLOT(SelectionChanged(const QString &)));
|
||||
@@ -86,8 +92,9 @@ TransitionSelectionWidget::TransitionSelectionWidget(QWidget *parent,
|
||||
void TransitionSelectionWidget::SetTransition(const TransitionSelection &t)
|
||||
{
|
||||
// Order of entries
|
||||
// 1. Any transition
|
||||
// 2. Current transition
|
||||
// 1. None transition
|
||||
// 2. Any transition
|
||||
// 3. Current transition
|
||||
// 4. Transitions
|
||||
|
||||
switch (t.GetType()) {
|
||||
@@ -102,6 +109,10 @@ void TransitionSelectionWidget::SetTransition(const TransitionSelection &t)
|
||||
setCurrentIndex(findText(QString::fromStdString(
|
||||
obs_module_text("AdvSceneSwitcher.anyTransition"))));
|
||||
break;
|
||||
case TransitionSelection::Type::NONE:
|
||||
setCurrentIndex(findText(QString::fromStdString(
|
||||
obs_module_text("AdvSceneSwitcher.noneTransition"))));
|
||||
break;
|
||||
default:
|
||||
setCurrentIndex(-1);
|
||||
break;
|
||||
@@ -120,6 +131,12 @@ void TransitionSelectionWidget::EnableAnyEntry(bool enable)
|
||||
Populate();
|
||||
}
|
||||
|
||||
void TransitionSelectionWidget::EnableNoneEntry(bool enable)
|
||||
{
|
||||
_addNone = enable;
|
||||
Populate();
|
||||
}
|
||||
|
||||
void TransitionSelectionWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
FilterComboBox::showEvent(event);
|
||||
@@ -133,7 +150,7 @@ void TransitionSelectionWidget::Populate()
|
||||
{
|
||||
const QSignalBlocker blocker(this);
|
||||
clear();
|
||||
PopulateTransitionSelection(this, _addCurrent, _addAny);
|
||||
PopulateTransitionSelection(this, _addCurrent, _addAny, true, _addNone);
|
||||
}
|
||||
|
||||
static bool isFirstEntry(const QComboBox *l, QString name, int idx)
|
||||
@@ -163,6 +180,9 @@ TransitionSelection TransitionSelectionWidget::GetCurrentSelection() const
|
||||
if (IsAnyTransitionSelected(text)) {
|
||||
result._type = TransitionSelection::Type::ANY;
|
||||
}
|
||||
if (IsNoneTransitionSelected(text)) {
|
||||
result._type = TransitionSelection::Type::NONE;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -187,6 +207,16 @@ bool TransitionSelectionWidget::IsAnyTransitionSelected(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TransitionSelectionWidget::IsNoneTransitionSelected(
|
||||
const QString &name) const
|
||||
{
|
||||
if (name == QString::fromStdString((obs_module_text(
|
||||
"AdvSceneSwitcher.noneTransition")))) {
|
||||
return isFirstEntry(this, name, currentIndex());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TransitionSelectionWidget::SelectionChanged(const QString &)
|
||||
{
|
||||
emit TransitionChanged(GetCurrentSelection());
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
TRANSITION,
|
||||
CURRENT,
|
||||
ANY,
|
||||
NONE,
|
||||
};
|
||||
|
||||
Type GetType() const { return _type; }
|
||||
@@ -33,10 +34,11 @@ class TransitionSelectionWidget : public FilterComboBox {
|
||||
|
||||
public:
|
||||
TransitionSelectionWidget(QWidget *parent, bool current = true,
|
||||
bool any = false);
|
||||
bool any = false, bool none = false);
|
||||
void SetTransition(const TransitionSelection &);
|
||||
void EnableCurrentEntry(bool enable);
|
||||
void EnableAnyEntry(bool enable);
|
||||
void EnableNoneEntry(bool enable);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
@@ -52,9 +54,11 @@ private:
|
||||
TransitionSelection GetCurrentSelection() const;
|
||||
bool IsCurrentTransitionSelected(const QString &name) const;
|
||||
bool IsAnyTransitionSelected(const QString &name) const;
|
||||
bool IsNoneTransitionSelected(const QString &name) const;
|
||||
|
||||
bool _addCurrent;
|
||||
bool _addAny;
|
||||
bool _addNone;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user