mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 09:54:54 -05:00
98 lines
2.7 KiB
C++
98 lines
2.7 KiB
C++
#pragma once
|
|
#include "macro-condition-edit.hpp"
|
|
#include "usb-helpers.hpp"
|
|
#include "regex-config.hpp"
|
|
|
|
#include <QPushButton>
|
|
|
|
namespace advss {
|
|
|
|
class MacroConditionUSB : public MacroCondition {
|
|
public:
|
|
MacroConditionUSB(Macro *m) : MacroCondition(m, true) {}
|
|
bool CheckCondition();
|
|
bool Save(obs_data_t *obj) const;
|
|
bool Load(obs_data_t *obj);
|
|
std::string GetId() const { return id; };
|
|
static std::shared_ptr<MacroCondition> Create(Macro *m)
|
|
{
|
|
return std::make_shared<MacroConditionUSB>(m);
|
|
}
|
|
|
|
struct DeviceMatchOption {
|
|
std::string pattern = ".*";
|
|
RegexConfig regex = RegexConfig(true);
|
|
|
|
bool Matches(const std::string &value) const;
|
|
void Save(obs_data_t *, const char *) const;
|
|
void Load(obs_data_t *, const char *);
|
|
};
|
|
|
|
DeviceMatchOption _vendorID;
|
|
DeviceMatchOption _productID;
|
|
DeviceMatchOption _busNumber;
|
|
DeviceMatchOption _deviceAddress;
|
|
DeviceMatchOption _vendorName;
|
|
DeviceMatchOption _productName;
|
|
DeviceMatchOption _serialNumber;
|
|
|
|
private:
|
|
void SetupTempVars();
|
|
|
|
static bool _registered;
|
|
static const std::string id;
|
|
};
|
|
|
|
class MacroConditionUSBEdit : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MacroConditionUSBEdit(QWidget *parent,
|
|
std::shared_ptr<MacroConditionUSB> cond = nullptr);
|
|
void UpdateEntryData();
|
|
static QWidget *Create(QWidget *parent,
|
|
std::shared_ptr<MacroCondition> cond)
|
|
{
|
|
return new MacroConditionUSBEdit(
|
|
parent,
|
|
std::dynamic_pointer_cast<MacroConditionUSB>(cond));
|
|
}
|
|
|
|
private slots:
|
|
void VendorIDChanged(const QString &text);
|
|
void ProductIDChanged(const QString &text);
|
|
void BusNumberChanged(const QString &text);
|
|
void DeviceAddressChanged(const QString &text);
|
|
void VendorNameChanged(const QString &text);
|
|
void ProductNameChanged(const QString &text);
|
|
void SerialNumberChanged(const QString &text);
|
|
void VendorIDRegexChanged(const RegexConfig ®ex);
|
|
void ProductIDRegexChanged(const RegexConfig ®ex);
|
|
void BusNumberRegexChanged(const RegexConfig ®ex);
|
|
void DeviceAddressRegexChanged(const RegexConfig ®ex);
|
|
void VendorNameRegexChanged(const RegexConfig ®ex);
|
|
void ProductNameRegexChanged(const RegexConfig ®ex);
|
|
void SerialNumberRegexChanged(const RegexConfig ®ex);
|
|
|
|
private:
|
|
QComboBox *_vendorID;
|
|
QComboBox *_productID;
|
|
QComboBox *_busNumber;
|
|
QComboBox *_deviceAddress;
|
|
QComboBox *_vendorName;
|
|
QComboBox *_productName;
|
|
QComboBox *_serialNumber;
|
|
RegexConfigWidget *_vendorIDRegex;
|
|
RegexConfigWidget *_productIDRegex;
|
|
RegexConfigWidget *_busNumberRegex;
|
|
RegexConfigWidget *_deviceAddressRegex;
|
|
RegexConfigWidget *_vendorNameRegex;
|
|
RegexConfigWidget *_productNameRegex;
|
|
RegexConfigWidget *_serialNumberRegex;
|
|
|
|
std::shared_ptr<MacroConditionUSB> _entryData;
|
|
bool _loading = true;
|
|
};
|
|
|
|
} // namespace advss
|