#11650 Cloud data configuration file search order

Check multiple locations for configuration files. The first valid configuration file is used. Currently, using Qt5 the ResInsight binary file is stored at the root of the installation folder. When moving to Qt6, we will probably use sub folders /bin /lib and others. Support both one and two search levels to support Qt6.
This commit is contained in:
Magne Sjaastad 2024-08-29 09:37:07 +02:00
parent c3d8f13eeb
commit 681b4fbffe
2 changed files with 39 additions and 12 deletions

View File

@ -1533,27 +1533,52 @@ cvf::Font* RiaApplication::defaultWellLabelFont()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
auto readConfigFiles = []( RiaPreferences* preferences )
auto readCloudConfigFiles = []( RiaPreferences* preferences )
{
if ( preferences == nullptr ) return;
// Check multiple locations for configuration files. The first valid configuration file is used. Currently, using Qt5 the ResInsight
// binary file is stored at the root of the installation folder. When moving to Qt6, we will probably use sub folders /bin /lib and
// others. Support both one and two search levels to support Qt6.
//
// home_folder/.resinsight/*_config.json
// location_of_resinsight_executable/../share/cloud_services/*_config.json
// location_of_resinsight_executable/../../share/cloud_services/*_config.json
//
{
QString osduConfigPath = QDir::homePath() + "/.resinsight/osdu_config.json";
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduConfigPath );
QStringList osduFilePathCandidates;
osduFilePathCandidates << QDir::homePath() + "/.resinsight/osdu_config.json";
osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/osdu_config.json";
osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/osdu_config.json";
for ( const auto& osduFileCandidate : osduFilePathCandidates )
{
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduFileCandidate );
if ( !keyValuePairs.empty() )
{
preferences->osduPreferences()->setData( keyValuePairs );
preferences->osduPreferences()->setFieldsReadOnly();
break;
}
}
}
{
QString sumoConfigPath = QDir::homePath() + "/.resinsight/sumo_config.json";
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoConfigPath );
QStringList sumoFilePathCandidates;
sumoFilePathCandidates << QDir::homePath() + "/.resinsight/sumo_config.json";
sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/sumo_config.json";
sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/sumo_config.json";
for ( const auto& sumoFileCandidate : sumoFilePathCandidates )
{
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoFileCandidate );
if ( !keyValuePairs.empty() )
{
preferences->sumoPreferences()->setData( keyValuePairs );
preferences->sumoPreferences()->setFieldsReadOnly();
break;
}
}
}
};
@ -1577,7 +1602,7 @@ void RiaApplication::initialize()
initializeDataLoadController();
readConfigFiles( m_preferences.get() );
readCloudConfigFiles( m_preferences.get() );
}
//--------------------------------------------------------------------------------------------------

View File

@ -475,9 +475,11 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
otherGroup->add( &m_summaryCalculationExpressionFolder );
caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" );
osduGroup->setCollapsedByDefault();
m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup );
caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" );
sumoGroup->setCollapsedByDefault();
m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup );
}
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )