Files
SceneSwitcher/plugins/base/utils/source-setting.hpp
WarmUpTill 3ffe3c2fca Fix setting source settings without default value
Example text source's text field didn't have default value.
So, if never set before, can't be set using the "Source" action type.

Needed now that it is possible to create new sources via macro.
2026-10-24 21:32:32 +02:00

70 lines
1.8 KiB
C++

#pragma once
#include "filter-combo-box.hpp"
#include "help-icon.hpp"
#include <obs.hpp>
#include <optional>
#include <string>
#include <vector>
#include <QWidget>
#include <QLabel>
namespace advss {
class SourceSetting {
public:
SourceSetting() = default;
SourceSetting(const std::string &id, obs_property_type type,
const std::string &description,
const std::string &longDescription = "");
bool Save(obs_data_t *obj) const;
bool Load(obs_data_t *obj);
std::string GetID() const { return _id; }
obs_property_type GetType() const { return _type; }
bool IsList() const;
bool operator==(const SourceSetting &other) const;
private:
std::string _id = "";
obs_property_type _type = OBS_PROPERTY_INVALID;
std::string _description = "";
std::string _longDescription = "";
friend class SourceSettingSelection;
};
std::optional<std::string> GetSourceSettingValue(const OBSWeakSource &source,
const SourceSetting &setting);
std::optional<std::string>
GetSourceSettingListEntryName(const OBSWeakSource &source,
const SourceSetting &setting);
void SetSourceSetting(obs_source_t *source, const SourceSetting &setting,
const std::string &value);
void SetSourceSettingListEntryValueByName(obs_source_t *source,
const SourceSetting &setting,
const std::string &name);
class SourceSettingSelection : public QWidget {
Q_OBJECT
public:
SourceSettingSelection(QWidget *parent = nullptr);
void SetSource(const OBSWeakSource &,
bool restorePreviousSelection = true);
void SetSelection(const OBSWeakSource &source, const SourceSetting &);
private slots:
void SelectionIdxChanged(int);
signals:
void SelectionChanged(const SourceSetting &);
private:
void Populate(const OBSWeakSource &);
FilterComboBox *_settings;
HelpIcon *_tooltip;
};
} // namespace advss