Improve settings button selection handling

Will now try to keep the current button selection if possible.
This can be useful when switching between source of the same time.
This commit is contained in:
WarmUpTill
2025-02-27 20:49:23 +01:00
committed by WarmUpTill
parent 8dfe81f522
commit 7de28eedd3
6 changed files with 83 additions and 35 deletions

View File

@@ -1,12 +1,16 @@
#pragma once
#include "filter-combo-box.hpp"
#include <obs.hpp>
#include <QComboBox>
#include <qmetatype.h>
#include <string>
#include <vector>
namespace advss {
class SourceSelection;
class FilterSelection;
struct SourceSettingButton {
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
@@ -18,7 +22,23 @@ struct SourceSettingButton {
std::vector<SourceSettingButton> GetSourceButtons(OBSWeakSource source);
void PressSourceButton(const SourceSettingButton &button, obs_source_t *source);
void PopulateSourceButtonSelection(QComboBox *list, OBSWeakSource source);
class SourceSettingsButtonSelection : public FilterComboBox {
Q_OBJECT
public:
SourceSettingsButtonSelection(QWidget *parent = nullptr);
void SetSource(const OBSWeakSource &source,
bool restorePreviousSelection = true);
void SetSelection(const OBSWeakSource &source,
const SourceSettingButton &button);
signals:
void SelectionChanged(const SourceSettingButton &);
private:
void PopulateSelection(const OBSWeakSource &source);
};
} // namespace advss