Keep showing selected source setting if source is unavailable
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
WarmUpTill
2026-10-20 18:32:03 +02:00
committed by WarmUpTill
parent d35c66940e
commit d813edb6fb
2 changed files with 25 additions and 4 deletions

View File

@@ -512,9 +512,8 @@ void SourceSettingSelection::SetSource(const OBSWeakSource &source,
{
const auto previousSelection = _settings->currentData();
Populate(source);
if (restorePreviousSelection) {
_settings->setCurrentIndex(
_settings->findData(previousSelection));
if (restorePreviousSelection && previousSelection.isValid()) {
Select(previousSelection.value<SourceSetting>());
}
}
@@ -522,9 +521,30 @@ void SourceSettingSelection::SetSelection(const OBSWeakSource &source,
const SourceSetting &setting)
{
SetSource(source, false);
Select(setting);
}
void SourceSettingSelection::Select(const SourceSetting &setting)
{
QVariant variant;
variant.setValue(setting);
_settings->setCurrentIndex(_settings->findData(variant));
int idx = _settings->findData(variant);
// Keep showing the selected setting even if the source does not provide
// at the moment.
// So when a variable acts as the source the UI does not just show the
// placeholder value
if (idx == -1 && !setting._id.empty()) {
const auto &name = setting._description.empty()
? setting._id
: setting._description;
_settings->addItem(QString::fromStdString(name), variant);
idx = _settings->count() - 1;
adjustSize();
updateGeometry();
}
_settings->setCurrentIndex(idx);
}
void SourceSettingSelection::SelectionIdxChanged(int idx)

View File

@@ -61,6 +61,7 @@ signals:
private:
void Populate(const OBSWeakSource &);
void Select(const SourceSetting &);
FilterComboBox *_settings;
HelpIcon *_tooltip;