diff --git a/UI/window-basic-main-transitions.cpp b/UI/window-basic-main-transitions.cpp index 952f5d4d2..baed893a9 100644 --- a/UI/window-basic-main-transitions.cpp +++ b/UI/window-basic-main-transitions.cpp @@ -254,6 +254,12 @@ void OBSBasic::TransitionStopped() OBSSource scene = OBSGetStrongRef(swapScene); if (scene) SetCurrentScene(scene); + + // Make sure we re-enable the transition button + if (transitionButton) + transitionButton->setEnabled(true); + + EnableQuickTransitionWidgets(); } if (api) { @@ -294,7 +300,7 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force, bool direct, return; OBSWeakSource lastProgramScene; - + if (usingPreviewProgram) { lastProgramScene = programScene; programScene = OBSGetWeakRef(source); @@ -321,6 +327,12 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force, bool direct, OBSSource transition = obs_get_output_source(0); obs_source_release(transition); + bool stillTransitioning = obs_transition_get_time(transition) < 1.0f; + + // If actively transitioning, block new transitions from starting + if (usingPreviewProgram && stillTransitioning) + goto cleanup; + if (force) { obs_transition_set(transition, source); if (api) @@ -355,6 +367,15 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force, bool direct, TransitionFullyStopped(); } + // If transition has begun, disable Transition button + if (usingPreviewProgram && stillTransitioning) { + if (transitionButton) + transitionButton->setEnabled(false); + + DisableQuickTransitionWidgets(); + } + +cleanup: if (usingPreviewProgram && sceneDuplicationMode) obs_scene_release(scene); } @@ -725,7 +746,7 @@ void OBSBasic::CreateProgramOptions() QHBoxLayout *mainButtonLayout = new QHBoxLayout(); mainButtonLayout->setSpacing(2); - QPushButton *transitionButton = new QPushButton(QTStr("Transition")); + transitionButton = new QPushButton(QTStr("Transition")); QHBoxLayout *quickTransitions = new QHBoxLayout(); quickTransitions->setSpacing(2); @@ -809,7 +830,7 @@ void OBSBasic::CreateProgramOptions() menu.exec(QCursor::pos()); }; - connect(transitionButton, &QAbstractButton::clicked, + connect(transitionButton.data(), &QAbstractButton::clicked, this, &OBSBasic::TransitionClicked); connect(addQuickTransition, &QAbstractButton::clicked, onAdd); connect(configTransitions, &QAbstractButton::clicked, onConfig); @@ -1124,6 +1145,48 @@ void OBSBasic::RefreshQuickTransitions() AddQuickTransitionId(qt.id); } +void OBSBasic::DisableQuickTransitionWidgets() +{ + if (!IsPreviewProgramMode()) + return; + + QVBoxLayout *programLayout = + reinterpret_cast(programOptions->layout()); + + for (int idx = 0;; idx++) { + QLayoutItem *item = programLayout->itemAt(idx); + if (!item) + break; + + QWidget *widget = item->widget(); + if (!widget) + continue; + + widget->setEnabled(false); + } +} + +void OBSBasic::EnableQuickTransitionWidgets() +{ + if (!IsPreviewProgramMode()) + return; + + QVBoxLayout *programLayout = + reinterpret_cast(programOptions->layout()); + + for (int idx = 0;; idx++) { + QLayoutItem *item = programLayout->itemAt(idx); + if (!item) + break; + + QWidget *widget = item->widget(); + if (!widget) + continue; + + widget->setEnabled(true); + } +} + void OBSBasic::SetPreviewProgramMode(bool enabled) { if (IsPreviewProgramMode() == enabled) diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 27377622a..52ac7597b 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -186,6 +186,7 @@ private: QPointer startStreamMenu; + QPointer transitionButton; QPointer replayBufferButton; QScopedPointer trayIcon; @@ -310,6 +311,8 @@ private: obs_data_array_t *SaveQuickTransitions(); void ClearQuickTransitionWidgets(); void RefreshQuickTransitions(); + void DisableQuickTransitionWidgets(); + void EnableQuickTransitionWidgets(); void CreateDefaultQuickTransitions(); QMenu *CreatePerSceneTransitionMenu();