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_chaperoneSwitchToBeginnerEnabled,
CHAPERONE_chaperoneHapticFeedbackEnabled, CHAPERONE_chaperoneHapticFeedbackEnabled,
CHAPERONE_chaperoneAlarmSoundEnabled,
CHAPERONE_disableChaperone, CHAPERONE_disableChaperone,
// LAST_ENUMERATOR must always be set to the last value // LAST_ENUMERATOR must always be set to the last value
LAST_ENUMERATOR = CHAPERONE_disableChaperone, LAST_ENUMERATOR = CHAPERONE_disableChaperone,
+4
View File
@@ -284,6 +284,10 @@ private:
SettingCategory::Chaperone, SettingCategory::Chaperone,
QtInfo{ "chaperoneHapticFeedbackEnabled" }, QtInfo{ "chaperoneHapticFeedbackEnabled" },
false }, false },
BoolSettingValue{ BoolSetting::CHAPERONE_chaperoneAlarmSoundEnabled,
SettingCategory::Chaperone,
QtInfo{ "chaperoneAlarmSoundEnabled" },
false },
BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone, BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone,
SettingCategory::Chaperone, SettingCategory::Chaperone,
QtInfo{ "disableChaperone" }, QtInfo{ "disableChaperone" },
+12 -16
View File
@@ -16,8 +16,6 @@ void ChaperoneTabController::initStage1()
.toFloat(); .toFloat();
m_chaperoneHapticFeedbackDistance m_chaperoneHapticFeedbackDistance
= settings->value( "chaperoneHapticFeedbackDistance", 0.5f ).toFloat(); = settings->value( "chaperoneHapticFeedbackDistance", 0.5f ).toFloat();
m_enableChaperoneAlarmSound
= settings->value( "chaperoneAlarmSoundEnabled", false ).toBool();
m_chaperoneAlarmSoundLooping m_chaperoneAlarmSoundLooping
= settings->value( "chaperoneAlarmSoundLooping", true ).toBool(); = settings->value( "chaperoneAlarmSoundLooping", true ).toBool();
m_chaperoneAlarmSoundAdjustVolume m_chaperoneAlarmSoundAdjustVolume
@@ -493,7 +491,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
} }
// Alarm Sound // Alarm Sound
if ( m_enableChaperoneAlarmSound ) if ( isChaperoneAlarmSoundEnabled() )
{ {
// LOG(WARNING) << "In alarm"; // LOG(WARNING) << "In alarm";
float activationDistance = m_chaperoneAlarmSoundDistance; float activationDistance = m_chaperoneAlarmSoundDistance;
@@ -863,7 +861,8 @@ float ChaperoneTabController::chaperoneHapticFeedbackDistance() const
bool ChaperoneTabController::isChaperoneAlarmSoundEnabled() const bool ChaperoneTabController::isChaperoneAlarmSoundEnabled() const
{ {
return m_enableChaperoneAlarmSound; return settings::getSetting(
settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundEnabled );
} }
bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const
@@ -1034,24 +1033,21 @@ void ChaperoneTabController::setChaperoneHapticFeedbackDistance( float value,
void ChaperoneTabController::setChaperoneAlarmSoundEnabled( bool value, void ChaperoneTabController::setChaperoneAlarmSoundEnabled( bool value,
bool notify ) bool notify )
{ {
if ( m_enableChaperoneAlarmSound != value ) if ( isChaperoneAlarmSoundEnabled() != value )
{ {
if ( !value && m_chaperoneAlarmSoundActive ) if ( !value && m_chaperoneAlarmSoundActive )
{ {
parent->cancelAlarm01Sound(); parent->cancelAlarm01Sound();
} }
m_enableChaperoneAlarmSound = value;
m_chaperoneAlarmSoundActive = false; m_chaperoneAlarmSoundActive = false;
auto settings = OverlayController::appSettings();
settings->beginGroup( "chaperoneSettings" ); settings::setSetting(
settings->setValue( "chaperoneAlarmSoundEnabled", settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundEnabled,
m_enableChaperoneAlarmSound ); value );
settings->endGroup();
settings->sync();
if ( notify ) if ( notify )
{ {
emit chaperoneAlarmSoundEnabledChanged( emit chaperoneAlarmSoundEnabledChanged( value );
m_enableChaperoneAlarmSound );
} }
} }
} }
@@ -1062,7 +1058,7 @@ void ChaperoneTabController::setChaperoneAlarmSoundLooping( bool value,
if ( m_chaperoneAlarmSoundLooping != value ) if ( m_chaperoneAlarmSoundLooping != value )
{ {
m_chaperoneAlarmSoundLooping = value; m_chaperoneAlarmSoundLooping = value;
if ( m_enableChaperoneAlarmSound && m_chaperoneAlarmSoundActive ) if ( isChaperoneAlarmSoundEnabled() && m_chaperoneAlarmSoundActive )
{ {
if ( m_chaperoneAlarmSoundLooping ) if ( m_chaperoneAlarmSoundLooping )
{ {
@@ -1373,7 +1369,7 @@ void ChaperoneTabController::addChaperoneProfile(
= isChaperoneHapticFeedbackEnabled(); = isChaperoneHapticFeedbackEnabled();
profile->chaperoneHapticFeedbackDistance profile->chaperoneHapticFeedbackDistance
= m_chaperoneHapticFeedbackDistance; = m_chaperoneHapticFeedbackDistance;
profile->enableChaperoneAlarmSound = m_enableChaperoneAlarmSound; profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled();
profile->chaperoneAlarmSoundLooping = m_chaperoneAlarmSoundLooping; profile->chaperoneAlarmSoundLooping = m_chaperoneAlarmSoundLooping;
profile->chaperoneAlarmSoundAdjustVolume profile->chaperoneAlarmSoundAdjustVolume
= m_chaperoneAlarmSoundAdjustVolume; = m_chaperoneAlarmSoundAdjustVolume;
@@ -145,7 +145,6 @@ private:
bool m_chaperoneHapticFeedbackActive = false; bool m_chaperoneHapticFeedbackActive = false;
std::thread m_chaperoneHapticFeedbackThread; std::thread m_chaperoneHapticFeedbackThread;
bool m_enableChaperoneAlarmSound = false;
bool m_chaperoneAlarmSoundLooping = true; bool m_chaperoneAlarmSoundLooping = true;
bool m_chaperoneAlarmSoundAdjustVolume = false; bool m_chaperoneAlarmSoundAdjustVolume = false;
float m_chaperoneAlarmSoundDistance = 0.5f; float m_chaperoneAlarmSoundDistance = 0.5f;