frontend: Adjustments to Add Source window

This commit is contained in:
Warchamp7
2026-07-14 20:17:32 -04:00
committed by Ryan Foster
parent 6750a6e9f5
commit f730063da3
4 changed files with 187 additions and 188 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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<QListWidgetItem *> 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<OBSSource> 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<int64_t>(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);
}

View File

@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1010</width>
<height>614</height>
<width>1040</width>
<height>620</height>
</rect>
</property>
<property name="sizePolicy">
@@ -151,6 +151,12 @@
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
@@ -235,7 +241,7 @@
<number>0</number>
</property>
<property name="class" stdset="0">
<string/>
<string>dialog-container</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
@@ -254,7 +260,85 @@
<number>0</number>
</property>
<item>
<widget class="QFrame" name="selectExistingFrame">
<widget class="QLabel" name="sourceSelectTitle">
<property name="text">
<string>Basic.SourceSelect.Recent</string>
</property>
<property name="class" stdset="0">
<string>text-title</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="sourceSelectDescription">
<property name="text">
<string>Basic.SourceSelect.Description</string>
</property>
<property name="class" stdset="0">
<string>text-small text-muted margin-y</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="deprecatedFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="class" stdset="0">
<string>frame-notice</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="deprecatedCreateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string>Basic.SourceSelect.Deprecated.Create</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="selectSourceFrame">
<property name="accessibleName">
<string>Basic.SourceSelect.AddExisting</string>
</property>
@@ -284,18 +368,40 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="existingLabel">
<widget class="QPushButton" name="createNewSource">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Basic.SourceSelect.NewSource</string>
</property>
<property name="class" stdset="0">
<string>btn-create-new</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="noExistingLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic.SourceSelect.Existing</string>
<string>Basic.SourceSelect.NoExisting</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="class" stdset="0">
<string>text-title</string>
<string>text-muted</string>
</property>
</widget>
</item>
@@ -313,6 +419,9 @@
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
@@ -327,8 +436,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>510</height>
<width>819</width>
<height>250</height>
</rect>
</property>
<property name="autoFillBackground">
@@ -401,6 +510,25 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="addExistingButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic.SourceSelect.NoSelection</string>
</property>
<property name="class" stdset="0">
<string>button-primary</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
@@ -427,143 +555,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addExistingButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add Existing</string>
</property>
<property name="class" stdset="0">
<string>button-primary</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="createNewFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="class" stdset="0">
<string>dialog-container dialog-frame</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Basic.SourceSelect.NewSource</string>
</property>
<property name="class" stdset="0">
<string>text-title</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deprecatedCreateLabel">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string>Basic.SourceSelect.Deprecated.Create</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="newSourceName">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accessibleName">
<string>Basic.SourceSelect.Accessible.SourceName</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="createNewSource">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic.SourceSelect.CreateButton</string>
</property>
<property name="class" stdset="0">
<string>button-primary margin-left</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -663,10 +654,6 @@
</customwidgets>
<tabstops>
<tabstop>sourceTypeList</tabstop>
<tabstop>existingScrollArea</tabstop>
<tabstop>addExistingButton</tabstop>
<tabstop>newSourceName</tabstop>
<tabstop>createNewSource</tabstop>
<tabstop>sourceVisible</tabstop>
</tabstops>
<resources>