diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index 2620b8563..d7fdb7a6d 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -269,6 +269,21 @@ Settings::Settings( const QString& settingsFilePath, bool debugMode ) s_instance = this; } +const bool +Settings::isModuleEnabled( const QString& module ) +{ + // Iterate over the list of modules searching for a match + for ( const auto& moduleInstance : qAsConst( m_moduleInstances ) ) + { + if ( moduleInstance.key().module() == module ) + { + return true; + } + } + + return false; +} + void Settings::reconcileInstancesAndSequence() { diff --git a/src/libcalamares/Settings.h b/src/libcalamares/Settings.h index b2f669ffe..625057f42 100644 --- a/src/libcalamares/Settings.h +++ b/src/libcalamares/Settings.h @@ -152,8 +152,21 @@ public: */ bool isSetupMode() const { return m_isSetupMode; } + /** @brief Returns whether the named module is enabled + * + * 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. */ bool disableCancel() const { return m_disableCancel; } + /** @brief Temporary setting of disable-cancel: can't cancel during exec. */ bool disableCancelDuringExec() const { return m_disableCancelDuringExec; }