diff --git a/src/settings/settings_controller.h b/src/settings/settings_controller.h index 82efc60..7e51619 100644 --- a/src/settings/settings_controller.h +++ b/src/settings/settings_controller.h @@ -374,7 +374,7 @@ private: 0.5 }, DoubleSettingValue{ DoubleSetting::CHAPERONE_alarmSoundDistance, SettingCategory::Video, - QtInfo{ "alarmSoundDistance" }, + QtInfo{ "chaperoneAlarmSoundDistance" }, 0.5 }, DoubleSettingValue{ DoubleSetting::CHAPERONE_showDashboardDistance, SettingCategory::Video, diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index beaa577..00d396a 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -11,8 +11,6 @@ void ChaperoneTabController::initStage1() { auto settings = OverlayController::appSettings(); settings->beginGroup( "chaperoneSettings" ); - m_chaperoneAlarmSoundDistance - = settings->value( "chaperoneAlarmSoundDistance", 0.5f ).toFloat(); m_chaperoneShowDashboardDistance = settings->value( "chaperoneShowDashboardDistance", 0.5f ).toFloat(); m_fadeDistanceRemembered @@ -482,7 +480,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance ) if ( isChaperoneAlarmSoundEnabled() ) { // LOG(WARNING) << "In alarm"; - float activationDistance = m_chaperoneAlarmSoundDistance; + float activationDistance = chaperoneAlarmSoundDistance(); if ( distance <= activationDistance && proxSensorOverrideState ) { @@ -875,7 +873,8 @@ bool ChaperoneTabController::disableChaperone() const float ChaperoneTabController::chaperoneAlarmSoundDistance() const { - return m_chaperoneAlarmSoundDistance; + return static_cast( settings::getSetting( + settings::DoubleSetting::CHAPERONE_alarmSoundDistance ) ); } bool ChaperoneTabController::isChaperoneShowDashboardEnabled() const @@ -1085,20 +1084,16 @@ void ChaperoneTabController::setChaperoneAlarmSoundAdjustVolume( bool value, void ChaperoneTabController::setChaperoneAlarmSoundDistance( float value, bool notify ) { - if ( fabs( static_cast( m_chaperoneAlarmSoundDistance - value ) ) + if ( fabs( static_cast( chaperoneAlarmSoundDistance() - value ) ) > 0.005 ) { - m_chaperoneAlarmSoundDistance = value; - auto settings = OverlayController::appSettings(); - settings->beginGroup( "chaperoneSettings" ); - settings->setValue( "chaperoneAlarmSoundDistance", - m_chaperoneAlarmSoundDistance ); - settings->endGroup(); - settings->sync(); + settings::setSetting( + settings::DoubleSetting::CHAPERONE_alarmSoundDistance, + static_cast( value ) ); + if ( notify ) { - emit chaperoneAlarmSoundDistanceChanged( - m_chaperoneAlarmSoundDistance ); + emit chaperoneAlarmSoundDistanceChanged( value ); } } } @@ -1351,7 +1346,7 @@ void ChaperoneTabController::addChaperoneProfile( profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping(); profile->chaperoneAlarmSoundAdjustVolume = isChaperoneAlarmSoundAdjustVolume(); - profile->chaperoneAlarmSoundDistance = m_chaperoneAlarmSoundDistance; + profile->chaperoneAlarmSoundDistance = chaperoneAlarmSoundDistance(); profile->enableChaperoneShowDashboard = isChaperoneShowDashboardEnabled(); profile->chaperoneShowDashboardDistance diff --git a/src/tabcontrollers/ChaperoneTabController.h b/src/tabcontrollers/ChaperoneTabController.h index fafe1d4..54d2108 100644 --- a/src/tabcontrollers/ChaperoneTabController.h +++ b/src/tabcontrollers/ChaperoneTabController.h @@ -142,7 +142,6 @@ private: bool m_chaperoneHapticFeedbackActive = false; std::thread m_chaperoneHapticFeedbackThread; - float m_chaperoneAlarmSoundDistance = 0.5f; bool m_chaperoneAlarmSoundActive = false; float m_chaperoneShowDashboardDistance = 0.5f;