UI: Allow prop. view to be created via identifier
Allows a properties view control to be created only with an identifier string instead of only being created with a pointer to an object. This way, we don't necessarily have to have an object for some arbitrary settings we want the user to be able to modify.
This commit is contained in:
parent
88d3c506ae
commit
baaa061344
@ -42,7 +42,13 @@ static inline long long color_to_int(QColor color)
|
||||
|
||||
void OBSPropertiesView::ReloadProperties()
|
||||
{
|
||||
properties.reset(reloadCallback(obj));
|
||||
if (obj) {
|
||||
properties.reset(reloadCallback(obj));
|
||||
} else {
|
||||
properties.reset(reloadCallback((void*)type.c_str()));
|
||||
obs_properties_apply_settings(properties.get(), settings);
|
||||
}
|
||||
|
||||
RefreshProperties();
|
||||
}
|
||||
|
||||
@ -97,6 +103,19 @@ OBSPropertiesView::OBSPropertiesView(OBSData settings_, void *obj_,
|
||||
ReloadProperties();
|
||||
}
|
||||
|
||||
OBSPropertiesView::OBSPropertiesView(OBSData settings_, const char *type_,
|
||||
PropertiesReloadCallback reloadCallback_, int minSize_)
|
||||
: VScrollArea (nullptr),
|
||||
properties (nullptr, obs_properties_destroy),
|
||||
settings (settings_),
|
||||
type (type_),
|
||||
reloadCallback (reloadCallback_),
|
||||
minSize (minSize_)
|
||||
{
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
ReloadProperties();
|
||||
}
|
||||
|
||||
void OBSPropertiesView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
emit PropertiesResized();
|
||||
@ -694,7 +713,9 @@ void WidgetInfo::ControlChanged()
|
||||
return;
|
||||
}
|
||||
|
||||
view->callback(view->obj, view->settings);
|
||||
if (view->callback)
|
||||
view->callback(view->obj, view->settings);
|
||||
|
||||
if (obs_property_modified(property, view->settings)) {
|
||||
view->lastFocused = setting;
|
||||
QMetaObject::invokeMethod(view, "RefreshProperties",
|
||||
|
@ -59,6 +59,7 @@ private:
|
||||
properties_t properties;
|
||||
OBSData settings;
|
||||
void *obj = nullptr;
|
||||
std::string type;
|
||||
PropertiesReloadCallback reloadCallback;
|
||||
PropertiesUpdateCallback callback = nullptr;
|
||||
int minSize;
|
||||
@ -95,4 +96,7 @@ public:
|
||||
PropertiesReloadCallback reloadCallback,
|
||||
PropertiesUpdateCallback callback,
|
||||
int minSize = 0);
|
||||
OBSPropertiesView(OBSData settings, const char *type,
|
||||
PropertiesReloadCallback reloadCallback,
|
||||
int minSize = 0);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user