@ -114,33 +114,13 @@ interpretModulesSearch( const bool debugMode, const QStringList& rawPaths, QStri
}
}
Settings : : Settings ( const QString & settingsFilePath ,
bool debugMode ,
QObject * parent )
: QObject ( parent )
, m_debug ( debugMode )
, m_doChroot ( true )
, m_promptInstall ( false )
, m_disableCancel ( false )
{
cDebug ( ) < < " Using Calamares settings file at " < < settingsFilePath ;
QFile file ( settingsFilePath ) ;
if ( file . exists ( ) & & file . open ( QFile : : ReadOnly | QFile : : Text ) )
{
QByteArray ba = file . readAll ( ) ;
try
static void
interpretInstances ( const YAML : : Node & node , Settings : : InstanceDescriptionList & customInstances )
{
YAML : : Node config = YAML : : Load ( ba . constData ( ) ) ;
Q_ASSERT ( config . IsMap ( ) ) ;
interpretModulesSearch ( debugMode , CalamaresUtils : : yamlToStringList ( config [ " modules-search " ] ) , m_modulesSearchPaths ) ;
// Parse the custom instances section
if ( config [ " instances " ] )
if ( node )
{
QVariant instancesV
= CalamaresUtils : : yamlToVariant ( config [ " instances " ] ) . toList ( ) ;
QVariant instancesV = CalamaresUtils : : yamlToVariant ( node ) . toList ( ) ;
if ( instancesV . type ( ) = = QVariant : : List )
{
const auto instances = instancesV . toList ( ) ;
@ -150,7 +130,7 @@ Settings::Settings( const QString& settingsFilePath,
continue ;
QVariantMap instancesVListItemMap =
instancesVListItem . toMap ( ) ;
QMap < QString , QString > instanceMap ;
Settings : : InstanceDescription instanceMap ;
for ( auto it = instancesVListItemMap . constBegin ( ) ;
it ! = instancesVListItemMap . constEnd ( ) ; + + it )
{
@ -158,17 +138,22 @@ Settings::Settings( const QString& settingsFilePath,
continue ;
instanceMap . insert ( it . key ( ) , it . value ( ) . toString ( ) ) ;
}
m_customModuleInstances . append ( instanceMap ) ;
customInstances . append ( instanceMap ) ;
}
}
}
}
static void
interpretSequence ( const YAML : : Node & node , Settings : : ModuleSequence & moduleSequence )
{
// Parse the modules sequence section
Q_ASSERT ( config [ " sequence " ] ) ; // It better exist!
if ( node )
{
QVariant sequenceV
= CalamaresUtils : : yamlToVariant ( config [ " sequence " ] ) ;
Q_ASSERT ( sequenceV . type ( ) = = QVariant : : List ) ;
QVariant sequenceV = CalamaresUtils : : yamlToVariant ( node ) ;
if ( ! ( sequenceV . type ( ) = = QVariant : : List ) )
throw YAML : : Exception ( YAML : : Mark ( ) , " sequence key does not have a list-value " ) ;
const auto sequence = sequenceV . toList ( ) ;
for ( const QVariant & sequenceVListItem : sequence )
{
@ -187,10 +172,37 @@ Settings::Settings( const QString& settingsFilePath,
. toMap ( )
. value ( thisActionS )
. toStringList ( ) ;
m_ modules Sequence. append ( qMakePair ( thisAction ,
moduleSequence. append ( qMakePair ( thisAction ,
thisActionRoster ) ) ;
}
}
else
throw YAML : : Exception ( YAML : : Mark ( ) , " sequence key is missing " ) ;
}
Settings : : Settings ( const QString & settingsFilePath ,
bool debugMode ,
QObject * parent )
: QObject ( parent )
, m_debug ( debugMode )
, m_doChroot ( true )
, m_promptInstall ( false )
, m_disableCancel ( false )
{
cDebug ( ) < < " Using Calamares settings file at " < < settingsFilePath ;
QFile file ( settingsFilePath ) ;
if ( file . exists ( ) & & file . open ( QFile : : ReadOnly | QFile : : Text ) )
{
QByteArray ba = file . readAll ( ) ;
try
{
YAML : : Node config = YAML : : Load ( ba . constData ( ) ) ;
Q_ASSERT ( config . IsMap ( ) ) ;
interpretModulesSearch ( debugMode , CalamaresUtils : : yamlToStringList ( config [ " modules-search " ] ) , m_modulesSearchPaths ) ;
interpretInstances ( config [ " instances " ] , m_customModuleInstances ) ;
interpretSequence ( config [ " sequence " ] , m_modulesSequence ) ;
m_brandingComponentName = requireString ( config , " branding " ) ;
m_promptInstall = requireBool ( config , " prompt-install " , false ) ;