UI: Implement deferred update flag (properties)

This commit is contained in:
jp9000 2015-03-19 13:44:48 -07:00 committed by John Bradley
parent ef4ee1fd1a
commit dc36f6f420
3 changed files with 13 additions and 1 deletions

View File

@ -50,6 +50,9 @@ void OBSPropertiesView::ReloadProperties()
obs_properties_apply_settings(properties.get(), settings);
}
uint32_t flags = obs_properties_get_flags(properties.get());
deferUpdate = (flags & OBS_PROPERTIES_DEFER_UPDATE) != 0;
RefreshProperties();
}
@ -755,7 +758,7 @@ void WidgetInfo::ControlChanged()
return;
}
if (view->callback)
if (view->callback && !view->deferUpdate)
view->callback(view->obj, view->settings);
view->SignalChanged();

View File

@ -66,6 +66,7 @@ private:
std::vector<std::unique_ptr<WidgetInfo>> children;
std::string lastFocused;
QWidget *lastWidget = nullptr;
bool deferUpdate;
QWidget *NewWidget(obs_property_t *prop, QWidget *widget,
const char *signal);
@ -106,4 +107,7 @@ public:
int minSize = 0);
inline obs_data_t *GetSettings() const {return settings;}
inline void UpdateSettings() {callback(obj, settings);}
inline bool DeferUpdate() const {return deferUpdate;}
};

View File

@ -117,6 +117,9 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
if (val == QDialogButtonBox::AcceptRole) {
acceptClicked = true;
close();
if (view->DeferUpdate())
view->UpdateSettings();
}
if (val == QDialogButtonBox::RejectRole) {
@ -260,6 +263,8 @@ bool OBSBasicProperties::ConfirmQuit()
switch (button) {
case QMessageBox::Save:
if (view->DeferUpdate())
view->UpdateSettings();
// Do nothing because the settings are already updated
break;
case QMessageBox::Discard: