diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index 2620b8563..73be293dd 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -269,13 +269,26 @@ Settings::Settings( const QString& settingsFilePath, bool debugMode ) 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 Settings::reconcileInstancesAndSequence() { // Since moduleFinder captures targetKey by reference, we can // update targetKey to change what the finder lambda looks for. 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) for ( const auto& step : m_modulesSequence ) diff --git a/src/libcalamares/Settings.h b/src/libcalamares/Settings.h index b2f669ffe..6156a98da 100644 --- a/src/libcalamares/Settings.h +++ b/src/libcalamares/Settings.h @@ -152,8 +152,12 @@ public: */ 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. */ bool disableCancel() const { return m_disableCancel; } + /** @brief Temporary setting of disable-cancel: can't cancel during exec. */ bool disableCancelDuringExec() const { return m_disableCancelDuringExec; }