Improve setting selection handling
Some checks are pending
debian-build / build (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions

Will now try to keep the current selection if possible.
This can be useful when switching between source of the same time.
This commit is contained in:
WarmUpTill
2025-02-28 20:39:29 +01:00
committed by WarmUpTill
parent af055a12a1
commit ae25b4d023
6 changed files with 21 additions and 13 deletions

View File

@@ -249,14 +249,21 @@ SourceSettingSelection::SourceSettingSelection(QWidget *parent)
setLayout(layout);
}
void SourceSettingSelection::SetSource(const OBSWeakSource &source)
void SourceSettingSelection::SetSource(const OBSWeakSource &source,
bool restorePreviousSelection)
{
_settings->clear();
const auto previousSelection = _settings->currentData();
Populate(source);
if (restorePreviousSelection) {
_settings->setCurrentIndex(
_settings->findData(previousSelection));
}
}
void SourceSettingSelection::SetSetting(const SourceSetting &setting)
void SourceSettingSelection::SetSelection(const OBSWeakSource &source,
const SourceSetting &setting)
{
SetSource(source, false);
QVariant variant;
variant.setValue(setting);
_settings->setCurrentIndex(_settings->findData(variant));
@@ -281,6 +288,7 @@ void SourceSettingSelection::SelectionIdxChanged(int idx)
void SourceSettingSelection::Populate(const OBSWeakSource &source)
{
_settings->clear();
OBSSourceAutoRelease s = obs_weak_source_get_source(source);
auto settings = GetSoruceSettings(s);
for (const auto &setting : settings) {