Move properties loading to OBSPropertiesView
This commit is contained in:
parent
7c0018d4bc
commit
088a05db8f
@ -40,6 +40,12 @@ static inline long long color_to_int(QColor color)
|
||||
shift(color.alpha(), 24);
|
||||
}
|
||||
|
||||
void OBSPropertiesView::ReloadProperties()
|
||||
{
|
||||
properties.reset(reloadCallback(obj));
|
||||
RefreshProperties();
|
||||
}
|
||||
|
||||
void OBSPropertiesView::RefreshProperties()
|
||||
{
|
||||
children.clear();
|
||||
@ -76,20 +82,21 @@ void OBSPropertiesView::RefreshProperties()
|
||||
}
|
||||
}
|
||||
|
||||
OBSPropertiesView::OBSPropertiesView(OBSData settings_,
|
||||
obs_properties_t *properties_, void *obj_,
|
||||
OBSPropertiesView::OBSPropertiesView(OBSData settings_, void *obj_,
|
||||
PropertiesReloadCallback reloadCallback,
|
||||
PropertiesUpdateCallback callback_, int minSize_)
|
||||
: QScrollArea (nullptr),
|
||||
widget (nullptr),
|
||||
properties (properties_, obs_properties_destroy),
|
||||
settings (settings_),
|
||||
obj (obj_),
|
||||
callback (callback_),
|
||||
minSize (minSize_),
|
||||
lastWidget (nullptr)
|
||||
: QScrollArea (nullptr),
|
||||
widget (nullptr),
|
||||
properties (nullptr, obs_properties_destroy),
|
||||
settings (settings_),
|
||||
obj (obj_),
|
||||
reloadCallback (reloadCallback),
|
||||
callback (callback_),
|
||||
minSize (minSize_),
|
||||
lastWidget (nullptr)
|
||||
{
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
RefreshProperties();
|
||||
ReloadProperties();
|
||||
}
|
||||
|
||||
void OBSPropertiesView::resizeEvent(QResizeEvent *event)
|
||||
|
@ -9,7 +9,9 @@ class QFormLayout;
|
||||
class OBSPropertiesView;
|
||||
class QLabel;
|
||||
|
||||
typedef void (*PropertiesUpdateCallback)(void *obj, obs_data_t *settings);
|
||||
typedef obs_properties_t *(*PropertiesReloadCallback)(void *obj);
|
||||
typedef void (*PropertiesUpdateCallback)(void *obj,
|
||||
obs_data_t *settings);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@ -57,6 +59,7 @@ private:
|
||||
properties_t properties;
|
||||
OBSData settings;
|
||||
void *obj;
|
||||
PropertiesReloadCallback reloadCallback;
|
||||
PropertiesUpdateCallback callback;
|
||||
int minSize;
|
||||
std::vector<std::unique_ptr<WidgetInfo>> children;
|
||||
@ -81,14 +84,15 @@ private:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void ReloadProperties();
|
||||
void RefreshProperties();
|
||||
|
||||
signals:
|
||||
void PropertiesResized();
|
||||
|
||||
public:
|
||||
OBSPropertiesView(OBSData settings,
|
||||
obs_properties_t *properties,
|
||||
void *obj, PropertiesUpdateCallback callback,
|
||||
OBSPropertiesView(OBSData settings, void *obj,
|
||||
PropertiesReloadCallback reloadCallback,
|
||||
PropertiesUpdateCallback callback,
|
||||
int minSize = 0);
|
||||
};
|
||||
|
@ -49,8 +49,8 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||
OBSData settings = obs_source_get_settings(source);
|
||||
obs_data_release(settings);
|
||||
|
||||
view = new OBSPropertiesView(settings,
|
||||
obs_source_properties(source), source,
|
||||
view = new OBSPropertiesView(settings, source,
|
||||
(PropertiesReloadCallback)obs_source_properties,
|
||||
(PropertiesUpdateCallback)obs_source_update);
|
||||
|
||||
layout()->addWidget(view);
|
||||
|
@ -239,13 +239,10 @@ void OBSBasicSettings::LoadServiceInfo()
|
||||
QLayout *layout = ui->streamContainer->layout();
|
||||
obs_service_t *service = main->GetService();
|
||||
obs_data_t *settings = obs_service_get_settings(service);
|
||||
obs_properties_t *properties = obs_service_properties(service);
|
||||
|
||||
delete streamProperties;
|
||||
streamProperties = new OBSPropertiesView(
|
||||
settings,
|
||||
properties,
|
||||
service,
|
||||
streamProperties = new OBSPropertiesView(settings, service,
|
||||
(PropertiesReloadCallback)obs_service_properties,
|
||||
(PropertiesUpdateCallback)obs_service_update,
|
||||
170);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user