[libcalamaresui] Refactor Requirements classes
- improve naming of member variables - expand documentation
This commit is contained in:
parent
43eae0bc47
commit
d33752c66c
@ -317,7 +317,7 @@ ModuleManager::checkRequirements()
|
||||
|
||||
for (const auto& module : m_loadedModulesByInstanceKey )
|
||||
{
|
||||
auto l = module->checkRequirements();
|
||||
RequirementsList l = module->checkRequirements();
|
||||
if ( l.length() > 0 )
|
||||
{
|
||||
cDebug() << " .." << module->name() << l.length() << "requirements";
|
||||
@ -325,7 +325,7 @@ ModuleManager::checkRequirements()
|
||||
}
|
||||
for (const auto& r : l)
|
||||
{
|
||||
if (r.required && !r.checked)
|
||||
if ( r.mandatory && !r.satisfied )
|
||||
acceptable = false;
|
||||
}
|
||||
}
|
||||
|
@ -28,22 +28,30 @@ 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)
|
||||
* for system installation. An entry has a name and some explanation functions
|
||||
* (functions, because they need to respond to translations).
|
||||
*
|
||||
* A requirement can be *satisfied* or not.
|
||||
* A requirement can be optional (i.e. a "good to have") or mandatory.
|
||||
*
|
||||
* Requirements which are not satisfied, and also mandatory, will prevent the
|
||||
* installation from proceeding.
|
||||
*/
|
||||
struct RequirementEntry
|
||||
{
|
||||
using TextFunction = std::function< QString() >;
|
||||
|
||||
/// @brief name of this requirement; not shown to user and used as ID
|
||||
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;
|
||||
|
||||
/// @brief Description of this requirement, for use in user-visible lists
|
||||
TextFunction enumerationText;
|
||||
|
||||
/// @brief User-visible string to show that the requirement is not met
|
||||
std::function< QString() > negatedText;
|
||||
|
||||
bool satisfied;
|
||||
bool mandatory;
|
||||
};
|
||||
|
||||
using RequirementsList = QList< RequirementEntry >;
|
||||
|
@ -60,15 +60,15 @@ CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
|
||||
|
||||
for ( const auto& entry : checkEntries )
|
||||
{
|
||||
if ( !entry.checked )
|
||||
if ( !entry.satisfied )
|
||||
{
|
||||
CheckItemWidget* ciw = new CheckItemWidget( entry.checked, entry.required );
|
||||
CheckItemWidget* ciw = new CheckItemWidget( entry.satisfied, entry.mandatory );
|
||||
CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); )
|
||||
m_entriesLayout->addWidget( ciw );
|
||||
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||
|
||||
allChecked = false;
|
||||
if ( entry.required )
|
||||
if ( entry.mandatory )
|
||||
{
|
||||
requirementsSatisfied = false;
|
||||
}
|
||||
@ -182,7 +182,7 @@ CheckerWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntrie
|
||||
if ( entry.enumerationText().isEmpty() )
|
||||
continue;
|
||||
|
||||
CheckItemWidget* ciw = new CheckItemWidget( entry.checked, entry.required );
|
||||
CheckItemWidget* ciw = new CheckItemWidget( entry.satisfied, entry.mandatory );
|
||||
CALAMARES_RETRANSLATE( ciw->setText( entry.enumerationText() ); )
|
||||
entriesLayout->addWidget( ciw );
|
||||
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||
|
Loading…
Reference in New Issue
Block a user