Convert to new paths system

This commit is contained in:
Vasily
2019-03-19 16:10:35 +01:00
committed by username223
parent 62dcea6943
commit d654567d98
4 changed files with 42 additions and 32 deletions
+17 -18
View File
@@ -65,20 +65,19 @@ OverlayController::OverlayController( bool desktopMode,
<< focusChangedSoundFile; << focusChangedSoundFile;
} }
QString alarm01SoundFile constexpr auto alarmFileName = "res/sounds/alarm01.wav";
= QStandardPaths::locate( QStandardPaths::AppDataLocation, const auto alarm01SoundFile
QStringLiteral( "res/sounds/alarm01.wav" ) ); = paths::binaryDirectoryFindFile( alarmFileName );
QFileInfo alarm01SoundFileInfo( alarm01SoundFile );
if ( alarm01SoundFileInfo.exists() && alarm01SoundFileInfo.isFile() ) if ( alarm01SoundFile.has_value() )
{ {
m_alarm01SoundEffect.setSource( m_alarm01SoundEffect.setSource( QUrl::fromLocalFile(
QUrl::fromLocalFile( alarm01SoundFile ) ); QString::fromStdString( ( *alarm01SoundFile ) ) ) );
m_alarm01SoundEffect.setVolume( 1.0 ); m_alarm01SoundEffect.setVolume( 1.0 );
} }
else else
{ {
LOG( ERROR ) << "Could not find alarm01 sound file " LOG( ERROR ) << "Could not find alarm01 sound file " << alarmFileName;
<< alarm01SoundFile;
} }
QSurfaceFormat format; QSurfaceFormat format;
@@ -326,19 +325,19 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
m_ulOverlayHandle, m_ulOverlayHandle,
vr::VROverlayFlags_SendVRSmoothScrollEvents, vr::VROverlayFlags_SendVRSmoothScrollEvents,
true ); true );
QString thumbIconPath = QStandardPaths::locate(
QStandardPaths::AppDataLocation, constexpr auto thumbiconFilename = "res/img/icons/thumbicon.png";
QStringLiteral( "res/img/icons/thumbicon.png" ) ); const auto thumbIconPath
if ( QFile::exists( thumbIconPath ) ) = paths::binaryDirectoryFindFile( thumbiconFilename );
if ( thumbIconPath.has_value() )
{ {
vr::VROverlay()->SetOverlayFromFile( vr::VROverlay()->SetOverlayFromFile( m_ulOverlayThumbnailHandle,
m_ulOverlayThumbnailHandle, thumbIconPath->c_str() );
thumbIconPath.toStdString().c_str() );
} }
else else
{ {
LOG( ERROR ) << "Could not find thumbnail icon \"" << thumbIconPath LOG( ERROR ) << "Could not find thumbnail icon \""
<< "\""; << thumbiconFilename << "\"";
} }
// Too many render calls in too short time overwhelm Qt and an assertion // Too many render calls in too short time overwhelm Qt and an assertion
+8 -9
View File
@@ -70,15 +70,14 @@ void AudioTabController::initStage2( OverlayController* var_parent,
notifKey.c_str(), notifKey.c_str(), &m_ulNotificationOverlayHandle ); notifKey.c_str(), notifKey.c_str(), &m_ulNotificationOverlayHandle );
if ( overlayError == vr::VROverlayError_None ) if ( overlayError == vr::VROverlayError_None )
{ {
QString notifIconPath = QStandardPaths::locate( constexpr auto notificationIconFilename
QStandardPaths::AppDataLocation, = "/res/img/audio/microphone/ptt_notification.png";
QStringLiteral( const auto notifIconPath
"/res/img/audio/microphone/ptt_notification.png" ) ); = paths::binaryDirectoryFindFile( notificationIconFilename );
if ( QFile::exists( notifIconPath ) ) if ( notifIconPath.has_value() )
{ {
vr::VROverlay()->SetOverlayFromFile( vr::VROverlay()->SetOverlayFromFile( m_ulNotificationOverlayHandle,
m_ulNotificationOverlayHandle, notifIconPath->c_str() );
notifIconPath.toStdString().c_str() );
vr::VROverlay()->SetOverlayWidthInMeters( vr::VROverlay()->SetOverlayWidthInMeters(
m_ulNotificationOverlayHandle, 0.02f ); m_ulNotificationOverlayHandle, 0.02f );
vr::HmdMatrix34_t notificationTransform vr::HmdMatrix34_t notificationTransform
@@ -93,7 +92,7 @@ void AudioTabController::initStage2( OverlayController* var_parent,
else else
{ {
LOG( ERROR ) << "Could not find notification icon \"" LOG( ERROR ) << "Could not find notification icon \""
<< notifIconPath << "\""; << notificationIconFilename << "\"";
} }
} }
else else
+16 -4
View File
@@ -250,10 +250,22 @@ void UtilitiesTabController::modAlarmTimeMinute( int value, bool notify )
QString getBatteryIconPath( int batteryState ) QString getBatteryIconPath( int batteryState )
{ {
QString batteryPrefix = "/res/img/battery/battery_"; constexpr auto batteryPrefix = "/res/img/battery/battery_";
return QStandardPaths::locate(
QStandardPaths::AppDataLocation, const auto batteryFullPath
batteryPrefix + QString::number( batteryState ) + ".png" ); = ( batteryPrefix + QString::number( batteryState ) + ".png" )
.toStdString();
const auto batteryPath = paths::binaryDirectoryFindFile( batteryFullPath );
if ( !batteryPath.has_value() )
{
LOG( ERROR ) << "Unable to find battery image number '" << batteryState
<< "'.";
return "";
}
return QString::fromStdString( *batteryPath );
} }
vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index ) vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index )
+1 -1
View File
@@ -35,7 +35,7 @@ optional<string> binaryDirectoryFindFile( const string fileName )
return path.toStdString(); return path.toStdString();
} }
optional<string> binaryDirectoryFindDirectory( string directoryName ) optional<string> binaryDirectoryFindDirectory( const string directoryName )
{ {
const auto path const auto path
= QStandardPaths::locate( QStandardPaths::AppDataLocation, = QStandardPaths::locate( QStandardPaths::AppDataLocation,