UI: Fix non-default transitions going below add vals

This commit is contained in:
jp9000 2020-10-06 08:25:03 -07:00
parent 755e4f8897
commit da8547c112
2 changed files with 26 additions and 7 deletions

View File

@ -102,6 +102,26 @@ void OBSBasic::InitDefaultTransitions()
ui->transitions->blockSignals(false);
}
int OBSBasic::AddTransitionBeforeSeparator(const QString &name,
obs_source_t *source)
{
int idx = -1;
for (int i = 0; i < ui->transitions->count(); i++) {
QVariant v = ui->transitions->itemData(i);
if (!v.toString().isEmpty()) {
idx = i;
break;
}
}
ui->transitions->blockSignals(true);
ui->transitions->insertItem(idx - 1, name,
QVariant::fromValue(OBSSource(source)));
ui->transitions->blockSignals(false);
return idx - 1;
}
void OBSBasic::AddQuickTransitionHotkey(QuickTransition *qt)
{
DStr hotkeyId;
@ -516,10 +536,9 @@ void OBSBasic::AddTransition(QString id)
source = obs_source_create_private(QT_TO_UTF8(id), name.c_str(),
NULL);
InitTransition(source);
ui->transitions->addItem(
QT_UTF8(name.c_str()),
QVariant::fromValue(OBSSource(source)));
ui->transitions->setCurrentIndex(ui->transitions->count() - 1);
int idx = AddTransitionBeforeSeparator(QT_UTF8(name.c_str()),
source);
ui->transitions->setCurrentIndex(idx);
CreatePropertiesWindow(source);
obs_source_release(source);
@ -1550,9 +1569,7 @@ void OBSBasic::LoadTransitions(obs_data_array_t *transitions)
obs_source_create_private(id, name, settings);
if (!obs_obj_invalid(source)) {
InitTransition(source);
ui->transitions->addItem(
QT_UTF8(name),
QVariant::fromValue(OBSSource(source)));
AddTransitionBeforeSeparator(QT_UTF8(name), source);
}
obs_data_release(settings);

View File

@ -401,6 +401,8 @@ private:
void CreateProgramDisplay();
void CreateProgramOptions();
int AddTransitionBeforeSeparator(const QString &name,
obs_source_t *source);
void AddQuickTransitionId(int id);
void AddQuickTransition();
void AddQuickTransitionHotkey(QuickTransition *qt);