提交 f7d39c12 编写于 作者: C Clayton Groeneveld

UI: Fix studio mode transition bugs

-If the user were in the middle of a transition and clicked
the cut transition, the transitions would become borked.

-This actually disables the transition widgets, so the
user doesn't click them. Before, the disabling of the
widgets didn't work as expected. The code for enabling/disabling
them was also simplified.

-This loading of studio mode was moved in OBSInit because
the loading of transitions needs to happen first. This fixes
a bug when enabling/disabling the t-bar when the program
is first loaded. The t-bar would be disabled even if a
cut or stinger transition was not used.

-When the user would click the quick transitions, the
t-bar would be enabled even when it was not supposed
to.
上级 37a7805a
......@@ -268,11 +268,7 @@ void OBSBasic::TransitionStopped()
if (scene)
SetCurrentScene(scene);
// Make sure we re-enable the transition button
if (transitionButton)
transitionButton->setEnabled(true);
EnableQuickTransitionWidgets();
EnableTransitionWidgets(true);
}
if (api) {
......@@ -343,8 +339,7 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
obs_source_release(transition);
float t = obs_transition_get_time(transition);
bool stillTransitioning = (!tBarActive && t < 1.0f) ||
(tBarActive && t > 0.0f) || tBarDown;
bool stillTransitioning = t < 1.0f && t > 0.0f;
// If actively transitioning, block new transitions from starting
if (usingPreviewProgram && stillTransitioning)
......@@ -399,6 +394,8 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
manual ? OBS_TRANSITION_MODE_MANUAL
: OBS_TRANSITION_MODE_AUTO;
EnableTransitionWidgets(false);
bool success = obs_transition_start(transition, mode, duration,
source);
......@@ -406,14 +403,6 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force,
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);
......@@ -454,8 +443,6 @@ void OBSBasic::SetTransition(OBSSource transition)
ui->transitionRemove->setEnabled(configurable);
ui->transitionProps->setEnabled(configurable);
EnableTBar();
if (api)
api->on_event(OBS_FRONTEND_EVENT_TRANSITION_CHANGED);
}
......@@ -469,6 +456,7 @@ void OBSBasic::on_transitions_currentIndexChanged(int)
{
OBSSource transition = GetCurrentTransition();
SetTransition(transition);
EnableTBar();
}
void OBSBasic::AddTransition()
......@@ -907,12 +895,15 @@ void OBSBasic::TBarReleased()
tBar->setValue(0);
tBar->blockSignals(false);
tBarActive = false;
EnableTransitionWidgets(true);
} else if (val <= T_BAR_CLAMP) {
obs_transition_set_manual_time(GetCurrentTransition(), 0.0f);
tBar->blockSignals(true);
tBar->setValue(0);
tBar->blockSignals(false);
tBarActive = false;
EnableTransitionWidgets(true);
}
tBarDown = false;
......@@ -1215,8 +1206,6 @@ void OBSBasic::QuickTransitionChange()
qt->source = GetTransitionComboItem(ui->transitions, trIdx);
ResetQuickTransitionText(qt);
}
EnableTBar();
}
void OBSBasic::QuickTransitionChangeDuration(int value)
......@@ -1280,29 +1269,10 @@ void OBSBasic::RefreshQuickTransitions()
AddQuickTransitionId(qt.id);
}
void OBSBasic::DisableQuickTransitionWidgets()
void OBSBasic::EnableTransitionWidgets(bool enable)
{
if (!IsPreviewProgramMode())
return;
QVBoxLayout *programLayout =
reinterpret_cast<QVBoxLayout *>(programOptions->layout());
ui->transitions->setEnabled(enable);
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;
......@@ -1314,12 +1284,16 @@ void OBSBasic::EnableQuickTransitionWidgets()
if (!item)
break;
QWidget *widget = item->widget();
if (!widget)
QPushButton *button =
qobject_cast<QPushButton *>(item->widget());
if (!button)
continue;
widget->setEnabled(true);
button->setEnabled(enable);
}
if (transitionButton)
transitionButton->setEnabled(enable);
}
void OBSBasic::SetPreviewProgramMode(bool enabled)
......
......@@ -1633,15 +1633,6 @@ void OBSBasic::OBSInit()
editPropertiesMode = config_get_bool(
App()->GlobalConfig(), "BasicWindow", "EditPropertiesMode");
if (!opt_studio_mode) {
SetPreviewProgramMode(config_get_bool(App()->GlobalConfig(),
"BasicWindow",
"PreviewProgramMode"));
} else {
SetPreviewProgramMode(true);
opt_studio_mode = false;
}
#define SET_VISIBILITY(name, control) \
do { \
if (config_has_user_value(App()->GlobalConfig(), \
......@@ -1824,6 +1815,15 @@ void OBSBasic::OBSInit()
ui->sources->UpdateIcons();
if (!opt_studio_mode) {
SetPreviewProgramMode(config_get_bool(App()->GlobalConfig(),
"BasicWindow",
"PreviewProgramMode"));
} else {
SetPreviewProgramMode(true);
opt_studio_mode = false;
}
#if !defined(_WIN32) && !defined(__APPLE__)
delete ui->actionShowCrashLogs;
delete ui->actionUploadLastCrashLog;
......
......@@ -391,7 +391,7 @@ private:
void ClearQuickTransitionWidgets();
void RefreshQuickTransitions();
void DisableQuickTransitionWidgets();
void EnableQuickTransitionWidgets();
void EnableTransitionWidgets(bool enable);
void CreateDefaultQuickTransitions();
QMenu *CreatePerSceneTransitionMenu();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册