Convert m_chaperoneShowDashboardDistance to new settings API

This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 292398fd98
commit 0c07f0c207
3 changed files with 11 additions and 17 deletions
+1 -1
View File
@@ -378,7 +378,7 @@ private:
0.5 }, 0.5 },
DoubleSettingValue{ DoubleSetting::CHAPERONE_showDashboardDistance, DoubleSettingValue{ DoubleSetting::CHAPERONE_showDashboardDistance,
SettingCategory::Video, SettingCategory::Video,
QtInfo{ "showDashboardDistance" }, QtInfo{ "chaperoneShowDashboardDistance" },
0.5 }, 0.5 },
DoubleSettingValue{ DoubleSetting::CHAPERONE_fadeDistanceRemembered, DoubleSettingValue{ DoubleSetting::CHAPERONE_fadeDistanceRemembered,
SettingCategory::Chaperone, SettingCategory::Chaperone,
+10 -15
View File
@@ -11,8 +11,6 @@ void ChaperoneTabController::initStage1()
{ {
auto settings = OverlayController::appSettings(); auto settings = OverlayController::appSettings();
settings->beginGroup( "chaperoneSettings" ); settings->beginGroup( "chaperoneSettings" );
m_chaperoneShowDashboardDistance
= settings->value( "chaperoneShowDashboardDistance", 0.5f ).toFloat();
m_fadeDistanceRemembered m_fadeDistanceRemembered
= settings->value( "fadeDistanceRemembered", 0.5f ).toFloat(); = settings->value( "fadeDistanceRemembered", 0.5f ).toFloat();
settings->endGroup(); settings->endGroup();
@@ -515,7 +513,7 @@ void ChaperoneTabController::handleChaperoneWarnings( float distance )
// Show Dashboard // Show Dashboard
if ( isChaperoneShowDashboardEnabled() ) if ( isChaperoneShowDashboardEnabled() )
{ {
float activationDistance = m_chaperoneShowDashboardDistance; float activationDistance = chaperoneShowDashboardDistance();
if ( distance <= activationDistance && !m_chaperoneShowDashboardActive ) if ( distance <= activationDistance && !m_chaperoneShowDashboardActive )
{ {
if ( !vr::VROverlay()->IsDashboardVisible() ) if ( !vr::VROverlay()->IsDashboardVisible() )
@@ -885,7 +883,8 @@ bool ChaperoneTabController::isChaperoneShowDashboardEnabled() const
float ChaperoneTabController::chaperoneShowDashboardDistance() const float ChaperoneTabController::chaperoneShowDashboardDistance() const
{ {
return m_chaperoneShowDashboardDistance; return static_cast<float>( settings::getSetting(
settings::DoubleSetting::CHAPERONE_showDashboardDistance ) );
} }
Q_INVOKABLE unsigned ChaperoneTabController::getChaperoneProfileCount() Q_INVOKABLE unsigned ChaperoneTabController::getChaperoneProfileCount()
@@ -1119,20 +1118,16 @@ void ChaperoneTabController::setChaperoneShowDashboardEnabled( bool value,
void ChaperoneTabController::setChaperoneShowDashboardDistance( float value, void ChaperoneTabController::setChaperoneShowDashboardDistance( float value,
bool notify ) bool notify )
{ {
if ( fabs( static_cast<double>( m_chaperoneShowDashboardDistance - value ) ) if ( fabs( static_cast<double>( chaperoneShowDashboardDistance() - value ) )
> 0.005 ) > 0.005 )
{ {
m_chaperoneShowDashboardDistance = value; settings::setSetting(
auto settings = OverlayController::appSettings(); settings::DoubleSetting::CHAPERONE_showDashboardDistance,
settings->beginGroup( "chaperoneSettings" ); static_cast<double>( value ) );
settings->setValue( "chaperoneShowDashboardDistance",
m_chaperoneShowDashboardDistance );
settings->endGroup();
settings->sync();
if ( notify ) if ( notify )
{ {
emit chaperoneShowDashboardDistanceChanged( emit chaperoneShowDashboardDistanceChanged( value );
m_chaperoneShowDashboardDistance );
} }
} }
} }
@@ -1350,7 +1345,7 @@ void ChaperoneTabController::addChaperoneProfile(
profile->enableChaperoneShowDashboard profile->enableChaperoneShowDashboard
= isChaperoneShowDashboardEnabled(); = isChaperoneShowDashboardEnabled();
profile->chaperoneShowDashboardDistance profile->chaperoneShowDashboardDistance
= m_chaperoneShowDashboardDistance; = chaperoneShowDashboardDistance();
} }
saveChaperoneProfiles(); saveChaperoneProfiles();
OverlayController::appSettings()->sync(); OverlayController::appSettings()->sync();
@@ -144,7 +144,6 @@ private:
bool m_chaperoneAlarmSoundActive = false; bool m_chaperoneAlarmSoundActive = false;
float m_chaperoneShowDashboardDistance = 0.5f;
bool m_chaperoneShowDashboardActive = false; bool m_chaperoneShowDashboardActive = false;
unsigned settingsUpdateCounter = 0; unsigned settingsUpdateCounter = 0;