From b8488d318d7973fdf38f4cf1297e32a97ff45422 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sun, 12 Jan 2020 00:48:27 +0100 Subject: [PATCH] Convert m_pttShowNotification to new settings API --- src/settings/internal/settings_controller.h | 4 ++ src/settings/settings.h | 1 + src/tabcontrollers/AudioTabController.cpp | 53 +++++---------------- src/tabcontrollers/AudioTabController.h | 10 +--- 4 files changed, 19 insertions(+), 49 deletions(-) diff --git a/src/settings/internal/settings_controller.h b/src/settings/internal/settings_controller.h index 7a00f7c..8f535ee 100644 --- a/src/settings/internal/settings_controller.h +++ b/src/settings/internal/settings_controller.h @@ -288,6 +288,10 @@ private: SettingCategory::Audio, QtInfo{ "pttEnabled" }, false }, + BoolSettingValue{ BoolSetting::AUDIO_pttShowNotification, + SettingCategory::Audio, + QtInfo{ "pttShowNotification" }, + false }, BoolSettingValue{ BoolSetting::AUDIO_micProximitySensorCanMute, SettingCategory::Audio, QtInfo{ "micProximitySensorCanMute" }, diff --git a/src/settings/settings.h b/src/settings/settings.h index 9952a5e..5035cbd 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -30,6 +30,7 @@ enum class BoolSetting APPLICATION_enableDebug, AUDIO_pttEnabled, + AUDIO_pttShowNotification, AUDIO_micProximitySensorCanMute, AUDIO_micReversePtt, diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index aa2d273..d13541e 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -52,7 +52,6 @@ void AudioTabController::initStage1() findMicDeviceIndex( audioManager->getMicDevId(), false ); m_micVolume = audioManager->getMicVolume(); m_micMuted = audioManager->getMicMuted(); - reloadPttConfig(); // Temporarily disabled audio profiles for 1.8.19 until api is clear. // reloadAudioProfiles(); reloadAudioSettings(); @@ -1328,32 +1327,15 @@ bool AudioTabController::pttActive() const bool AudioTabController::pttShowNotification() const { - return m_pttShowNotification; -} - -void AudioTabController::reloadPttConfig() -{ - std::lock_guard lock( eventLoopMutex ); - auto settings = OverlayController::appSettings(); - settings->beginGroup( getSettingsName() ); - setPttShowNotification( - settings->value( "pttShowNotification", true ).toBool(), true, false ); - settings->endGroup(); -} - -void AudioTabController::savePttConfig() -{ - auto settings = OverlayController::appSettings(); - settings->beginGroup( getSettingsName() ); - settings->setValue( "pttShowNotification", pttShowNotification() ); - settings->endGroup(); + return settings::getSetting( + settings::BoolSetting::AUDIO_pttShowNotification ); } void AudioTabController::startPtt() { m_pttActive = true; onPttStart(); - if ( m_pttShowNotification + if ( pttShowNotification() && getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid ) { vr::VROverlay()->ShowOverlay( getNotificationOverlayHandle() ); @@ -1365,7 +1347,7 @@ void AudioTabController::stopPtt() { m_pttActive = false; onPttStop(); - if ( m_pttShowNotification + if ( pttShowNotification() && getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid ) { vr::VROverlay()->HideOverlay( getNotificationOverlayHandle() ); @@ -1373,7 +1355,7 @@ void AudioTabController::stopPtt() emit pttActiveChanged( m_pttActive ); } -void AudioTabController::setPttEnabled( bool value, bool notify, bool save ) +void AudioTabController::setPttEnabled( bool value, bool notify ) { std::lock_guard lock( eventLoopMutex ); @@ -1392,29 +1374,18 @@ void AudioTabController::setPttEnabled( bool value, bool notify, bool save ) { emit pttEnabledChanged( value ); } - - if ( save ) - { - savePttConfig(); - } } -void AudioTabController::setPttShowNotification( bool value, - bool notify, - bool save ) +void AudioTabController::setPttShowNotification( bool value, bool notify ) { std::lock_guard lock( eventLoopMutex ); - if ( value != m_pttShowNotification ) + + settings::setSetting( settings::BoolSetting::AUDIO_pttShowNotification, + value ); + + if ( notify ) { - m_pttShowNotification = value; - if ( notify ) - { - emit pttShowNotificationChanged( value ); - } - if ( save ) - { - savePttConfig(); - } + emit pttShowNotificationChanged( value ); } } diff --git a/src/tabcontrollers/AudioTabController.h b/src/tabcontrollers/AudioTabController.h index a20dd47..b848b87 100644 --- a/src/tabcontrollers/AudioTabController.h +++ b/src/tabcontrollers/AudioTabController.h @@ -88,7 +88,6 @@ private: unsigned settingsUpdateCounter = 0; bool m_pttActive = false; - bool m_pttShowNotification = false; std::unique_ptr audioManager; std::vector> m_recordingDevices; @@ -185,9 +184,6 @@ public: void startPtt(); void stopPtt(); - void reloadPttConfig(); - void savePttConfig(); - public slots: void setMirrorVolume( float value, bool notify = true ); void setMirrorMuted( bool value, bool notify = true ); @@ -210,10 +206,8 @@ public slots: void setAudioProfileDefault( bool value, bool notify = true ); - void setPttEnabled( bool value, bool notify = true, bool save = true ); - void setPttShowNotification( bool value, - bool notify = true, - bool save = true ); + void setPttEnabled( bool value, bool notify = true ); + void setPttShowNotification( bool value, bool notify = true ); signals: void playbackDeviceIndexChanged( int index );