From 8d4a0b36451218cd13af58828eb7788e1df12551 Mon Sep 17 00:00:00 2001 From: gxalpha Date: Sun, 11 Sep 2022 16:54:24 +0200 Subject: [PATCH] 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. --- UI/window-basic-main-transitions.cpp | 17 ++++------------- UI/window-basic-main.hpp | 1 - 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/UI/window-basic-main-transitions.cpp b/UI/window-basic-main-transitions.cpp index e3f4e7374..0d9b6d001 100644 --- a/UI/window-basic-main-transitions.cpp +++ b/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()); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index e2c72ddbd..fa0857056 100644 --- a/UI/window-basic-main.hpp +++ b/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();