Clean-up from initial review

This commit is contained in:
dalto 2021-10-28 14:46:38 -05:00
parent e22efab1b3
commit be513813e6
2 changed files with 17 additions and 6 deletions

View File

@ -269,15 +269,17 @@ Settings::Settings( const QString& settingsFilePath, bool debugMode )
s_instance = this; s_instance = this;
} }
bool const bool
Settings::isModuleEnabled( QString module ) Settings::isModuleEnabled( const QString& module )
{ {
// Iterate over the list of modules searching for a match // Iterate over the list of modules searching for a match
for ( const auto& moduleInstance : Calamares::Settings::instance()->moduleInstances() ) for ( const auto& moduleInstance : qAsConst( m_moduleInstances ) )
{ {
if ( moduleInstance.key().first == module ) if ( moduleInstance.key().first == module )
{
return true; return true;
} }
}
return false; return false;
} }
@ -288,7 +290,7 @@ Settings::reconcileInstancesAndSequence()
// Since moduleFinder captures targetKey by reference, we can // Since moduleFinder captures targetKey by reference, we can
// update targetKey to change what the finder lambda looks for. // update targetKey to change what the finder lambda looks for.
Calamares::ModuleSystem::InstanceKey targetKey; Calamares::ModuleSystem::InstanceKey targetKey;
auto moduleFinder = [ &targetKey ]( const InstanceDescription& d ) { return d.isValid() && d.key() == targetKey; }; auto moduleFinder = [&targetKey]( const InstanceDescription& d ) { return d.isValid() && d.key() == targetKey; };
// Check the sequence against the existing instances (which so far are only custom) // Check the sequence against the existing instances (which so far are only custom)
for ( const auto& step : m_modulesSequence ) for ( const auto& step : m_modulesSequence )

View File

@ -152,8 +152,17 @@ public:
*/ */
bool isSetupMode() const { return m_isSetupMode; } bool isSetupMode() const { return m_isSetupMode; }
/** @brief Returns true if the named module is enabled */ /** @brief Returns whether the named module is enabled
bool isModuleEnabled( QString module ); *
* Returns true if @p module is enabled in settings.conf. Be aware that it
* only tests for a specific module name so if a QML and non-QML version
* of the same module exists, it must be specified explicitly
*
* @p module is a module name or module key e.g. packagechooser) and not a
* full module key+id (e.g. packagechooser@packagechooser)
*
*/
const bool isModuleEnabled( const QString& module );
/** @brief Global setting of disable-cancel: can't cancel ever. */ /** @brief Global setting of disable-cancel: can't cancel ever. */
bool disableCancel() const { return m_disableCancel; } bool disableCancel() const { return m_disableCancel; }