Convert m_chaperoneAlarmSoundAdjustVolume to new settings API

This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 3632fc03d5
commit b6f0e22770
4 changed files with 16 additions and 16 deletions
+1
View File
@@ -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,
+5
View File
@@ -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" },
+10 -15
View File
@@ -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
@@ -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;