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_chaperoneHapticFeedbackEnabled,
CHAPERONE_chaperoneAlarmSoundEnabled, CHAPERONE_chaperoneAlarmSoundEnabled,
CHAPERONE_chaperoneAlarmSoundLooping, CHAPERONE_chaperoneAlarmSoundLooping,
CHAPERONE_chaperoneAlarmSoundAdjustVolume,
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,
+5
View File
@@ -292,6 +292,11 @@ private:
SettingCategory::Chaperone, SettingCategory::Chaperone,
QtInfo{ "chaperoneAlarmSoundLooping" }, QtInfo{ "chaperoneAlarmSoundLooping" },
true }, true },
BoolSettingValue{
BoolSetting::CHAPERONE_chaperoneAlarmSoundAdjustVolume,
SettingCategory::Chaperone,
QtInfo{ "chaperoneAlarmSoundAdjustVolume" },
false },
BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone, BoolSettingValue{ BoolSetting::CHAPERONE_disableChaperone,
SettingCategory::Chaperone, SettingCategory::Chaperone,
QtInfo{ "disableChaperone" }, QtInfo{ "disableChaperone" },
+10 -15
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_chaperoneAlarmSoundAdjustVolume
= settings->value( "chaperoneAlarmSoundAdjustVolume", false ).toBool();
m_chaperoneAlarmSoundDistance m_chaperoneAlarmSoundDistance
= settings->value( "chaperoneAlarmSoundDistance", 0.5f ).toFloat(); = settings->value( "chaperoneAlarmSoundDistance", 0.5f ).toFloat();
m_enableChaperoneShowDashboard m_enableChaperoneShowDashboard
@@ -502,7 +500,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
m_chaperoneAlarmSoundActive = true; m_chaperoneAlarmSoundActive = true;
} }
if ( isChaperoneAlarmSoundLooping() if ( isChaperoneAlarmSoundLooping()
&& m_chaperoneAlarmSoundAdjustVolume ) && isChaperoneAlarmSoundAdjustVolume() )
{ {
float vol = 1.1f - distance / activationDistance; float vol = 1.1f - distance / activationDistance;
if ( vol > 1.0f ) if ( vol > 1.0f )
@@ -871,7 +869,8 @@ bool ChaperoneTabController::isChaperoneAlarmSoundLooping() const
bool ChaperoneTabController::isChaperoneAlarmSoundAdjustVolume() const bool ChaperoneTabController::isChaperoneAlarmSoundAdjustVolume() const
{ {
return m_chaperoneAlarmSoundAdjustVolume; return settings::getSetting(
settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundAdjustVolume );
} }
bool ChaperoneTabController::disableChaperone() const bool ChaperoneTabController::disableChaperone() const
@@ -1082,19 +1081,15 @@ void ChaperoneTabController::setChaperoneAlarmSoundLooping( bool value,
void ChaperoneTabController::setChaperoneAlarmSoundAdjustVolume( bool value, void ChaperoneTabController::setChaperoneAlarmSoundAdjustVolume( bool value,
bool notify ) bool notify )
{ {
if ( m_chaperoneAlarmSoundAdjustVolume != value ) if ( isChaperoneAlarmSoundAdjustVolume() != value )
{ {
m_chaperoneAlarmSoundAdjustVolume = value; settings::setSetting(
auto settings = OverlayController::appSettings(); settings::BoolSetting::CHAPERONE_chaperoneAlarmSoundAdjustVolume,
settings->beginGroup( "chaperoneSettings" ); value );
settings->setValue( "chaperoneAlarmSoundAdjustVolume",
m_chaperoneAlarmSoundAdjustVolume );
settings->endGroup();
settings->sync();
if ( notify ) if ( notify )
{ {
emit chaperoneAlarmSoundAdjustVolumeChanged( emit chaperoneAlarmSoundAdjustVolumeChanged( value );
m_chaperoneAlarmSoundAdjustVolume );
} }
} }
} }
@@ -1368,7 +1363,7 @@ void ChaperoneTabController::addChaperoneProfile(
profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled(); profile->enableChaperoneAlarmSound = isChaperoneAlarmSoundEnabled();
profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping(); profile->chaperoneAlarmSoundLooping = isChaperoneAlarmSoundLooping();
profile->chaperoneAlarmSoundAdjustVolume profile->chaperoneAlarmSoundAdjustVolume
= m_chaperoneAlarmSoundAdjustVolume; = isChaperoneAlarmSoundAdjustVolume();
profile->chaperoneAlarmSoundDistance = m_chaperoneAlarmSoundDistance; profile->chaperoneAlarmSoundDistance = m_chaperoneAlarmSoundDistance;
profile->enableChaperoneShowDashboard = m_enableChaperoneShowDashboard; profile->enableChaperoneShowDashboard = m_enableChaperoneShowDashboard;
profile->chaperoneShowDashboardDistance profile->chaperoneShowDashboardDistance
@@ -145,7 +145,6 @@ private:
bool m_chaperoneHapticFeedbackActive = false; bool m_chaperoneHapticFeedbackActive = false;
std::thread m_chaperoneHapticFeedbackThread; std::thread m_chaperoneHapticFeedbackThread;
bool m_chaperoneAlarmSoundAdjustVolume = false;
float m_chaperoneAlarmSoundDistance = 0.5f; float m_chaperoneAlarmSoundDistance = 0.5f;
bool m_chaperoneAlarmSoundActive = false; bool m_chaperoneAlarmSoundActive = false;