Convert m_chaperoneAlarmSoundLooping to new settings API

This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 54022e0438
commit 3632fc03d5
4 changed files with 19 additions and 19 deletions
+1
View File
@@ -43,6 +43,7 @@ enum class BoolSetting
CHAPERONE_chaperoneSwitchToBeginnerEnabled, CHAPERONE_chaperoneSwitchToBeginnerEnabled,
CHAPERONE_chaperoneHapticFeedbackEnabled, CHAPERONE_chaperoneHapticFeedbackEnabled,
CHAPERONE_chaperoneAlarmSoundEnabled, CHAPERONE_chaperoneAlarmSoundEnabled,
CHAPERONE_chaperoneAlarmSoundLooping,
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
@@ -288,6 +288,10 @@ private:
SettingCategory::Chaperone, SettingCategory::Chaperone,
QtInfo{ "chaperoneAlarmSoundEnabled" }, QtInfo{ "chaperoneAlarmSoundEnabled" },
false }, false },
BoolSettingValue{ BoolSetting::CHAPERONE_chaperoneAlarmSoundLooping,
SettingCategory::Chaperone,
QtInfo{ "chaperoneAlarmSoundLooping" },
true },
BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone, BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone,
SettingCategory::Chaperone, SettingCategory::Chaperone,
QtInfo{ "disableChaperone" }, QtInfo{ "disableChaperone" },
+14 -18
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_chaperoneAlarmSoundLooping
= settings->value( "chaperoneAlarmSoundLooping", true ).toBool();
m_chaperoneAlarmSoundAdjustVolume m_chaperoneAlarmSoundAdjustVolume
= settings->value( "chaperoneAlarmSoundAdjustVolume", false ).toBool(); = settings->value( "chaperoneAlarmSoundAdjustVolume", false ).toBool();
m_chaperoneAlarmSoundDistance m_chaperoneAlarmSoundDistance
@@ -500,10 +498,10 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
{ {
if ( !m_chaperoneAlarmSoundActive ) if ( !m_chaperoneAlarmSoundActive )
{ {
parent->playAlarm01Sound( m_chaperoneAlarmSoundLooping ); parent->playAlarm01Sound( isChaperoneAlarmSoundLooping() );
m_chaperoneAlarmSoundActive = true; m_chaperoneAlarmSoundActive = true;
} }
if ( m_chaperoneAlarmSoundLooping if ( isChaperoneAlarmSoundLooping()
&& m_chaperoneAlarmSoundAdjustVolume ) && m_chaperoneAlarmSoundAdjustVolume )
{ {
float vol = 1.1f - distance / activationDistance; float vol = 1.1f - distance / activationDistance;
@@ -867,7 +865,8 @@ bool ChaperoneTabController::isChaperoneAlarmSoundEnabled() const
bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const
{ {
return m_chaperoneAlarmSoundLooping; return settings::getSetting(
settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundLooping );
} }
bool ChaperoneTabController::isChaperoneAlarmSoundAdjustVolume() const bool ChaperoneTabController::isChaperoneAlarmSoundAdjustVolume() const
@@ -1055,30 +1054,27 @@ void ChaperoneTabController::setChaperoneAlarmSoundEnabled( bool value,
void ChaperoneTabController::setChaperoneAlarmSoundLooping( bool value, void ChaperoneTabController::setChaperoneAlarmSoundLooping( bool value,
bool notify ) bool notify )
{ {
if ( m_chaperoneAlarmSoundLooping != value ) if ( isChaperoneAlarmSoundLooping() != value )
{ {
m_chaperoneAlarmSoundLooping = value;
if ( isChaperoneAlarmSoundEnabled() && m_chaperoneAlarmSoundActive ) if ( isChaperoneAlarmSoundEnabled() && m_chaperoneAlarmSoundActive )
{ {
if ( m_chaperoneAlarmSoundLooping ) if ( isChaperoneAlarmSoundLooping() )
{ {
parent->playAlarm01Sound( m_chaperoneAlarmSoundLooping ); parent->playAlarm01Sound( isChaperoneAlarmSoundLooping() );
} }
else else
{ {
parent->cancelAlarm01Sound(); parent->cancelAlarm01Sound();
} }
} }
auto settings = OverlayController::appSettings();
settings->beginGroup( "chaperoneSettings" ); settings::setSetting(
settings->setValue( "chaperoneAlarmSoundLooping", settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundLooping,
m_chaperoneAlarmSoundLooping ); value );
settings->endGroup();
settings->sync();
if ( notify ) if ( notify )
{ {
emit chaperoneAlarmSoundLoopingChanged( emit chaperoneAlarmSoundLoopingChanged( value );
m_chaperoneAlarmSoundLooping );
} }
} }
} }
@@ -1370,7 +1366,7 @@ void ChaperoneTabController::addChaperoneProfile(
profile->chaperoneHapticFeedbackDistance profile->chaperoneHapticFeedbackDistance
= m_chaperoneHapticFeedbackDistance; = m_chaperoneHapticFeedbackDistance;
profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled(); profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled();
profile->chaperoneAlarmSoundLooping = m_chaperoneAlarmSoundLooping; profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping();
profile->chaperoneAlarmSoundAdjustVolume profile->chaperoneAlarmSoundAdjustVolume
= m_chaperoneAlarmSoundAdjustVolume; = m_chaperoneAlarmSoundAdjustVolume;
profile->chaperoneAlarmSoundDistance = m_chaperoneAlarmSoundDistance; profile->chaperoneAlarmSoundDistance = m_chaperoneAlarmSoundDistance;
@@ -145,7 +145,6 @@ private:
bool m_chaperoneHapticFeedbackActive = false; bool m_chaperoneHapticFeedbackActive = false;
std::thread m_chaperoneHapticFeedbackThread; std::thread m_chaperoneHapticFeedbackThread;
bool m_chaperoneAlarmSoundLooping = true;
bool m_chaperoneAlarmSoundAdjustVolume = false; bool m_chaperoneAlarmSoundAdjustVolume = false;
float m_chaperoneAlarmSoundDistance = 0.5f; float m_chaperoneAlarmSoundDistance = 0.5f;
bool m_chaperoneAlarmSoundActive = false; bool m_chaperoneAlarmSoundActive = false;