diff --git a/UI/window-basic-main-transitions.cpp b/UI/window-basic-main-transitions.cpp index d0531ae55..c6b79309c 100644 --- a/UI/window-basic-main-transitions.cpp +++ b/UI/window-basic-main-transitions.cpp @@ -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); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 450811063..77c987de9 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -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);