Convert m_enableChaperoneAlarmSound to new settings API

This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 4011674b0f
commit 54022e0438
4 changed files with 17 additions and 17 deletions
+1
View File
@@ -42,6 +42,7 @@ enum class BoolSetting
CHAPERONE_chaperoneSwitchToBeginnerEnabled,
CHAPERONE_chaperoneHapticFeedbackEnabled,
CHAPERONE_chaperoneAlarmSoundEnabled,
CHAPERONE_disableChaperone,
// LAST_ENUMERATOR must always be set to the last value
LAST_ENUMERATOR = CHAPERONE_disableChaperone,
+4
View File
@@ -284,6 +284,10 @@ private:
SettingCategory::Chaperone,
QtInfo{ "chaperoneHapticFeedbackEnabled" },
false },
BoolSettingValue{ BoolSetting::CHAPERONE_chaperoneAlarmSoundEnabled,
SettingCategory::Chaperone,
QtInfo{ "chaperoneAlarmSoundEnabled" },
false },
BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone,
SettingCategory::Chaperone,
QtInfo{ "disableChaperone" },
+12 -16
View File
@@ -16,8 +16,6 @@ void ChaperoneTabController::initStage1()
.toFloat();
m_chaperoneHapticFeedbackDistance
= settings->value( "chaperoneHapticFeedbackDistance", 0.5f ).toFloat();
m_enableChaperoneAlarmSound
= settings->value( "chaperoneAlarmSoundEnabled", false ).toBool();
m_chaperoneAlarmSoundLooping
= settings->value( "chaperoneAlarmSoundLooping", true ).toBool();
m_chaperoneAlarmSoundAdjustVolume
@@ -493,7 +491,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
}
// Alarm Sound
if ( m_enableChaperoneAlarmSound )
if ( isChaperoneAlarmSoundEnabled() )
{
// LOG(WARNING) << "In alarm";
float activationDistance = m_chaperoneAlarmSoundDistance;
@@ -863,7 +861,8 @@ float ChaperoneTabController::chaperoneHapticFeedbackDistance() const
bool ChaperoneTabController::isChaperoneAlarmSoundEnabled() const
{
return m_enableChaperoneAlarmSound;
return settings::getSetting(
settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundEnabled );
}
bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const
@@ -1034,24 +1033,21 @@ void ChaperoneTabController::setChaperoneHapticFeedbackDistance( float value,
void ChaperoneTabController::setChaperoneAlarmSoundEnabled( bool value,
bool notify )
{
if ( m_enableChaperoneAlarmSound != value )
if ( isChaperoneAlarmSoundEnabled() != value )
{
if ( !value && m_chaperoneAlarmSoundActive )
{
parent->cancelAlarm01Sound();
}
m_enableChaperoneAlarmSound = value;
m_chaperoneAlarmSoundActive = false;
auto settings = OverlayController::appSettings();
settings->beginGroup( "chaperoneSettings" );
settings->setValue( "chaperoneAlarmSoundEnabled",
m_enableChaperoneAlarmSound );
settings->endGroup();
settings->sync();
settings::setSetting(
settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundEnabled,
value );
if ( notify )
{
emit chaperoneAlarmSoundEnabledChanged(
m_enableChaperoneAlarmSound );
emit chaperoneAlarmSoundEnabledChanged( value );
}
}
}
@@ -1062,7 +1058,7 @@ void ChaperoneTabController::setChaperoneAlarmSoundLooping( bool value,
if ( m_chaperoneAlarmSoundLooping != value )
{
m_chaperoneAlarmSoundLooping = value;
if ( m_enableChaperoneAlarmSound && m_chaperoneAlarmSoundActive )
if ( isChaperoneAlarmSoundEnabled() && m_chaperoneAlarmSoundActive )
{
if ( m_chaperoneAlarmSoundLooping )
{
@@ -1373,7 +1369,7 @@ void ChaperoneTabController::addChaperoneProfile(
= isChaperoneHapticFeedbackEnabled();
profile->chaperoneHapticFeedbackDistance
= m_chaperoneHapticFeedbackDistance;
profile->enableChaperoneAlarmSound = m_enableChaperoneAlarmSound;
profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled();
profile->chaperoneAlarmSoundLooping = m_chaperoneAlarmSoundLooping;
profile->chaperoneAlarmSoundAdjustVolume
= m_chaperoneAlarmSoundAdjustVolume;
@@ -145,7 +145,6 @@ private:
bool m_chaperoneHapticFeedbackActive = false;
std::thread m_chaperoneHapticFeedbackThread;
bool m_enableChaperoneAlarmSound = false;
bool m_chaperoneAlarmSoundLooping = true;
bool m_chaperoneAlarmSoundAdjustVolume = false;
float m_chaperoneAlarmSoundDistance = 0.5f;