diff --git a/src/settings/settings.h b/src/settings/settings.h index 445d593..46046e7 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -44,6 +44,7 @@ enum class BoolSetting CHAPERONE_chaperoneHapticFeedbackEnabled, CHAPERONE_chaperoneAlarmSoundEnabled, CHAPERONE_chaperoneAlarmSoundLooping, + CHAPERONE_chaperoneAlarmSoundAdjustVolume, CHAPERONE_disableChaperone, // LAST_ENUMERATOR must always be set to the last value LAST_ENUMERATOR = CHAPERONE_disableChaperone, diff --git a/src/settings/settings_controller.h b/src/settings/settings_controller.h index 40fe6c5..35bb968 100644 --- a/src/settings/settings_controller.h +++ b/src/settings/settings_controller.h @@ -292,6 +292,11 @@ private: SettingCategory::Chaperone, QtInfo{ "chaperoneAlarmSoundLooping" }, true }, + BoolSettingValue{ + BoolSetting::CHAPERONE_chaperoneAlarmSoundAdjustVolume, + SettingCategory::Chaperone, + QtInfo{ "chaperoneAlarmSoundAdjustVolume" }, + false }, BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone, SettingCategory::Chaperone, QtInfo{ "disableChaperone" }, diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index 97c29dd..67a7135 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -16,8 +16,6 @@ void ChaperoneTabController::initStage1() .toFloat(); m_chaperoneHapticFeedbackDistance = settings->value( "chaperoneHapticFeedbackDistance", 0.5f ).toFloat(); - m_chaperoneAlarmSoundAdjustVolume - = settings->value( "chaperoneAlarmSoundAdjustVolume", false ).toBool(); m_chaperoneAlarmSoundDistance = settings->value( "chaperoneAlarmSoundDistance", 0.5f ).toFloat(); m_enableChaperoneShowDashboard @@ -502,7 +500,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance ) m_chaperoneAlarmSoundActive = true; } if ( isChaperoneAlarmSoundLooping() - && m_chaperoneAlarmSoundAdjustVolume ) + && isChaperoneAlarmSoundAdjustVolume() ) { float vol = 1.1f - distance / activationDistance; if ( vol > 1.0f ) @@ -871,7 +869,8 @@ bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const bool ChaperoneTabController::isChaperoneAlarmSoundAdjustVolume() const { - return m_chaperoneAlarmSoundAdjustVolume; + return settings::getSetting( + settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundAdjustVolume ); } bool ChaperoneTabController::disableChaperone() const @@ -1082,19 +1081,15 @@ void ChaperoneTabController::setChaperoneAlarmSoundLooping( bool value, void ChaperoneTabController::setChaperoneAlarmSoundAdjustVolume( bool value, bool notify ) { - if ( m_chaperoneAlarmSoundAdjustVolume != value ) + if ( isChaperoneAlarmSoundAdjustVolume() != value ) { - m_chaperoneAlarmSoundAdjustVolume = value; - auto settings = OverlayController::appSettings(); - settings->beginGroup( "chaperoneSettings" ); - settings->setValue( "chaperoneAlarmSoundAdjustVolume", - m_chaperoneAlarmSoundAdjustVolume ); - settings->endGroup(); - settings->sync(); + settings::setSetting( + settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundAdjustVolume, + value ); + if ( notify ) { - emit chaperoneAlarmSoundAdjustVolumeChanged( - m_chaperoneAlarmSoundAdjustVolume ); + emit chaperoneAlarmSoundAdjustVolumeChanged( value ); } } } @@ -1368,7 +1363,7 @@ void ChaperoneTabController::addChaperoneProfile( profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled(); profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping(); profile->chaperoneAlarmSoundAdjustVolume - = m_chaperoneAlarmSoundAdjustVolume; + = isChaperoneAlarmSoundAdjustVolume(); profile->chaperoneAlarmSoundDistance = m_chaperoneAlarmSoundDistance; profile->enableChaperoneShowDashboard = m_enableChaperoneShowDashboard; profile->chaperoneShowDashboardDistance diff --git a/src/tabcontrollers/ChaperoneTabController.h b/src/tabcontrollers/ChaperoneTabController.h index 02b8765..f1472ac 100644 --- a/src/tabcontrollers/ChaperoneTabController.h +++ b/src/tabcontrollers/ChaperoneTabController.h @@ -145,7 +145,6 @@ private: bool m_chaperoneHapticFeedbackActive = false; std::thread m_chaperoneHapticFeedbackThread; - bool m_chaperoneAlarmSoundAdjustVolume = false; float m_chaperoneAlarmSoundDistance = 0.5f; bool m_chaperoneAlarmSoundActive = false;