SceneSwitcher/plugins/base/utils/source-setting.hpp
WarmUpTill ae25b4d023
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
Improve setting selection handling
Will now try to keep the current selection if possible.
This can be useful when switching between source of the same time.
2025-03-05 14:16:04 +01:00

61 lines
1.5 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, 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; }
EXPORT bool operator==(const SourceSetting &other) const;
private:
std::string _id = "";
std::string _description = "";
std::string _longDescription = "";
friend class SourceSettingSelection;
};
std::vector<SourceSetting> GetSoruceSettings(obs_source_t *source);
std::optional<std::string> GetSourceSettingValue(const OBSWeakSource &source,
const SourceSetting &setting);
void SetSourceSetting(obs_source_t *source, const SourceSetting &setting,
const std::string &value);
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