1
0
Эх сурвалжийг харах

UI: Use valueChanged() signal for T-Bar everywhere

The sliderMoved signal doesn't trigger when clicking on the slider, only
the valueChanged signal. According to QTBUG-72995 this is intentional,
since the documentation states that sliderDown also needs to be true for
the sliderMoved signal to be triggered. As for why sliderDown isn't true
when clicking, or why that would even be necessary for a signal that
should trigger when the slider is moved (and it very clearly moves)
remains a mystery.

Also gets rid of the wrong usage of the on_foo_bar slot declaration,
which should only be used for signals where the sender is part of a UI
file and it gets connected automatically. While it of course is possible
to connect it manually, this is against convention and can cause
confusion. In this case it was particularly wrong since even if tBar was
part of a UI file (which it isn't), the method should have been called
on_tBar_valueChanged instead of on_tbar_position_valueChanged.
gxalpha 3 жил өмнө
parent
commit
8d4a0b3645

+ 4 - 13
UI/window-basic-main-transitions.cpp

@@ -793,9 +793,7 @@ void OBSBasic::CreateProgramOptions()
 
 	tBar->setProperty("themeID", "tBarSlider");
 
-	connect(tBar, SIGNAL(sliderMoved(int)), this, SLOT(TBarChanged(int)));
-	connect(tBar, SIGNAL(valueChanged(int)), this,
-		SLOT(on_tbar_position_valueChanged(int)));
+	connect(tBar, &QSlider::valueChanged, this, &OBSBasic::TBarChanged);
 	connect(tBar, SIGNAL(sliderReleased()), this, SLOT(TBarReleased()));
 
 	layout->addStretch(0);
@@ -918,8 +916,6 @@ void OBSBasic::TBarChanged(int value)
 {
 	OBSSourceAutoRelease transition = obs_get_output_source(0);
 
-	tBar->setValue(value);
-
 	if (!tBarActive) {
 		OBSSource sceneSource = GetCurrentSceneSource();
 		OBSSource tBarTr = GetOverrideTransition(sceneSource);
@@ -945,6 +941,9 @@ void OBSBasic::TBarChanged(int value)
 
 	obs_transition_set_manual_time(transition,
 				       (float)value / T_BAR_PRECISION_F);
+
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_TBAR_VALUE_CHANGED);
 }
 
 int OBSBasic::GetTbarPosition()
@@ -952,14 +951,6 @@ int OBSBasic::GetTbarPosition()
 	return tBar->value();
 }
 
-void OBSBasic::on_tbar_position_valueChanged(int value)
-{
-	if (api) {
-		api->on_event(OBS_FRONTEND_EVENT_TBAR_VALUE_CHANGED);
-	}
-
-	UNUSED_PARAMETER(value);
-}
 void OBSBasic::on_modeSwitch_clicked()
 {
 	SetPreviewProgramMode(!IsPreviewProgramMode());

+ 0 - 1
UI/window-basic-main.hpp

@@ -1118,7 +1118,6 @@ private slots:
 	void on_transitionRemove_clicked();
 	void on_transitionProps_clicked();
 	void on_transitionDuration_valueChanged(int value);
-	void on_tbar_position_valueChanged(int value);
 
 	void ShowTransitionProperties();
 	void HideTransitionProperties();