Convert m_chaperoneAlarmSoundDistance to new settings API

This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 13c8eabeb0
commit 292398fd98
3 changed files with 11 additions and 17 deletions
+1 -1
View File
@@ -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,
+10 -15
View File
@@ -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<float>( 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<double>( m_chaperoneAlarmSoundDistance - value ) )
if ( fabs( static_cast<double>( 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<double>( 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
@@ -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;