[welcome] [welcomeq] Move requirements to Config

The Config object can hold all of the configuration information,
including also the requirements-checking parts. Move requirements-
checking configuration there, so it is shared and consistent
across welcome and welcomeq, regardless.

This repairs the test that expects the Config object to handle
**all** of the configuration, too.
This commit is contained in:
Adriaan de Groot 2021-08-26 16:39:55 +02:00
parent 67d2b5568d
commit ad76a2cbe8
7 changed files with 33 additions and 47 deletions

View File

@ -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
)

View File

@ -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.";
}
}

View File

@ -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;

View File

@ -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();
}

View File

@ -66,7 +66,6 @@ public:
private:
Config* m_conf;
WelcomePage* m_widget;
GeneralRequirements* m_requirementsChecker;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeViewStepFactory )

View File

@ -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*

View File

@ -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 )