[libcalamaresui] Move requirements information out of welcome module.
- Move type and rename it; put in Calamares namespace - Emit signals from the viewmanager as results come in - Remove state changing from welcome view step based on its internal requirements checking (for now this breaks progressing past the welcome page) - Log checking of the requirements
This commit is contained in:
parent
24e04645b6
commit
27b921bde1
@ -5,6 +5,7 @@ set( calamaresui_SOURCES
|
||||
modulesystem/Module.cpp
|
||||
modulesystem/ModuleManager.cpp
|
||||
modulesystem/ProcessJobModule.cpp
|
||||
modulesystem/Requirement.cpp
|
||||
modulesystem/ViewModule.cpp
|
||||
|
||||
utils/CalamaresUtilsGui.cpp
|
||||
|
@ -297,9 +297,10 @@ Module::initFrom( const QVariantMap& moduleDescriptor )
|
||||
m_name = moduleDescriptor.value( "name" ).toString();
|
||||
}
|
||||
|
||||
void
|
||||
RequirementsList
|
||||
Module::checkRequirements()
|
||||
{
|
||||
return RequirementsList();
|
||||
}
|
||||
|
||||
} //ns
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef CALAMARES_MODULE_H
|
||||
#define CALAMARES_MODULE_H
|
||||
|
||||
#include "Requirement.h"
|
||||
#include "UiDllMacro.h"
|
||||
|
||||
#include <Typedefs.h>
|
||||
@ -165,7 +166,7 @@ public:
|
||||
/**
|
||||
* @brief Check the requirements of this module.
|
||||
*/
|
||||
virtual void checkRequirements();
|
||||
virtual RequirementsList checkRequirements();
|
||||
|
||||
protected:
|
||||
explicit Module();
|
||||
|
@ -318,14 +318,27 @@ ModuleManager::loadModules()
|
||||
void
|
||||
ModuleManager::checkRequirements()
|
||||
{
|
||||
cDebug() << "Checking module requirements ..";
|
||||
QTimer::singleShot( 0, this, [ this ]()
|
||||
{
|
||||
bool acceptable = true;
|
||||
|
||||
for (const auto& module : m_loadedModulesByInstanceKey )
|
||||
{
|
||||
module->checkRequirements();
|
||||
auto l = module->checkRequirements();
|
||||
if ( l.length() > 0 )
|
||||
{
|
||||
cDebug() << " .." << module->name() << l.length() << "requirements";
|
||||
emit requirementsResult( l );
|
||||
}
|
||||
for (const auto& r : l)
|
||||
{
|
||||
if (r.required && !r.checked)
|
||||
acceptable = false;
|
||||
}
|
||||
}
|
||||
|
||||
emit modulesChecked();
|
||||
emit requirementsComplete( acceptable );
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifndef MODULELOADER_H
|
||||
#define MODULELOADER_H
|
||||
|
||||
#include "Requirement.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
#include <QObject>
|
||||
@ -29,6 +30,7 @@ namespace Calamares
|
||||
{
|
||||
|
||||
class Module;
|
||||
class RequirementEntry; // from Requirement.h
|
||||
|
||||
/**
|
||||
* @brief The ModuleManager class is a singleton which manages Calamares modules.
|
||||
@ -89,7 +91,8 @@ public:
|
||||
signals:
|
||||
void initDone();
|
||||
void modulesLoaded();
|
||||
void modulesChecked();
|
||||
void requirementsComplete( bool );
|
||||
void requirementsResult( RequirementsList& );
|
||||
|
||||
private slots:
|
||||
void doInit();
|
||||
|
19
src/libcalamaresui/modulesystem/Requirement.cpp
Normal file
19
src/libcalamaresui/modulesystem/Requirement.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Requirement.h"
|
||||
|
52
src/libcalamaresui/modulesystem/Requirement.h
Normal file
52
src/libcalamaresui/modulesystem/Requirement.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef CALAMARES_REQUIREMENT_H
|
||||
#define CALAMARES_REQUIREMENT_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
/**
|
||||
* An indication of a requirement, which is checked in preparation
|
||||
* for system installation. An entry has a name and some explanation,
|
||||
* as well as three meaningful states:
|
||||
* - checked = true, the requirement is met (green)
|
||||
* - checked = false, the requirement is not met
|
||||
* - required = false, warn about it (yellow), no failure
|
||||
* - required = true, prohibit installation (red)
|
||||
*/
|
||||
struct RequirementEntry
|
||||
{
|
||||
QString name;
|
||||
std::function< QString() > enumerationText; //Partial string, inserted in a
|
||||
//list of requirements to satisfy.
|
||||
std::function< QString() > negatedText; //Complete sentence about this requirement
|
||||
//not having been met.
|
||||
bool checked;
|
||||
bool required;
|
||||
};
|
||||
|
||||
using RequirementsList = QList< RequirementEntry >;
|
||||
|
||||
} // namespace Calamares
|
||||
#endif
|
@ -33,8 +33,6 @@ WelcomeViewStep::WelcomeViewStep( QObject* parent )
|
||||
{
|
||||
emit nextStatusChanged( true );
|
||||
m_widget = new WelcomePage( m_requirementsChecker );
|
||||
connect( m_requirementsChecker, &RequirementsChecker::verdictChanged,
|
||||
this, &WelcomeViewStep::nextStatusChanged );
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,12 +53,12 @@ CheckerWidget::CheckerWidget( QWidget* parent )
|
||||
|
||||
|
||||
void
|
||||
CheckerWidget::init( const QList< PrepareEntry >& checkEntries )
|
||||
CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
|
||||
{
|
||||
bool allChecked = true;
|
||||
bool requirementsSatisfied = true;
|
||||
|
||||
for ( const PrepareEntry& entry : checkEntries )
|
||||
for ( const auto& entry : checkEntries )
|
||||
{
|
||||
if ( !entry.checked )
|
||||
{
|
||||
@ -162,7 +162,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries )
|
||||
|
||||
|
||||
void
|
||||
CheckerWidget::showDetailsDialog( const QList< PrepareEntry >& checkEntries )
|
||||
CheckerWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntries )
|
||||
{
|
||||
QDialog* detailsDialog = new QDialog( this );
|
||||
QBoxLayout* mainLayout = new QVBoxLayout;
|
||||
@ -177,7 +177,7 @@ CheckerWidget::showDetailsDialog( const QList< PrepareEntry >& checkEntries )
|
||||
CalamaresUtils::unmarginLayout( entriesLayout );
|
||||
mainLayout->addLayout( entriesLayout );
|
||||
|
||||
for ( const PrepareEntry& entry : checkEntries )
|
||||
for ( const auto& entry : checkEntries )
|
||||
{
|
||||
if ( entry.enumerationText().isEmpty() )
|
||||
continue;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifndef CHECKERWIDGET_H
|
||||
#define CHECKERWIDGET_H
|
||||
|
||||
#include "modulesystem/Requirement.h"
|
||||
#include "RequirementsChecker.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
@ -30,10 +31,10 @@ class CheckerWidget : public QWidget
|
||||
public:
|
||||
explicit CheckerWidget( QWidget* parent = nullptr );
|
||||
|
||||
void init( const QList< PrepareEntry >& checkEntries );
|
||||
void init( const Calamares::RequirementsList& checkEntries );
|
||||
|
||||
private:
|
||||
void showDetailsDialog( const QList< PrepareEntry >& checkEntries );
|
||||
void showDetailsDialog( const Calamares::RequirementsList& checkEntries );
|
||||
|
||||
QBoxLayout* m_mainLayout;
|
||||
QBoxLayout* m_entriesLayout;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "CheckerWidget.h"
|
||||
#include "partman_devices.h"
|
||||
|
||||
#include "modulesystem/Requirement.h"
|
||||
#include "widgets/WaitingWidget.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
@ -30,6 +31,7 @@
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Units.h"
|
||||
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
|
||||
@ -107,7 +109,7 @@ RequirementsChecker::RequirementsChecker( QObject* parent )
|
||||
<< " hasInternet:" << hasInternet
|
||||
<< " isRoot:" << isRoot;
|
||||
|
||||
QList< PrepareEntry > checkEntries;
|
||||
Calamares::RequirementsList checkEntries;
|
||||
foreach ( const QString& entry, m_entriesToCheck )
|
||||
{
|
||||
if ( entry == "storage" )
|
||||
@ -171,7 +173,7 @@ RequirementsChecker::RequirementsChecker( QObject* parent )
|
||||
m_widget->layout()->addWidget( m_actualWidget );
|
||||
|
||||
bool canGoNext = true;
|
||||
foreach ( const PrepareEntry& entry, checkEntries )
|
||||
foreach ( const auto& entry, checkEntries )
|
||||
{
|
||||
if ( !entry.checked && entry.required )
|
||||
{
|
||||
|
@ -23,31 +23,9 @@
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#include <functional>
|
||||
|
||||
class CheckerWidget;
|
||||
class QWidget;
|
||||
|
||||
/**
|
||||
* An indication of a requirement, which is checked in preparation
|
||||
* for system installation. An entry has a name and some explanation,
|
||||
* as well as three meaningful states:
|
||||
* - checked = true, the requirement is met (green)
|
||||
* - checked = false, the requirement is not met
|
||||
* - required = false, warn about it (yellow), no failure
|
||||
* - required = true, prohibit installation (red)
|
||||
*/
|
||||
struct PrepareEntry
|
||||
{
|
||||
QString name;
|
||||
std::function< QString() > enumerationText; //Partial string, inserted in a
|
||||
//list of requirements to satisfy.
|
||||
std::function< QString() > negatedText; //Complete sentence about this requirement
|
||||
//not having been met.
|
||||
bool checked;
|
||||
bool required;
|
||||
};
|
||||
|
||||
class RequirementsChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Loading…
Reference in New Issue
Block a user