UI: Don't transition if already transitioning (studio mode)
Closes obsproject/obs-studio#1304
This commit is contained in:
parent
e55579e63d
commit
8b98568bbc
@ -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<QVBoxLayout*>(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<QVBoxLayout*>(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)
|
||||
|
@ -186,6 +186,7 @@ private:
|
||||
|
||||
QPointer<QMenu> startStreamMenu;
|
||||
|
||||
QPointer<QPushButton> transitionButton;
|
||||
QPointer<QPushButton> replayBufferButton;
|
||||
|
||||
QScopedPointer<QSystemTrayIcon> trayIcon;
|
||||
@ -310,6 +311,8 @@ private:
|
||||
obs_data_array_t *SaveQuickTransitions();
|
||||
void ClearQuickTransitionWidgets();
|
||||
void RefreshQuickTransitions();
|
||||
void DisableQuickTransitionWidgets();
|
||||
void EnableQuickTransitionWidgets();
|
||||
void CreateDefaultQuickTransitions();
|
||||
|
||||
QMenu *CreatePerSceneTransitionMenu();
|
||||
|
Loading…
x
Reference in New Issue
Block a user