Convert m_chaperoneHapticFeedbackDistance to new settings API

This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 81bbec52b4
commit 13c8eabeb0
3 changed files with 11 additions and 17 deletions
+1 -1
View File
@@ -370,7 +370,7 @@ private:
0.5 }, 0.5 },
DoubleSettingValue{ DoubleSetting::CHAPERONE_hapticFeedbackDistance, DoubleSettingValue{ DoubleSetting::CHAPERONE_hapticFeedbackDistance,
SettingCategory::Video, SettingCategory::Video,
QtInfo{ "hapticFeedbackDistance" }, QtInfo{ "chaperoneHapticFeedbackDistance" },
0.5 }, 0.5 },
DoubleSettingValue{ DoubleSetting::CHAPERONE_alarmSoundDistance, DoubleSettingValue{ DoubleSetting::CHAPERONE_alarmSoundDistance,
SettingCategory::Video, SettingCategory::Video,
+10 -15
View File
@@ -11,8 +11,6 @@ void ChaperoneTabController::initStage1()
{ {
auto settings = OverlayController::appSettings(); auto settings = OverlayController::appSettings();
settings->beginGroup( "chaperoneSettings" ); settings->beginGroup( "chaperoneSettings" );
m_chaperoneHapticFeedbackDistance
= settings->value( "chaperoneHapticFeedbackDistance", 0.5f ).toFloat();
m_chaperoneAlarmSoundDistance m_chaperoneAlarmSoundDistance
= settings->value( "chaperoneAlarmSoundDistance", 0.5f ).toFloat(); = settings->value( "chaperoneAlarmSoundDistance", 0.5f ).toFloat();
m_chaperoneShowDashboardDistance m_chaperoneShowDashboardDistance
@@ -417,7 +415,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
if ( isChaperoneHapticFeedbackEnabled() ) if ( isChaperoneHapticFeedbackEnabled() )
{ {
float activationDistance = m_chaperoneHapticFeedbackDistance; float activationDistance = chaperoneHapticFeedbackDistance();
if ( distance <= activationDistance && proxSensorOverrideState ) if ( distance <= activationDistance && proxSensorOverrideState )
{ {
@@ -847,7 +845,8 @@ bool ChaperoneTabController::isChaperoneHapticFeedbackEnabled() const
float ChaperoneTabController::chaperoneHapticFeedbackDistance() const float ChaperoneTabController::chaperoneHapticFeedbackDistance() const
{ {
return m_chaperoneHapticFeedbackDistance; return static_cast<float>( settings::getSetting(
settings::DoubleSetting::CHAPERONE_hapticFeedbackDistance ) );
} }
bool ChaperoneTabController::isChaperoneAlarmSoundEnabled() const bool ChaperoneTabController::isChaperoneAlarmSoundEnabled() const
@@ -1003,20 +1002,16 @@ void ChaperoneTabController::setChaperoneHapticFeedbackDistance( float value,
bool notify ) bool notify )
{ {
if ( fabs( if ( fabs(
static_cast<double>( m_chaperoneHapticFeedbackDistance - value ) ) static_cast<double>( chaperoneHapticFeedbackDistance() - value ) )
> 0.005 ) > 0.005 )
{ {
m_chaperoneHapticFeedbackDistance = value; settings::setSetting(
auto settings = OverlayController::appSettings(); settings::DoubleSetting::CHAPERONE_hapticFeedbackDistance,
settings->beginGroup( "chaperoneSettings" ); static_cast<double>( value ) );
settings->setValue( "chaperoneHapticFeedbackDistance",
m_chaperoneHapticFeedbackDistance );
settings->endGroup();
settings->sync();
if ( notify ) if ( notify )
{ {
emit chaperoneHapticFeedbackDistanceChanged( emit chaperoneHapticFeedbackDistanceChanged( value );
m_chaperoneHapticFeedbackDistance );
} }
} }
} }
@@ -1351,7 +1346,7 @@ void ChaperoneTabController::addChaperoneProfile(
profile->enableChaperoneHapticFeedback profile->enableChaperoneHapticFeedback
= isChaperoneHapticFeedbackEnabled(); = isChaperoneHapticFeedbackEnabled();
profile->chaperoneHapticFeedbackDistance profile->chaperoneHapticFeedbackDistance
= m_chaperoneHapticFeedbackDistance; = chaperoneHapticFeedbackDistance();
profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled(); profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled();
profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping(); profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping();
profile->chaperoneAlarmSoundAdjustVolume profile->chaperoneAlarmSoundAdjustVolume
@@ -139,7 +139,6 @@ private:
bool m_chaperoneSwitchToBeginnerActive = false; bool m_chaperoneSwitchToBeginnerActive = false;
int32_t m_chaperoneSwitchToBeginnerLastStyle = 0; int32_t m_chaperoneSwitchToBeginnerLastStyle = 0;
float m_chaperoneHapticFeedbackDistance = 0.5f;
bool m_chaperoneHapticFeedbackActive = false; bool m_chaperoneHapticFeedbackActive = false;
std::thread m_chaperoneHapticFeedbackThread; std::thread m_chaperoneHapticFeedbackThread;