Add isModuleEnabled function

This commit is contained in:
dalto 2021-10-23 13:57:24 -05:00
parent 132bca649e
commit e22efab1b3
2 changed files with 18 additions and 1 deletions

View File

@ -269,13 +269,26 @@ Settings::Settings( const QString& settingsFilePath, bool debugMode )
s_instance = this; s_instance = this;
} }
bool
Settings::isModuleEnabled( QString module )
{
// Iterate over the list of modules searching for a match
for ( const auto& moduleInstance : Calamares::Settings::instance()->moduleInstances() )
{
if ( moduleInstance.key().first == module )
return true;
}
return false;
}
void void
Settings::reconcileInstancesAndSequence() 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,12 @@ public:
*/ */
bool isSetupMode() const { return m_isSetupMode; } bool isSetupMode() const { return m_isSetupMode; }
/** @brief Returns true if the named module is enabled */
bool isModuleEnabled( 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; }
/** @brief Temporary setting of disable-cancel: can't cancel during exec. */ /** @brief Temporary setting of disable-cancel: can't cancel during exec. */
bool disableCancelDuringExec() const { return m_disableCancelDuringExec; } bool disableCancelDuringExec() const { return m_disableCancelDuringExec; }