diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index 4895d4b80..01a89703a 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -8,26 +8,22 @@ find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus Network ) find_package( LIBPARTED ) if ( LIBPARTED_FOUND ) set( PARTMAN_SRC checker/partman_devices.c ) - set( CHECKER_LINK_LIBRARIES ${LIBPARTED_LIBRARY} ) + set( PARTMAN_LIB ${LIBPARTED_LIBRARY} ) else() set( PARTMAN_SRC ) - set( CHECKER_LINK_LIBRARIES ) + set( PARTMAN_LIB ) add_definitions( -DWITHOUT_LIBPARTED ) endif() -set( CHECKER_SOURCES - checker/CheckerContainer.cpp - checker/GeneralRequirements.cpp - checker/ResultWidget.cpp - checker/ResultsListWidget.cpp - ${PARTMAN_SRC} -) - calamares_add_plugin( welcome TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - ${CHECKER_SOURCES} + checker/CheckerContainer.cpp + checker/GeneralRequirements.cpp + checker/ResultWidget.cpp + checker/ResultsListWidget.cpp + ${PARTMAN_SRC} WelcomeViewStep.cpp Config.cpp Config.h @@ -37,7 +33,7 @@ calamares_add_plugin( welcome RESOURCES welcome.qrc LINK_PRIVATE_LIBRARIES - ${CHECKER_LINK_LIBRARIES} + ${PARTMAN_LIB} Qt5::DBus Qt5::Network SHARED_LIB @@ -46,9 +42,14 @@ calamares_add_plugin( welcome calamares_add_test( welcometest SOURCES + checker/GeneralRequirements.cpp + ${PARTMAN_SRC} Config.cpp Tests.cpp LIBRARIES + ${PARTMAN_LIB} + Qt5::DBus + Qt5::Network Qt5::Widgets Calamares::calamaresui ) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 989475153..c6b960d9d 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -27,6 +27,7 @@ Config::Config( QObject* parent ) : QObject( parent ) , m_languages( CalamaresUtils::Locale::availableTranslations() ) , m_filtermodel( std::make_unique< QSortFilterProxyModel >() ) + , m_requirementsChecker( std::make_unique< GeneralRequirements >( this ) ) { initLanguages(); @@ -399,4 +400,15 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) ::setLanguageIcon( this, configurationMap ); ::setGeoIP( this, configurationMap ); + + if ( configurationMap.contains( "requirements" ) + && configurationMap.value( "requirements" ).type() == QVariant::Map ) + { + m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); + } + else + { + cWarning() << "no valid requirements map found in welcome " + "module configuration."; + } } diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index a3f1276a6..6cce75f22 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -10,6 +10,8 @@ #ifndef WELCOME_CONFIG_H #define WELCOME_CONFIG_H +#include "checker/GeneralRequirements.h" + #include "locale/LabelModel.h" #include "modulesystem/RequirementsModel.h" @@ -100,6 +102,9 @@ public slots: QAbstractItemModel* unsatisfiedRequirements() const; + /// @brief Check the general requirements + Calamares::RequirementsList checkRequirements() const { return m_requirementsChecker->checkRequirements(); } + signals: void countryCodeChanged( QString countryCode ); void localeIndexChanged( int localeIndex ); @@ -118,6 +123,7 @@ private: CalamaresUtils::Locale::LabelModel* m_languages = nullptr; std::unique_ptr< QSortFilterProxyModel > m_filtermodel; + std::unique_ptr< GeneralRequirements > m_requirementsChecker; QString m_languageIcon; QString m_countryCode; diff --git a/src/modules/welcome/WelcomeViewStep.cpp b/src/modules/welcome/WelcomeViewStep.cpp index 2a0d57bc4..df42271fc 100644 --- a/src/modules/welcome/WelcomeViewStep.cpp +++ b/src/modules/welcome/WelcomeViewStep.cpp @@ -12,7 +12,6 @@ #include "Config.h" #include "WelcomePage.h" -#include "checker/GeneralRequirements.h" #include "Branding.h" #include "modulesystem/ModuleManager.h" @@ -25,7 +24,6 @@ WelcomeViewStep::WelcomeViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_conf( new Config( this ) ) , m_widget( new WelcomePage( m_conf ) ) - , m_requirementsChecker( new GeneralRequirements( this ) ) { connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, @@ -96,17 +94,6 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_conf->setConfigurationMap( configurationMap ); - if ( configurationMap.contains( "requirements" ) - && configurationMap.value( "requirements" ).type() == QVariant::Map ) - { - m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); - } - else - { - cWarning() << "no valid requirements map found in welcome " - "module configuration."; - } - //here init the qml or qwidgets needed bits m_widget->init(); } @@ -114,5 +101,5 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap ) Calamares::RequirementsList WelcomeViewStep::checkRequirements() { - return m_requirementsChecker->checkRequirements(); + return m_conf->checkRequirements(); } diff --git a/src/modules/welcome/WelcomeViewStep.h b/src/modules/welcome/WelcomeViewStep.h index 57632f7ac..dfc6f1169 100644 --- a/src/modules/welcome/WelcomeViewStep.h +++ b/src/modules/welcome/WelcomeViewStep.h @@ -66,7 +66,6 @@ public: private: Config* m_conf; WelcomePage* m_widget; - GeneralRequirements* m_requirementsChecker; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeViewStepFactory ) diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.cpp b/src/modules/welcomeq/WelcomeQmlViewStep.cpp index af32f2992..914ea4f3a 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.cpp +++ b/src/modules/welcomeq/WelcomeQmlViewStep.cpp @@ -26,7 +26,6 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin< WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent ) : Calamares::QmlViewStep( parent ) , m_config( new Config( this ) ) - , m_requirementsChecker( new GeneralRequirements( this ) ) { connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, @@ -58,7 +57,6 @@ WelcomeQmlViewStep::isBackEnabled() const bool WelcomeQmlViewStep::isAtBeginning() const { - // TODO: adjust to "pages" in the QML return true; } @@ -66,7 +64,6 @@ WelcomeQmlViewStep::isAtBeginning() const bool WelcomeQmlViewStep::isAtEnd() const { - // TODO: adjust to "pages" in the QML return true; } @@ -81,26 +78,13 @@ void WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_config->setConfigurationMap( configurationMap ); - - if ( configurationMap.contains( "requirements" ) - && configurationMap.value( "requirements" ).type() == QVariant::Map ) - { - m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); - } - else - { - cWarning() << "no valid requirements map found in welcomeq " - "module configuration."; - } - Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last - setContextProperty( "Welcome", m_config ); } Calamares::RequirementsList WelcomeQmlViewStep::checkRequirements() { - return m_requirementsChecker->checkRequirements(); + return m_config->checkRequirements(); } QObject* diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.h b/src/modules/welcomeq/WelcomeQmlViewStep.h index 4c68ea2ae..1ed90ce05 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.h +++ b/src/modules/welcomeq/WelcomeQmlViewStep.h @@ -29,9 +29,7 @@ class Handler; } } // namespace CalamaresUtils -class GeneralRequirements; -// TODO: Needs a generic Calamares::QmlViewStep as base class // TODO: refactor and move what makes sense to base class class PLUGINDLLEXPORT WelcomeQmlViewStep : public Calamares::QmlViewStep { @@ -65,7 +63,6 @@ public: private: Config* m_config; - GeneralRequirements* m_requirementsChecker; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeQmlViewStepFactory )