[libcalamares] Detailed InstanceDescription type

This commit is contained in:
Adriaan de Groot 2020-03-13 02:55:38 +01:00
parent 0e68013bb3
commit e37809a126
3 changed files with 21 additions and 7 deletions

View File

@ -72,7 +72,18 @@ namespace Calamares
{ {
InstanceDescription::InstanceDescription( const QVariantMap& m ) InstanceDescription::InstanceDescription( const QVariantMap& m )
: module( m.value( "module" ).toString() )
, id( m.value( "id" ).toString() )
, config( m.value( "config" ).toString() )
{ {
if ( id.isEmpty() )
{
id = module;
}
if ( config.isEmpty() )
{
config = module + QStringLiteral( ".conf" );
}
} }
Settings* Settings::s_instance = nullptr; Settings* Settings::s_instance = nullptr;

View File

@ -32,16 +32,20 @@
namespace Calamares namespace Calamares
{ {
class DLLEXPORT InstanceDescription struct DLLEXPORT InstanceDescription
{ {
public:
InstanceDescription( const QVariantMap& ); InstanceDescription( const QVariantMap& );
QString module; ///< Module name (e.g. "welcome")
QString id; ///< Id, to distinguish multiple instances (e.g. "one", for "welcome@one")
QString config; ///< Config-file name (for multiple instances)
}; };
class DLLEXPORT Settings : public QObject class DLLEXPORT Settings : public QObject
{ {
Q_OBJECT Q_OBJECT
explicit Settings( const QString& settingsFilePath, bool debugMode ); explicit Settings( const QString& settingsFilePath, bool debugMode );
public: public:
static Settings* instance(); static Settings* instance();
/// @brief Find a settings.conf, following @p debugMode /// @brief Find a settings.conf, following @p debugMode

View File

@ -129,9 +129,8 @@ ModuleManager::doInit()
} }
// At this point m_availableDescriptorsByModuleName is filled with // At this point m_availableDescriptorsByModuleName is filled with
// the modules that were found in the search paths. // the modules that were found in the search paths.
cDebug() << "Found" cDebug() << "Found" << m_availableDescriptorsByModuleName.count() << "modules"
<< m_availableDescriptorsByModuleName.count() << "modules" << m_moduleDirectoriesByModuleName.count() << "names";
<< m_moduleDirectoriesByModuleName.count() << "names";
emit initDone(); emit initDone();
} }
@ -167,7 +166,7 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co
for ( int i = 0; i < customInstances.count(); ++i ) for ( int i = 0; i < customInstances.count(); ++i )
{ {
const auto& thisInstance = customInstances[ i ]; const auto& thisInstance = customInstances[ i ];
if ( thisInstance.value( "module" ) == m.module() && thisInstance.value( "id" ) == m.id() ) if ( thisInstance.module == m.module() && thisInstance.id == m.id() )
{ {
return i; return i;
} }
@ -196,7 +195,7 @@ getConfigFileName( const Settings::InstanceDescriptionList& customInstances,
return QString(); return QString();
} }
return customInstances[ found ].value( "config" ); return customInstances[ found ].config;
} }
else else
{ {