@@ -76,7 +76,11 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
7676 ui->propertiesLayout ->addWidget (view);
7777
7878 if (type == OBS_SOURCE_TYPE_TRANSITION) {
79- connect (view, &OBSPropertiesView::PropertiesRefreshed, this , &OBSBasicProperties::AddPreviewButton);
79+ ui->transitionButton ->setVisible (true );
80+ connect (ui->transitionButton , &QPushButton::clicked, this ,
81+ &OBSBasicProperties::previewTransitionClicked);
82+ } else {
83+ ui->transitionButton ->setVisible (false );
8084 }
8185
8286 view->show ();
@@ -147,6 +151,8 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
147151 } else {
148152 ui->preview ->hide ();
149153 }
154+
155+ connect (ui->defaultsButton , &QPushButton::clicked, this , &OBSBasicProperties::restoreDefaultsClicked);
150156}
151157
152158OBSBasicProperties::~OBSBasicProperties ()
@@ -159,37 +165,6 @@ OBSBasicProperties::~OBSBasicProperties()
159165 main->UpdateContextBarDeferred (true );
160166}
161167
162- void OBSBasicProperties::AddPreviewButton ()
163- {
164- QPushButton *playButton = new QPushButton (QTStr (" PreviewTransition" ), this );
165- VScrollArea *area = view;
166- area->widget ()->layout ()->addWidget (playButton);
167-
168- playButton->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
169-
170- auto play = [this ]() {
171- OBSSource start;
172- OBSSource end;
173-
174- if (direction) {
175- start = sourceA;
176- end = sourceB;
177- } else {
178- start = sourceB;
179- end = sourceA;
180- }
181-
182- obs_transition_set (sourceClone, start);
183- obs_transition_start (sourceClone, OBS_TRANSITION_MODE_AUTO, main->GetTransitionDuration (), end);
184- direction = !direction;
185-
186- start = nullptr ;
187- end = nullptr ;
188- };
189-
190- connect (playButton, &QPushButton::clicked, this , play);
191- }
192-
193168static obs_source_t *CreateLabel (const char *name, size_t h)
194169{
195170 OBSDataAutoRelease settings = obs_data_create ();
@@ -251,6 +226,53 @@ static void CreateTransitionScene(OBSSource scene, const char *text, uint32_t co
251226 obs_sceneitem_set_bounds_type (item, OBS_BOUNDS_SCALE_INNER);
252227}
253228
229+ static bool ConfirmReset (QWidget *parent)
230+ {
231+ QMessageBox::StandardButton button;
232+
233+ button = OBSMessageBox::question (parent, QTStr (" ConfirmReset.Title" ), QTStr (" ConfirmReset.Text" ),
234+ QMessageBox::Yes | QMessageBox::No);
235+
236+ return button == QMessageBox::Yes;
237+ }
238+
239+ void OBSBasicProperties::restoreDefaultsClicked ()
240+ {
241+ if (!ConfirmReset (this )) {
242+ return ;
243+ }
244+
245+ OBSDataAutoRelease settings = obs_source_get_settings (source);
246+ obs_data_clear (settings);
247+
248+ if (!view->DeferUpdate ()) {
249+ obs_source_update (source, nullptr );
250+ }
251+
252+ view->ReloadProperties ();
253+ }
254+
255+ void OBSBasicProperties::previewTransitionClicked ()
256+ {
257+ OBSSource start;
258+ OBSSource end;
259+
260+ if (direction) {
261+ start = sourceA;
262+ end = sourceB;
263+ } else {
264+ start = sourceB;
265+ end = sourceA;
266+ }
267+
268+ obs_transition_set (sourceClone, start);
269+ obs_transition_start (sourceClone, OBS_TRANSITION_MODE_AUTO, main->GetTransitionDuration (), end);
270+ direction = !direction;
271+
272+ start = nullptr ;
273+ end = nullptr ;
274+ }
275+
254276void OBSBasicProperties::SourceRemoved (void *data, calldata_t *)
255277{
256278 QMetaObject::invokeMethod (static_cast <OBSBasicProperties *>(data), " close" );
@@ -269,16 +291,6 @@ void OBSBasicProperties::UpdateProperties(void *data, calldata_t *)
269291 QMetaObject::invokeMethod (static_cast <OBSBasicProperties *>(data)->view , " ReloadProperties" );
270292}
271293
272- static bool ConfirmReset (QWidget *parent)
273- {
274- QMessageBox::StandardButton button;
275-
276- button = OBSMessageBox::question (parent, QTStr (" ConfirmReset.Title" ), QTStr (" ConfirmReset.Text" ),
277- QMessageBox::Yes | QMessageBox::No);
278-
279- return button == QMessageBox::Yes;
280- }
281-
282294void OBSBasicProperties::on_buttonBox_clicked (QAbstractButton *button)
283295{
284296 QDialogButtonBox::ButtonRole val = ui->buttonBox ->buttonRole (button);
@@ -329,18 +341,6 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
329341 obs_source_update (source, oldSettings);
330342
331343 close ();
332-
333- } else if (val == QDialogButtonBox::ResetRole) {
334- if (!ConfirmReset (this ))
335- return ;
336-
337- OBSDataAutoRelease settings = obs_source_get_settings (source);
338- obs_data_clear (settings);
339-
340- if (!view->DeferUpdate ())
341- obs_source_update (source, nullptr );
342-
343- view->ReloadProperties ();
344344 }
345345}
346346
0 commit comments