From efbe0e8717f2fdf8521cc78276f7e3e59534ad9f Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Tue, 17 Dec 2024 18:19:04 -0800 Subject: [PATCH] Don't endlessly set position, volume, speed, or tempo in QT UI --- backends/ui/qt/main_window.cpp | 10 +++++----- backends/ui/qt/slider.cpp | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backends/ui/qt/main_window.cpp b/backends/ui/qt/main_window.cpp index aab0a66..eb82ad1 100644 --- a/backends/ui/qt/main_window.cpp +++ b/backends/ui/qt/main_window.cpp @@ -5,7 +5,7 @@ void LooperWindow::Pulse() { auto len = playback->GetLength(); auto pos = playback->GetPosition(); this->slider->SetLimits(0.0, len); - if (!this->slider->IsPressed()) this->slider->SetValue(pos); + if (!this->slider->IsPressed()) this->slider->SetValueNoSignal(pos); auto component_count = TimeToComponentCount(len); bool enable_ui = !playback->IsStopped(); if (enable_ui) { @@ -24,10 +24,10 @@ void LooperWindow::Pulse() { auto pitch = playback->GetPitch(); auto speed = playback->GetSpeed(); auto tempo = playback->GetTempo(); - if (!volume_slider->IsPressed()) volume_slider->SetValue(volume); - if (!pitch_slider->IsPressed()) pitch_slider->SetValue(pitch); - if (!speed_slider->IsPressed()) speed_slider->SetValue(speed); - if (!tempo_slider->IsPressed()) tempo_slider->SetValue(tempo); + if (!volume_slider->IsPressed()) volume_slider->SetValueNoSignal(volume); + if (!pitch_slider->IsPressed()) pitch_slider->SetValueNoSignal(pitch); + if (!speed_slider->IsPressed()) speed_slider->SetValueNoSignal(speed); + if (!tempo_slider->IsPressed()) tempo_slider->SetValueNoSignal(tempo); volume_slider->SetLabel(fmt::format("Volume: {}%", (int)volume).c_str()); pitch_slider->SetLabel(fmt::format("Pitch {:.02f}x", pitch).c_str()); speed_slider->SetLabel(fmt::format("Speed: {:.02f}x", speed).c_str()); diff --git a/backends/ui/qt/slider.cpp b/backends/ui/qt/slider.cpp index 74b3332..4c7257c 100644 --- a/backends/ui/qt/slider.cpp +++ b/backends/ui/qt/slider.cpp @@ -76,6 +76,11 @@ void LooperSlider::set_value(double value) { void LooperSlider::SetValue(double value) { set_value(value); } +void LooperSlider::SetValueNoSignal(double value) { + this->slider_value_updating = true; + set_value(value); + this->slider_value_updating = false; +} void LooperSlider::set_min(double min) { settings_changed = true; this->min = min;