| 407 | } |
| 408 | |
| 409 | void OverlayController::SetWidget( QQuickItem* quickItem, |
| 410 | const std::string& name, |
| 411 | const std::string& key ) |
| 412 | { |
| 413 | if ( !m_desktopMode ) |
| 414 | { |
| 415 | vr::VROverlayError overlayError |
| 416 | = vr::VROverlay()->CreateDashboardOverlay( |
| 417 | key.c_str(), |
| 418 | name.c_str(), |
| 419 | &m_ulOverlayHandle, |
| 420 | &m_ulOverlayThumbnailHandle ); |
| 421 | if ( overlayError != vr::VROverlayError_None ) |
| 422 | { |
| 423 | if ( overlayError == vr::VROverlayError_KeyInUse ) |
| 424 | { |
| 425 | QMessageBox::critical( nullptr, |
| 426 | "OpenVR Advanced Settings Overlay", |
| 427 | "Another instance is already running." ); |
| 428 | } |
| 429 | throw std::runtime_error( std::string( |
| 430 | "Failed to create Overlay: " |
| 431 | + std::string( vr::VROverlay()->GetOverlayErrorNameFromEnum( |
| 432 | overlayError ) ) ) ); |
| 433 | } |
| 434 | vr::VROverlay()->SetOverlayWidthInMeters( m_ulOverlayHandle, 2.5f ); |
| 435 | vr::VROverlay()->SetOverlayInputMethod( |
| 436 | m_ulOverlayHandle, vr::VROverlayInputMethod_Mouse ); |
| 437 | vr::VROverlay()->SetOverlayFlag( |
| 438 | m_ulOverlayHandle, |
| 439 | vr::VROverlayFlags_SendVRSmoothScrollEvents, |
| 440 | true ); |
| 441 | |
| 442 | constexpr auto thumbiconFilename = "res/img/icons/thumbicon.png"; |
| 443 | const auto thumbIconPath |
| 444 | = paths::binaryDirectoryFindFile( thumbiconFilename ); |
| 445 | if ( thumbIconPath.has_value() ) |
| 446 | { |
| 447 | vr::VROverlay()->SetOverlayFromFile( m_ulOverlayThumbnailHandle, |
| 448 | thumbIconPath->c_str() ); |
| 449 | } |
| 450 | else |
| 451 | { |
| 452 | LOG( ERROR ) << "Could not find thumbnail icon \"" |
| 453 | << thumbiconFilename << "\""; |
| 454 | } |
| 455 | |
| 456 | // Too many render calls in too short time overwhelm Qt and an |
| 457 | // assertion gets thrown. Therefore we use an timer to delay render |
| 458 | // calls |
| 459 | m_pRenderTimer.reset( new QTimer() ); |
| 460 | m_pRenderTimer->setSingleShot( true ); |
| 461 | m_pRenderTimer->setInterval( 5 ); |
| 462 | connect( m_pRenderTimer.get(), |
| 463 | SIGNAL( timeout() ), |
| 464 | this, |
| 465 | SLOT( renderOverlay() ) ); |
| 466 |
no test coverage detected