Merge pull request #39 from OpenVR-Advanced-Settings/refactor-singleton
Refactor OverlayController to be implemented as RAII object instead of global singleton
This commit is contained in:
+3
-11
@@ -408,16 +408,8 @@ int main( int argc, char* argv[] )
|
|||||||
|
|
||||||
// The OverlayController handles the majority of the application specfic
|
// The OverlayController handles the majority of the application specfic
|
||||||
// things. It contains all the other tabs.
|
// things. It contains all the other tabs.
|
||||||
// It is created using a singleton pattern that destructs the old
|
advsettings::OverlayController controller(
|
||||||
// instance whenever createInstance is called. This is obviously not
|
desktopMode, noSound, qmlEngine );
|
||||||
// ideal since it can lead to dangling points and use after free.
|
|
||||||
// The constructor only sets two member vars called desktopMode and
|
|
||||||
// noSound, the rest of the initialization is done in Init. It is
|
|
||||||
// unknown why this is done.
|
|
||||||
advsettings::OverlayController* controller
|
|
||||||
= advsettings::OverlayController::createInstance( desktopMode,
|
|
||||||
noSound );
|
|
||||||
controller->Init( &qmlEngine );
|
|
||||||
|
|
||||||
QQmlComponent component(
|
QQmlComponent component(
|
||||||
&qmlEngine, QUrl::fromLocalFile( "res/qml/mainwidget.qml" ) );
|
&qmlEngine, QUrl::fromLocalFile( "res/qml/mainwidget.qml" ) );
|
||||||
@@ -428,7 +420,7 @@ int main( int argc, char* argv[] )
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
auto quickObj = component.create();
|
auto quickObj = component.create();
|
||||||
controller->SetWidget(
|
controller.SetWidget(
|
||||||
qobject_cast<QQuickItem*>( quickObj ),
|
qobject_cast<QQuickItem*>( quickObj ),
|
||||||
advsettings::OverlayController::applicationDisplayName,
|
advsettings::OverlayController::applicationDisplayName,
|
||||||
advsettings::OverlayController::applicationKey );
|
advsettings::OverlayController::applicationKey );
|
||||||
|
|||||||
+91
-77
@@ -24,18 +24,14 @@
|
|||||||
// application namespace
|
// application namespace
|
||||||
namespace advsettings
|
namespace advsettings
|
||||||
{
|
{
|
||||||
std::unique_ptr<OverlayController> OverlayController::singleton;
|
|
||||||
|
|
||||||
constexpr const char* OverlayController::applicationVersionString;
|
constexpr const char* OverlayController::applicationVersionString;
|
||||||
|
|
||||||
QSettings* OverlayController::_appSettings = nullptr;
|
QSettings* OverlayController::_appSettings = nullptr;
|
||||||
|
|
||||||
OverlayController::~OverlayController()
|
OverlayController::OverlayController( bool desktopMode,
|
||||||
{
|
bool noSound,
|
||||||
Shutdown();
|
QQmlEngine& qmlEngine )
|
||||||
}
|
: QObject(), m_desktopMode( desktopMode ), m_noSound( noSound )
|
||||||
|
|
||||||
void OverlayController::Init( QQmlEngine* qmlEngine )
|
|
||||||
{
|
{
|
||||||
// Loading the OpenVR Runtime
|
// Loading the OpenVR Runtime
|
||||||
auto initError = vr::VRInitError_None;
|
auto initError = vr::VRInitError_None;
|
||||||
@@ -63,9 +59,9 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
QFileInfo activationSoundFileInfo( activationSoundFile );
|
QFileInfo activationSoundFileInfo( activationSoundFile );
|
||||||
if ( activationSoundFileInfo.exists() && activationSoundFileInfo.isFile() )
|
if ( activationSoundFileInfo.exists() && activationSoundFileInfo.isFile() )
|
||||||
{
|
{
|
||||||
activationSoundEffect.setSource(
|
m_activationSoundEffect.setSource(
|
||||||
QUrl::fromLocalFile( activationSoundFile ) );
|
QUrl::fromLocalFile( activationSoundFile ) );
|
||||||
activationSoundEffect.setVolume( 1.0 );
|
m_activationSoundEffect.setVolume( 1.0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -79,9 +75,9 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
if ( focusChangedSoundFileInfo.exists()
|
if ( focusChangedSoundFileInfo.exists()
|
||||||
&& focusChangedSoundFileInfo.isFile() )
|
&& focusChangedSoundFileInfo.isFile() )
|
||||||
{
|
{
|
||||||
focusChangedSoundEffect.setSource(
|
m_focusChangedSoundEffect.setSource(
|
||||||
QUrl::fromLocalFile( focusChangedSoundFile ) );
|
QUrl::fromLocalFile( focusChangedSoundFile ) );
|
||||||
focusChangedSoundEffect.setVolume( 1.0 );
|
m_focusChangedSoundEffect.setVolume( 1.0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -94,8 +90,9 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
QFileInfo alarm01SoundFileInfo( alarm01SoundFile );
|
QFileInfo alarm01SoundFileInfo( alarm01SoundFile );
|
||||||
if ( alarm01SoundFileInfo.exists() && alarm01SoundFileInfo.isFile() )
|
if ( alarm01SoundFileInfo.exists() && alarm01SoundFileInfo.isFile() )
|
||||||
{
|
{
|
||||||
alarm01SoundEffect.setSource( QUrl::fromLocalFile( alarm01SoundFile ) );
|
m_alarm01SoundEffect.setSource(
|
||||||
alarm01SoundEffect.setVolume( 1.0 );
|
QUrl::fromLocalFile( alarm01SoundFile ) );
|
||||||
|
m_alarm01SoundEffect.setVolume( 1.0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -225,41 +222,52 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init controllers
|
// Init controllers
|
||||||
steamVRTabController.initStage1();
|
m_steamVRTabController.initStage1();
|
||||||
chaperoneTabController.initStage1();
|
m_chaperoneTabController.initStage1();
|
||||||
moveCenterTabController.initStage1();
|
m_moveCenterTabController.initStage1();
|
||||||
fixFloorTabController.initStage1();
|
m_fixFloorTabController.initStage1();
|
||||||
audioTabController.initStage1();
|
m_audioTabController.initStage1();
|
||||||
statisticsTabController.initStage1();
|
m_statisticsTabController.initStage1();
|
||||||
settingsTabController.initStage1();
|
m_settingsTabController.initStage1();
|
||||||
reviveTabController.initStage1( settingsTabController.forceRevivePage() );
|
m_reviveTabController.initStage1(
|
||||||
utilitiesTabController.initStage1();
|
m_settingsTabController.forceRevivePage() );
|
||||||
accessibilityTabController.initStage1();
|
m_utilitiesTabController.initStage1();
|
||||||
|
m_accessibilityTabController.initStage1();
|
||||||
|
|
||||||
// Set qml context
|
// Set qml context
|
||||||
qmlEngine->rootContext()->setContextProperty( "applicationVersion",
|
qmlEngine.rootContext()->setContextProperty( "applicationVersion",
|
||||||
getVersionString() );
|
getVersionString() );
|
||||||
qmlEngine->rootContext()->setContextProperty( "vrRuntimePath",
|
qmlEngine.rootContext()->setContextProperty( "vrRuntimePath",
|
||||||
getVRRuntimePathUrl() );
|
getVRRuntimePathUrl() );
|
||||||
|
|
||||||
// Register qml singletons
|
// Pretty disgusting trick to allow qmlRegisterSingletonType to continue
|
||||||
|
// working with the lambdas that were already there. The callback function
|
||||||
|
// in qmlRegisterSingletonType won't work with any lambdas that capture the
|
||||||
|
// environment. The alternative to making a static pointer to this was
|
||||||
|
// rewriting all QML to not be singletons, which should probably be done
|
||||||
|
// whenever possible.
|
||||||
|
static OverlayController* const objectAddress = this;
|
||||||
qmlRegisterSingletonType<OverlayController>(
|
qmlRegisterSingletonType<OverlayController>(
|
||||||
"matzman666.advsettings",
|
"matzman666.advsettings",
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
"OverlayController",
|
"OverlayController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = getInstance();
|
QObject* obj = objectAddress;
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
|
// It is unknown if it it intended for the generic in
|
||||||
|
// qmlRegisterSingletonType to be <SteamVRTabController> in all the
|
||||||
|
// remaining function calls, or if it's just a copy paste accident that
|
||||||
|
// happens to work.
|
||||||
qmlRegisterSingletonType<SteamVRTabController>(
|
qmlRegisterSingletonType<SteamVRTabController>(
|
||||||
"matzman666.advsettings",
|
"matzman666.advsettings",
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
"SteamVRTabController",
|
"SteamVRTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->steamVRTabController;
|
QObject* obj = &( objectAddress->m_steamVRTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -269,7 +277,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"ChaperoneTabController",
|
"ChaperoneTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->chaperoneTabController;
|
QObject* obj = &( objectAddress->m_chaperoneTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -279,7 +287,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"MoveCenterTabController",
|
"MoveCenterTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->moveCenterTabController;
|
QObject* obj = &( objectAddress->m_moveCenterTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -289,7 +297,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"FixFloorTabController",
|
"FixFloorTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->fixFloorTabController;
|
QObject* obj = &( objectAddress->m_fixFloorTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -299,7 +307,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"AudioTabController",
|
"AudioTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->audioTabController;
|
QObject* obj = &( objectAddress->m_audioTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -309,7 +317,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"StatisticsTabController",
|
"StatisticsTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->statisticsTabController;
|
QObject* obj = &( objectAddress->m_statisticsTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -319,7 +327,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"SettingsTabController",
|
"SettingsTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->settingsTabController;
|
QObject* obj = &( objectAddress->m_settingsTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -329,7 +337,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"ReviveTabController",
|
"ReviveTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->reviveTabController;
|
QObject* obj = &( objectAddress->m_reviveTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -339,7 +347,7 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"UtilitiesTabController",
|
"UtilitiesTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->utilitiesTabController;
|
QObject* obj = &( objectAddress->m_utilitiesTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
@@ -349,12 +357,17 @@ void OverlayController::Init( QQmlEngine* qmlEngine )
|
|||||||
0,
|
0,
|
||||||
"AccessibilityTabController",
|
"AccessibilityTabController",
|
||||||
[]( QQmlEngine*, QJSEngine* ) {
|
[]( QQmlEngine*, QJSEngine* ) {
|
||||||
QObject* obj = &getInstance()->accessibilityTabController;
|
QObject* obj = &( objectAddress->m_accessibilityTabController );
|
||||||
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
|
||||||
return obj;
|
return obj;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OverlayController::~OverlayController()
|
||||||
|
{
|
||||||
|
Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
void OverlayController::Shutdown()
|
void OverlayController::Shutdown()
|
||||||
{
|
{
|
||||||
if ( m_pPumpEventsTimer )
|
if ( m_pPumpEventsTimer )
|
||||||
@@ -394,7 +407,7 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
|||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& key )
|
const std::string& key )
|
||||||
{
|
{
|
||||||
if ( !desktopMode )
|
if ( !m_desktopMode )
|
||||||
{
|
{
|
||||||
vr::VROverlayError overlayError
|
vr::VROverlayError overlayError
|
||||||
= vr::VROverlay()->CreateDashboardOverlay(
|
= vr::VROverlay()->CreateDashboardOverlay(
|
||||||
@@ -481,16 +494,16 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
|||||||
m_pPumpEventsTimer->setInterval( 20 );
|
m_pPumpEventsTimer->setInterval( 20 );
|
||||||
m_pPumpEventsTimer->start();
|
m_pPumpEventsTimer->start();
|
||||||
|
|
||||||
steamVRTabController.initStage2( this, m_pWindow.get() );
|
m_steamVRTabController.initStage2( this, m_pWindow.get() );
|
||||||
chaperoneTabController.initStage2( this, m_pWindow.get() );
|
m_chaperoneTabController.initStage2( this, m_pWindow.get() );
|
||||||
moveCenterTabController.initStage2( this, m_pWindow.get() );
|
m_moveCenterTabController.initStage2( this, m_pWindow.get() );
|
||||||
fixFloorTabController.initStage2( this, m_pWindow.get() );
|
m_fixFloorTabController.initStage2( this, m_pWindow.get() );
|
||||||
audioTabController.initStage2( this, m_pWindow.get() );
|
m_audioTabController.initStage2( this, m_pWindow.get() );
|
||||||
statisticsTabController.initStage2( this, m_pWindow.get() );
|
m_statisticsTabController.initStage2( this, m_pWindow.get() );
|
||||||
settingsTabController.initStage2( this, m_pWindow.get() );
|
m_settingsTabController.initStage2( this, m_pWindow.get() );
|
||||||
reviveTabController.initStage2( this, m_pWindow.get() );
|
m_reviveTabController.initStage2( this, m_pWindow.get() );
|
||||||
utilitiesTabController.initStage2( this, m_pWindow.get() );
|
m_utilitiesTabController.initStage2( this, m_pWindow.get() );
|
||||||
accessibilityTabController.initStage2( this, m_pWindow.get() );
|
m_accessibilityTabController.initStage2( this, m_pWindow.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::OnRenderRequest()
|
void OverlayController::OnRenderRequest()
|
||||||
@@ -503,7 +516,7 @@ void OverlayController::OnRenderRequest()
|
|||||||
|
|
||||||
void OverlayController::renderOverlay()
|
void OverlayController::renderOverlay()
|
||||||
{
|
{
|
||||||
if ( !desktopMode )
|
if ( !m_desktopMode )
|
||||||
{
|
{
|
||||||
// skip rendering if the overlay isn't visible
|
// skip rendering if the overlay isn't visible
|
||||||
if ( !vr::VROverlay()
|
if ( !vr::VROverlay()
|
||||||
@@ -653,8 +666,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
|||||||
LOG( INFO ) << "Received quit request.";
|
LOG( INFO ) << "Received quit request.";
|
||||||
vr::VRSystem()->AcknowledgeQuit_Exiting(); // Let us buy some time
|
vr::VRSystem()->AcknowledgeQuit_Exiting(); // Let us buy some time
|
||||||
// just in case
|
// just in case
|
||||||
moveCenterTabController.reset();
|
m_moveCenterTabController.reset();
|
||||||
chaperoneTabController.shutdown();
|
m_chaperoneTabController.shutdown();
|
||||||
Shutdown();
|
Shutdown();
|
||||||
QApplication::exit();
|
QApplication::exit();
|
||||||
return;
|
return;
|
||||||
@@ -664,14 +677,14 @@ void OverlayController::OnTimeoutPumpEvents()
|
|||||||
case vr::VREvent_DashboardActivated:
|
case vr::VREvent_DashboardActivated:
|
||||||
{
|
{
|
||||||
LOG( DEBUG ) << "Dashboard activated";
|
LOG( DEBUG ) << "Dashboard activated";
|
||||||
dashboardVisible = true;
|
m_dashboardVisible = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vr::VREvent_DashboardDeactivated:
|
case vr::VREvent_DashboardDeactivated:
|
||||||
{
|
{
|
||||||
LOG( DEBUG ) << "Dashboard deactivated";
|
LOG( DEBUG ) << "Dashboard deactivated";
|
||||||
dashboardVisible = false;
|
m_dashboardVisible = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -753,18 +766,19 @@ void OverlayController::OnTimeoutPumpEvents()
|
|||||||
= std::sqrt( vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2] );
|
= std::sqrt( vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2] );
|
||||||
}
|
}
|
||||||
|
|
||||||
fixFloorTabController.eventLoopTick( devicePoses );
|
m_fixFloorTabController.eventLoopTick( devicePoses );
|
||||||
statisticsTabController.eventLoopTick( devicePoses, leftSpeed, rightSpeed );
|
m_statisticsTabController.eventLoopTick(
|
||||||
moveCenterTabController.eventLoopTick(
|
devicePoses, leftSpeed, rightSpeed );
|
||||||
|
m_moveCenterTabController.eventLoopTick(
|
||||||
vr::VRCompositor()->GetTrackingSpace(), devicePoses );
|
vr::VRCompositor()->GetTrackingSpace(), devicePoses );
|
||||||
steamVRTabController.eventLoopTick();
|
m_steamVRTabController.eventLoopTick();
|
||||||
chaperoneTabController.eventLoopTick(
|
m_chaperoneTabController.eventLoopTick(
|
||||||
devicePoses, leftSpeed, rightSpeed, hmdSpeed );
|
devicePoses, leftSpeed, rightSpeed, hmdSpeed );
|
||||||
settingsTabController.eventLoopTick();
|
m_settingsTabController.eventLoopTick();
|
||||||
reviveTabController.eventLoopTick();
|
m_reviveTabController.eventLoopTick();
|
||||||
audioTabController.eventLoopTick();
|
m_audioTabController.eventLoopTick();
|
||||||
utilitiesTabController.eventLoopTick();
|
m_utilitiesTabController.eventLoopTick();
|
||||||
accessibilityTabController.eventLoopTick(
|
m_accessibilityTabController.eventLoopTick(
|
||||||
vr::VRCompositor()->GetTrackingSpace() );
|
vr::VRCompositor()->GetTrackingSpace() );
|
||||||
|
|
||||||
if ( m_ulOverlayThumbnailHandle != vr::k_ulOverlayHandleInvalid )
|
if ( m_ulOverlayThumbnailHandle != vr::k_ulOverlayHandleInvalid )
|
||||||
@@ -1010,7 +1024,7 @@ QUrl OverlayController::getVRRuntimePathUrl()
|
|||||||
|
|
||||||
bool OverlayController::soundDisabled()
|
bool OverlayController::soundDisabled()
|
||||||
{
|
{
|
||||||
return noSound;
|
return m_noSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vr::VROverlayHandle_t& OverlayController::overlayHandle()
|
const vr::VROverlayHandle_t& OverlayController::overlayHandle()
|
||||||
@@ -1039,44 +1053,44 @@ void OverlayController::showKeyboard( QString existingText,
|
|||||||
|
|
||||||
void OverlayController::playActivationSound()
|
void OverlayController::playActivationSound()
|
||||||
{
|
{
|
||||||
if ( !noSound )
|
if ( !m_noSound )
|
||||||
{
|
{
|
||||||
activationSoundEffect.play();
|
m_activationSoundEffect.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::playFocusChangedSound()
|
void OverlayController::playFocusChangedSound()
|
||||||
{
|
{
|
||||||
if ( !noSound )
|
if ( !m_noSound )
|
||||||
{
|
{
|
||||||
focusChangedSoundEffect.play();
|
m_focusChangedSoundEffect.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::playAlarm01Sound( bool loop )
|
void OverlayController::playAlarm01Sound( bool loop )
|
||||||
{
|
{
|
||||||
if ( !noSound && !alarm01SoundEffect.isPlaying() )
|
if ( !m_noSound && !m_alarm01SoundEffect.isPlaying() )
|
||||||
{
|
{
|
||||||
if ( loop )
|
if ( loop )
|
||||||
{
|
{
|
||||||
alarm01SoundEffect.setLoopCount( QSoundEffect::Infinite );
|
m_alarm01SoundEffect.setLoopCount( QSoundEffect::Infinite );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alarm01SoundEffect.setLoopCount( 1 );
|
m_alarm01SoundEffect.setLoopCount( 1 );
|
||||||
}
|
}
|
||||||
alarm01SoundEffect.play();
|
m_alarm01SoundEffect.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::setAlarm01SoundVolume( float vol )
|
void OverlayController::setAlarm01SoundVolume( float vol )
|
||||||
{
|
{
|
||||||
alarm01SoundEffect.setVolume( vol );
|
m_alarm01SoundEffect.setVolume( vol );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayController::cancelAlarm01Sound()
|
void OverlayController::cancelAlarm01Sound()
|
||||||
{
|
{
|
||||||
alarm01SoundEffect.stop();
|
m_alarm01SoundEffect.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace advsettings
|
} // namespace advsettings
|
||||||
|
|||||||
+20
-37
@@ -42,7 +42,7 @@ namespace advsettings
|
|||||||
class OverlayController : public QObject
|
class OverlayController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( bool desktopMode READ isDesktopMode )
|
Q_PROPERTY( bool m_desktopMode READ isDesktopMode )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr auto applicationOrganizationName = "matzman666";
|
static constexpr auto applicationOrganizationName = "matzman666";
|
||||||
@@ -64,51 +64,47 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<QTimer> m_pPumpEventsTimer;
|
std::unique_ptr<QTimer> m_pPumpEventsTimer;
|
||||||
std::unique_ptr<QTimer> m_pRenderTimer;
|
std::unique_ptr<QTimer> m_pRenderTimer;
|
||||||
bool dashboardVisible = false;
|
bool m_dashboardVisible = false;
|
||||||
|
|
||||||
QPoint m_ptLastMouse;
|
QPoint m_ptLastMouse;
|
||||||
Qt::MouseButtons m_lastMouseButtons = 0;
|
Qt::MouseButtons m_lastMouseButtons = 0;
|
||||||
|
|
||||||
bool desktopMode;
|
bool m_desktopMode;
|
||||||
bool noSound;
|
bool m_noSound;
|
||||||
|
|
||||||
QUrl m_runtimePathUrl;
|
QUrl m_runtimePathUrl;
|
||||||
|
|
||||||
utils::ChaperoneUtils m_chaperoneUtils;
|
utils::ChaperoneUtils m_chaperoneUtils;
|
||||||
|
|
||||||
QSoundEffect activationSoundEffect;
|
QSoundEffect m_activationSoundEffect;
|
||||||
QSoundEffect focusChangedSoundEffect;
|
QSoundEffect m_focusChangedSoundEffect;
|
||||||
QSoundEffect alarm01SoundEffect;
|
QSoundEffect m_alarm01SoundEffect;
|
||||||
|
|
||||||
public: // I know it's an ugly hack to make them public to enable external
|
public: // I know it's an ugly hack to make them public to enable external
|
||||||
// access, but I am too lazy to implement getters.
|
// access, but I am too lazy to implement getters.
|
||||||
SteamVRTabController steamVRTabController;
|
SteamVRTabController m_steamVRTabController;
|
||||||
ChaperoneTabController chaperoneTabController;
|
ChaperoneTabController m_chaperoneTabController;
|
||||||
MoveCenterTabController moveCenterTabController;
|
MoveCenterTabController m_moveCenterTabController;
|
||||||
FixFloorTabController fixFloorTabController;
|
FixFloorTabController m_fixFloorTabController;
|
||||||
AudioTabController audioTabController;
|
AudioTabController m_audioTabController;
|
||||||
StatisticsTabController statisticsTabController;
|
StatisticsTabController m_statisticsTabController;
|
||||||
SettingsTabController settingsTabController;
|
SettingsTabController m_settingsTabController;
|
||||||
ReviveTabController reviveTabController;
|
ReviveTabController m_reviveTabController;
|
||||||
UtilitiesTabController utilitiesTabController;
|
UtilitiesTabController m_utilitiesTabController;
|
||||||
AccessibilityTabController accessibilityTabController;
|
AccessibilityTabController m_accessibilityTabController;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayController( bool desktopMode, bool noSound )
|
|
||||||
: QObject(), desktopMode( desktopMode ), noSound( noSound )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
|
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
OverlayController( bool desktopMode, bool noSound, QQmlEngine& qmlEngine );
|
||||||
virtual ~OverlayController();
|
virtual ~OverlayController();
|
||||||
|
|
||||||
void Init( QQmlEngine* qmlEngine );
|
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
bool isDashboardVisible()
|
bool isDashboardVisible()
|
||||||
{
|
{
|
||||||
return dashboardVisible;
|
return m_dashboardVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetWidget( QQuickItem* quickItem,
|
void SetWidget( QQuickItem* quickItem,
|
||||||
@@ -137,7 +133,7 @@ public:
|
|||||||
|
|
||||||
bool isDesktopMode()
|
bool isDesktopMode()
|
||||||
{
|
{
|
||||||
return desktopMode;
|
return m_desktopMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
utils::ChaperoneUtils& chaperoneUtils() noexcept
|
utils::ChaperoneUtils& chaperoneUtils() noexcept
|
||||||
@@ -174,21 +170,8 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static QSettings* _appSettings;
|
static QSettings* _appSettings;
|
||||||
static std::unique_ptr<OverlayController> singleton;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static OverlayController* getInstance()
|
|
||||||
{
|
|
||||||
return singleton.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
static OverlayController* createInstance( bool desktopMode, bool noSound )
|
|
||||||
{
|
|
||||||
singleton.reset(
|
|
||||||
new advsettings::OverlayController( desktopMode, noSound ) );
|
|
||||||
return singleton.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
static QSettings* appSettings()
|
static QSettings* appSettings()
|
||||||
{
|
{
|
||||||
return _appSettings;
|
return _appSettings;
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ void ReviveTabController::initStage2( OverlayController* var_parent,
|
|||||||
void ReviveTabController::eventLoopTick()
|
void ReviveTabController::eventLoopTick()
|
||||||
{
|
{
|
||||||
if ( m_isOverlayInstalled
|
if ( m_isOverlayInstalled
|
||||||
|| parent->settingsTabController.forceRevivePage() )
|
|| parent->m_settingsTabController.forceRevivePage() )
|
||||||
{
|
{
|
||||||
if ( settingsUpdateCounter >= 50 )
|
if ( settingsUpdateCounter >= 50 )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user