From f730063da39f2e6338629f526acb99c8d574ffa1 Mon Sep 17 00:00:00 2001 From: Warchamp7 Date: Tue, 14 Jul 2026 20:17:32 -0400 Subject: [PATCH] frontend: Adjustments to Add Source window --- frontend/data/locale/en-US.ini | 10 +- frontend/data/themes/Yami.obt | 10 + frontend/dialogs/OBSBasicSourceSelect.cpp | 66 ++--- frontend/forms/OBSBasicSourceSelect.ui | 289 +++++++++++----------- 4 files changed, 187 insertions(+), 188 deletions(-) diff --git a/frontend/data/locale/en-US.ini b/frontend/data/locale/en-US.ini index 933a095db..b5cc6384c 100644 --- a/frontend/data/locale/en-US.ini +++ b/frontend/data/locale/en-US.ini @@ -644,13 +644,15 @@ Basic.Main.PreviewDisabled="Preview is currently disabled" Basic.SourceSelect="Add Source" Basic.SourceSelect.SelectType="Source Type" Basic.SourceSelect.Recent="Recently Created" -Basic.SourceSelect.NewSource="Create a New Source" -Basic.SourceSelect.Existing="Add an Existing Source" +Basic.SourceSelect.Description="Select which source(s) to add to your current scene." +Basic.SourceSelect.NewSource="Add a new %1" +Basic.SourceSelect.AddExisting="Add %1 existing" +Basic.SourceSelect.NoSelection="Add existing" Basic.SourceSelect.CreateButton="Create New" Basic.SourceSelect.AddVisible="Make source visible" -Basic.SourceSelect.NoExisting="No existing %1 sources" +Basic.SourceSelect.NoExisting="You have no existing %1 sources yet." Basic.SourceSelect.Accessible.SourceName="Source Name" -Basic.SourceSelect.Accessible.Existing="Add an Existing Source" +Basic.SourceSelect.Accessible.Existing="Add an existing source" Basic.SourceSelect.Deprecated.Create="This source type is marked as deprecated and may be removed in the future." # source box diff --git a/frontend/data/themes/Yami.obt b/frontend/data/themes/Yami.obt index fb2d78dd4..e1f26ef14 100644 --- a/frontend/data/themes/Yami.obt +++ b/frontend/data/themes/Yami.obt @@ -2437,6 +2437,16 @@ OBSBasicAdvAudio #scrollAreaWidgetContents { } /* Add Source Dialog */ +.btn-create-new { + background: transparent; + padding: var(--padding_wide) var(--padding_large); + border-radius: var(--border_radius); + border: 2px dashed var(--grey3); + outline: none; + qproperty-icon: url(theme:Dark/plus.svg); + margin-bottom: var(--spacing_large); +} + SourceSelectButton { background: var(--grey5); padding: var(--padding_base) var(--padding_large); diff --git a/frontend/dialogs/OBSBasicSourceSelect.cpp b/frontend/dialogs/OBSBasicSourceSelect.cpp index e06b1a02d..d7aece644 100644 --- a/frontend/dialogs/OBSBasicSourceSelect.cpp +++ b/frontend/dialogs/OBSBasicSourceSelect.cpp @@ -255,9 +255,9 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, undo_stack &undo_s) connect(ui->existingScrollArea->horizontalScrollBar(), &QScrollBar::valueChanged, this, &OBSBasicSourceSelect::updateButtonVisibility); - ui->createNewFrame->setVisible(false); - ui->deprecatedCreateLabel->setVisible(false); - ui->deprecatedCreateLabel->setProperty("class", "text-muted"); + ui->createNewSource->setVisible(false); + ui->noExistingLabel->setVisible(false); + ui->deprecatedFrame->setVisible(false); rebuildSourceTypeList(); refreshSources(); @@ -272,16 +272,16 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, undo_stack &undo_s) connect(ui->sourceTypeList, &QListWidget::itemDoubleClicked, this, &OBSBasicSourceSelect::createNew); connect(ui->sourceTypeList, &QListWidget::currentItemChanged, this, &OBSBasicSourceSelect::sourceTypeSelected); - connect(ui->newSourceName, &QLineEdit::returnPressed, this, &OBSBasicSourceSelect::createNew); connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(ui->addExistingButton, &QAbstractButton::clicked, this, &OBSBasicSourceSelect::addSelectedSources); connect(this, &OBSBasicSourceSelect::selectedItemsChanged, this, [this]() { ui->addExistingButton->setEnabled(selectedItems.size() > 0); if (selectedItems.size() > 0) { - ui->addExistingButton->setText(QTStr("Add %1 Existing").arg(selectedItems.size())); + ui->addExistingButton->setText( + QTStr("Basic.SourceSelect.AddExisting").arg(selectedItems.size())); } else { - ui->addExistingButton->setText("Add Existing"); + ui->addExistingButton->setText(QTStr("Basic.SourceSelect.NoSelection")); } }); @@ -537,6 +537,13 @@ void OBSBasicSourceSelect::rebuildSourceTypeList() ui->sourceTypeList->sortItems(); + auto *deprecatedTitle = new QListWidgetItem(ui->sourceTypeList); + deprecatedTitle->setText(QTStr("Deprecated")); + deprecatedTitle->setFlags(deprecatedTitle->flags() & ~Qt::ItemIsEnabled); + deprecatedTitle->setFlags(deprecatedTitle->flags() & ~Qt::ItemIsSelectable); + + ui->sourceTypeList->addItem(deprecatedTitle); + // Shift Deprecated sources to the bottom QList deprecatedItems; for (int i = 0; i < ui->sourceTypeList->count(); ++i) { @@ -732,10 +739,6 @@ void OBSBasicSourceSelect::createNew() { bool visible = ui->sourceVisible->isChecked(); - if (ui->newSourceName->text().isEmpty()) { - return; - } - if (selectedTypeId.compare(kRecentTypeId) == 0) { return; } @@ -746,7 +749,8 @@ void OBSBasicSourceSelect::createNew() std::string sourceType = selectedTypeId.toStdString(); const char *id = sourceType.c_str(); - std::string newName = ui->newSourceName->text().toStdString(); + QString placeholder = getDisplayNameForSourceType(selectedTypeId); + std::string newName = getNewSourceName(placeholder.toStdString().c_str()); std::optional createResult = setupNewSource(this, id, newName.c_str()); if (!createResult.has_value()) { @@ -779,7 +783,7 @@ void OBSBasicSourceSelect::createNew() OBSDataAutoRelease wrapper = obs_data_create(); obs_data_set_string(wrapper, "id", id); obs_data_set_int(wrapper, "item_id", obs_sceneitem_get_id(item)); - obs_data_set_string(wrapper, "name", ui->newSourceName->text().toUtf8().constData()); + obs_data_set_string(wrapper, "name", newName.c_str()); obs_data_set_bool(wrapper, "visible", visible); auto redo = [sceneUuid](const std::string &data) { @@ -808,7 +812,7 @@ void OBSBasicSourceSelect::createNew() obs_sceneitem_set_id(item, static_cast(obs_data_get_int(dat, "item_id"))); }; - undo_s.add_action(QTStr("Undo.Add").arg(ui->newSourceName->text()), undo, redo, + undo_s.add_action(QTStr("Undo.Add").arg(QString::fromStdString(newName)), undo, redo, std::string(obs_source_get_uuid(newSource)), std::string(obs_data_get_json(wrapper))); main->CreatePropertiesWindow(newSource); @@ -910,9 +914,15 @@ void OBSBasicSourceSelect::sourceTypeSelected(QListWidgetItem *current, QListWid QVariant unversionedIdData = current->data(kUnversionedIdRole); QVariant deprecatedData = current->data(kDeprecatedRole); + bool isDeprecatedType = deprecatedData.toBool(); + ui->deprecatedFrame->setVisible(isDeprecatedType); + if (unversionedIdData.toString().compare(kRecentTypeId) == 0) { + ui->sourceSelectTitle->setText(QTStr("Basic.SourceSelect.Recent")); selectedTypeId = kRecentTypeId.toString(); - ui->createNewFrame->setVisible(false); + ui->noExistingLabel->setVisible(false); + ui->existingScrollArea->setVisible(true); + ui->createNewSource->setVisible(false); updateExistingSources(kRecentListLimit); return; } @@ -922,31 +932,21 @@ void OBSBasicSourceSelect::sourceTypeSelected(QListWidgetItem *current, QListWid return; } - ui->createNewFrame->setVisible(true); - - bool isDeprecatedType = deprecatedData.toBool(); - ui->deprecatedCreateLabel->setVisible(isDeprecatedType); + ui->createNewSource->setVisible(type != "scene"); selectedTypeId = type; QString placeHolderText{getDisplayNameForSourceType(selectedTypeId)}; - QString text{placeHolderText}; - int i = 2; - OBSSourceAutoRelease source = nullptr; - while ((source = obs_get_source_by_name(QT_TO_UTF8(text)))) { - text = QString("%1 %2").arg(placeHolderText).arg(i++); - } - - ui->newSourceName->setText(text); + ui->createNewSource->setText( + QTStr("Basic.SourceSelect.NewSource").arg(getDisplayNameForSourceType(selectedTypeId))); + ui->sourceSelectTitle->setText(QString("%1").arg(getDisplayNameForSourceType(selectedTypeId))); updateExistingSources(); - if (existingFlowLayout->count() == 0) { - QLabel *noExisting = new QLabel(); - noExisting->setText( - QTStr("Basic.SourceSelect.NoExisting").arg(getDisplayNameForSourceType(selectedTypeId))); - noExisting->setProperty("class", "text-muted"); - existingFlowLayout->addWidget(noExisting); - } + ui->noExistingLabel->setText( + QTStr("Basic.SourceSelect.NoExisting").arg(getDisplayNameForSourceType(selectedTypeId))); + + ui->existingScrollArea->setVisible(existingFlowLayout->count() != 0); + ui->noExistingLabel->setVisible(existingFlowLayout->count() == 0); } diff --git a/frontend/forms/OBSBasicSourceSelect.ui b/frontend/forms/OBSBasicSourceSelect.ui index e3eede837..d0bdd8b14 100644 --- a/frontend/forms/OBSBasicSourceSelect.ui +++ b/frontend/forms/OBSBasicSourceSelect.ui @@ -9,8 +9,8 @@ 0 0 - 1010 - 614 + 1040 + 620 @@ -151,6 +151,12 @@ 0 + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + QAbstractScrollArea::AdjustToContentsOnFirstShow @@ -235,7 +241,7 @@ 0 - + dialog-container @@ -254,7 +260,85 @@ 0 - + + + Basic.SourceSelect.Recent + + + text-title + + + + + + + Basic.SourceSelect.Description + + + text-small text-muted margin-y + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + frame-notice + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + Basic.SourceSelect.Deprecated.Create + + + Qt::AlignCenter + + + + + + + + Basic.SourceSelect.AddExisting @@ -284,18 +368,40 @@ 0 - + - + + 0 + 0 + + + + PointingHandCursor + + + Basic.SourceSelect.NewSource + + + btn-create-new + + + + + + + 0 0 - Basic.SourceSelect.Existing + Basic.SourceSelect.NoExisting + + + Qt::AlignCenter - text-title + text-muted @@ -313,6 +419,9 @@ 0 + + Qt::ScrollBarAlwaysOn + Qt::ScrollBarAlwaysOff @@ -327,8 +436,8 @@ 0 0 - 800 - 510 + 819 + 250 @@ -401,6 +510,25 @@ 0 + + + + false + + + + 0 + 0 + + + + Basic.SourceSelect.NoSelection + + + button-primary + + + @@ -427,143 +555,6 @@ - - - - false - - - - 0 - 0 - - - - Add Existing - - - button-primary - - - - - - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - dialog-container dialog-frame - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Basic.SourceSelect.NewSource - - - text-title - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - Basic.SourceSelect.Deprecated.Create - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Basic.SourceSelect.Accessible.SourceName - - - - - - - - 0 - 0 - - - - Basic.SourceSelect.CreateButton - - - button-primary margin-left - - - @@ -663,10 +654,6 @@ sourceTypeList - existingScrollArea - addExistingButton - newSourceName - createNewSource sourceVisible