Move remaining PttController items into AudioTabController

This commit is contained in:
Vasily
2020-01-16 00:09:09 +01:00
committed by username223
parent ba4a19217d
commit 7be55a2199
5 changed files with 145 additions and 191 deletions
-2
View File
@@ -8,7 +8,6 @@ SOURCES += src/main.cpp\
src/tabcontrollers/StatisticsTabController.cpp \
src/tabcontrollers/SteamVRTabController.cpp \
src/tabcontrollers/UtilitiesTabController.cpp \
src/tabcontrollers/PttController.cpp \
src/tabcontrollers/VideoTabController.cpp \
src/utils/ChaperoneUtils.cpp \
src/openvr/openvr_init.cpp \
@@ -33,7 +32,6 @@ HEADERS += src/overlaycontroller.h \
src/tabcontrollers/UtilitiesTabController.h \
src/tabcontrollers/VideoTabController.h \
src/tabcontrollers/AudioManager.h \
src/tabcontrollers/PttController.h \
src/keyboard_input/keyboard_input.h \
src/media_keys/media_keys.h \
src/utils/Matrix.h \
+104
View File
@@ -1316,4 +1316,108 @@ void AudioTabController::shutdown()
LOG( INFO ) << "Audio Tab Controller Has Shut Down";
}
bool AudioTabController::pttEnabled() const
{
return m_pttEnabled;
}
bool AudioTabController::pttActive() const
{
return m_pttActive;
}
bool AudioTabController::pttShowNotification() const
{
return m_pttShowNotification;
}
void AudioTabController::reloadPttConfig()
{
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
auto settings = OverlayController::appSettings();
settings->beginGroup( getSettingsName() );
setPttEnabled(
settings->value( "pttEnabled", false ).toBool(), true, false );
setPttShowNotification(
settings->value( "pttShowNotification", true ).toBool(), true, false );
settings->endGroup();
}
void AudioTabController::savePttConfig()
{
auto settings = OverlayController::appSettings();
settings->beginGroup( getSettingsName() );
settings->setValue( "pttEnabled", pttEnabled() );
settings->setValue( "pttShowNotification", pttShowNotification() );
settings->endGroup();
}
void AudioTabController::startPtt()
{
m_pttActive = true;
onPttStart();
if ( m_pttShowNotification
&& getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid )
{
vr::VROverlay()->ShowOverlay( getNotificationOverlayHandle() );
}
emit pttActiveChanged( m_pttActive );
}
void AudioTabController::stopPtt()
{
m_pttActive = false;
onPttStop();
if ( m_pttShowNotification
&& getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid )
{
vr::VROverlay()->HideOverlay( getNotificationOverlayHandle() );
}
emit pttActiveChanged( m_pttActive );
}
void AudioTabController::setPttEnabled( bool value, bool notify, bool save )
{
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
if ( value != m_pttEnabled )
{
m_pttEnabled = value;
if ( value )
{
onPttEnabled();
}
else
{
onPttDisabled();
}
if ( notify )
{
emit pttEnabledChanged( value );
}
if ( save )
{
savePttConfig();
}
}
}
void AudioTabController::setPttShowNotification( bool value,
bool notify,
bool save )
{
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
if ( value != m_pttShowNotification )
{
m_pttShowNotification = value;
if ( notify )
{
emit pttShowNotificationChanged( value );
}
if ( save )
{
savePttConfig();
}
}
}
} // namespace advsettings
+41 -10
View File
@@ -1,9 +1,9 @@
#pragma once
#include <QObject>
#include <mutex>
#include "AudioManager.h"
#include "PttController.h"
#include <memory>
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
@@ -29,7 +29,7 @@ struct AudioProfile
bool defaultProfile = false;
};
class AudioTabController : public PttController
class AudioTabController : public QObject
{
Q_OBJECT
Q_PROPERTY( int playbackDeviceIndex READ playbackDeviceIndex WRITE
@@ -58,6 +58,12 @@ class AudioTabController : public PttController
Q_PROPERTY( bool recordingOverride READ recordingOverride WRITE
setRecordingOverride NOTIFY recordingOverrideChanged )
Q_PROPERTY( bool pttEnabled READ pttEnabled WRITE setPttEnabled NOTIFY
pttEnabledChanged )
Q_PROPERTY( bool pttActive READ pttActive NOTIFY pttActiveChanged )
Q_PROPERTY( bool pttShowNotification READ pttShowNotification WRITE
setPttShowNotification NOTIFY pttShowNotificationChanged )
private:
vr::VROverlayHandle_t m_ulNotificationOverlayHandle
= vr::k_ulOverlayHandleInvalid;
@@ -81,21 +87,27 @@ private:
unsigned settingsUpdateCounter = 0;
bool m_pttEnabled = false;
bool m_pttActive = false;
bool m_pttShowNotification = false;
std::unique_ptr<AudioManager> audioManager;
std::vector<std::pair<std::string, std::string>> m_recordingDevices;
std::vector<std::pair<std::string, std::string>> m_playbackDevices;
std::string lastMirrorDevId;
QString getSettingsName() override
std::recursive_mutex eventLoopMutex;
QString getSettingsName()
{
return "audioSettings";
}
void onPttStart() override;
void onPttStop() override;
void onPttEnabled() override;
void onPttDisabled() override;
void onPttStart();
void onPttStop();
void onPttEnabled();
void onPttDisabled();
virtual vr::VROverlayHandle_t getNotificationOverlayHandle() override
virtual vr::VROverlayHandle_t getNotificationOverlayHandle()
{
return m_ulNotificationOverlayHandle;
}
@@ -167,6 +179,16 @@ public:
void onDeviceStateChanged();
void shutdown();
bool pttEnabled() const;
bool pttActive() const;
bool pttShowNotification() const;
void startPtt();
void stopPtt();
void reloadPttConfig();
void savePttConfig();
public slots:
void setMirrorVolume( float value, bool notify = true );
void setMirrorMuted( bool value, bool notify = true );
@@ -189,6 +211,11 @@ 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 );
signals:
void playbackDeviceIndexChanged( int index );
@@ -213,5 +240,9 @@ signals:
void recordingOverrideChanged();
void defaultProfileDisplay();
void pttEnabledChanged( bool value );
void pttActiveChanged( bool value );
void pttShowNotificationChanged( bool value );
};
} // namespace advsettings
-111
View File
@@ -1,111 +0,0 @@
#include "PttController.h"
#include <QQuickWindow>
#include <QApplication>
#include "../overlaycontroller.h"
// application namespace
namespace advsettings
{
bool PttController::pttEnabled() const
{
return m_pttEnabled;
}
bool PttController::pttActive() const
{
return m_pttActive;
}
bool PttController::pttShowNotification() const
{
return m_pttShowNotification;
}
void PttController::reloadPttConfig()
{
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
auto settings = OverlayController::appSettings();
settings->beginGroup( getSettingsName() );
setPttEnabled(
settings->value( "pttEnabled", false ).toBool(), true, false );
setPttShowNotification(
settings->value( "pttShowNotification", true ).toBool(), true, false );
settings->endGroup();
}
void PttController::savePttConfig()
{
auto settings = OverlayController::appSettings();
settings->beginGroup( getSettingsName() );
settings->setValue( "pttEnabled", pttEnabled() );
settings->setValue( "pttShowNotification", pttShowNotification() );
settings->endGroup();
}
void PttController::startPtt()
{
m_pttActive = true;
onPttStart();
if ( m_pttShowNotification
&& getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid )
{
vr::VROverlay()->ShowOverlay( getNotificationOverlayHandle() );
}
emit pttActiveChanged( m_pttActive );
}
void PttController::stopPtt()
{
m_pttActive = false;
onPttStop();
if ( m_pttShowNotification
&& getNotificationOverlayHandle() != vr::k_ulOverlayHandleInvalid )
{
vr::VROverlay()->HideOverlay( getNotificationOverlayHandle() );
}
emit pttActiveChanged( m_pttActive );
}
void PttController::setPttEnabled( bool value, bool notify, bool save )
{
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
if ( value != m_pttEnabled )
{
m_pttEnabled = value;
if ( value )
{
onPttEnabled();
}
else
{
onPttDisabled();
}
if ( notify )
{
emit pttEnabledChanged( value );
}
if ( save )
{
savePttConfig();
}
}
}
void PttController::setPttShowNotification( bool value, bool notify, bool save )
{
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
if ( value != m_pttShowNotification )
{
m_pttShowNotification = value;
if ( notify )
{
emit pttShowNotificationChanged( value );
}
if ( save )
{
savePttConfig();
}
}
}
} // namespace advsettings
-68
View File
@@ -1,68 +0,0 @@
#pragma once
#include <QObject>
#include <QString>
#include <QVariant>
#include <string>
#include <mutex>
#include <openvr.h>
class QQuickWindow;
// application namespace
namespace advsettings
{
// forward declaration
class OverlayController;
class PttController : public QObject
{
Q_OBJECT
Q_PROPERTY( bool pttEnabled READ pttEnabled WRITE setPttEnabled NOTIFY
pttEnabledChanged )
Q_PROPERTY( bool pttActive READ pttActive NOTIFY pttActiveChanged )
Q_PROPERTY( bool pttShowNotification READ pttShowNotification WRITE
setPttShowNotification NOTIFY pttShowNotificationChanged )
protected:
bool m_pttEnabled = false;
bool m_pttActive = false;
bool m_pttShowNotification = false;
protected:
virtual QString getSettingsName() = 0;
virtual void onPttStart() {}
virtual void onPttStop() {}
virtual void onPttEnabled() {}
virtual void onPttDisabled() {}
virtual vr::VROverlayHandle_t getNotificationOverlayHandle()
{
return vr::k_ulOverlayHandleInvalid;
}
std::recursive_mutex eventLoopMutex;
public:
bool pttEnabled() const;
bool pttActive() const;
bool pttShowNotification() const;
void startPtt();
void stopPtt();
void reloadPttConfig();
void savePttConfig();
public slots:
void setPttEnabled( bool value, bool notify = true, bool save = true );
void setPttShowNotification( bool value,
bool notify = true,
bool save = true );
signals:
void pttEnabledChanged( bool value );
void pttActiveChanged( bool value );
void pttShowNotificationChanged( bool value );
};
} // namespace advsettings