mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#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:
parent
c3d8f13eeb
commit
681b4fbffe
@ -1533,27 +1533,52 @@ cvf::Font* RiaApplication::defaultWellLabelFont()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
auto readConfigFiles = []( RiaPreferences* preferences )
|
auto readCloudConfigFiles = []( RiaPreferences* preferences )
|
||||||
{
|
{
|
||||||
if ( preferences == nullptr ) return;
|
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";
|
QStringList osduFilePathCandidates;
|
||||||
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduConfigPath );
|
osduFilePathCandidates << QDir::homePath() + "/.resinsight/osdu_config.json";
|
||||||
if ( !keyValuePairs.empty() )
|
osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/osdu_config.json";
|
||||||
|
osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/osdu_config.json";
|
||||||
|
|
||||||
|
for ( const auto& osduFileCandidate : osduFilePathCandidates )
|
||||||
{
|
{
|
||||||
preferences->osduPreferences()->setData( keyValuePairs );
|
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduFileCandidate );
|
||||||
preferences->osduPreferences()->setFieldsReadOnly();
|
if ( !keyValuePairs.empty() )
|
||||||
|
{
|
||||||
|
preferences->osduPreferences()->setData( keyValuePairs );
|
||||||
|
preferences->osduPreferences()->setFieldsReadOnly();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QString sumoConfigPath = QDir::homePath() + "/.resinsight/sumo_config.json";
|
QStringList sumoFilePathCandidates;
|
||||||
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoConfigPath );
|
sumoFilePathCandidates << QDir::homePath() + "/.resinsight/sumo_config.json";
|
||||||
if ( !keyValuePairs.empty() )
|
sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/sumo_config.json";
|
||||||
|
sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/sumo_config.json";
|
||||||
|
|
||||||
|
for ( const auto& sumoFileCandidate : sumoFilePathCandidates )
|
||||||
{
|
{
|
||||||
preferences->sumoPreferences()->setData( keyValuePairs );
|
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoFileCandidate );
|
||||||
preferences->sumoPreferences()->setFieldsReadOnly();
|
if ( !keyValuePairs.empty() )
|
||||||
|
{
|
||||||
|
preferences->sumoPreferences()->setData( keyValuePairs );
|
||||||
|
preferences->sumoPreferences()->setFieldsReadOnly();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1577,7 +1602,7 @@ void RiaApplication::initialize()
|
|||||||
|
|
||||||
initializeDataLoadController();
|
initializeDataLoadController();
|
||||||
|
|
||||||
readConfigFiles( m_preferences.get() );
|
readCloudConfigFiles( m_preferences.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -475,9 +475,11 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
|||||||
otherGroup->add( &m_summaryCalculationExpressionFolder );
|
otherGroup->add( &m_summaryCalculationExpressionFolder );
|
||||||
|
|
||||||
caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" );
|
caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" );
|
||||||
|
osduGroup->setCollapsedByDefault();
|
||||||
m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup );
|
m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup );
|
||||||
|
|
||||||
caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" );
|
caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" );
|
||||||
|
sumoGroup->setCollapsedByDefault();
|
||||||
m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup );
|
m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup );
|
||||||
}
|
}
|
||||||
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
|
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
|
||||||
|
Loading…
Reference in New Issue
Block a user