From cbd4bd9bbe57de0cc7a894c20947bede8146fa05 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 13 Apr 2022 16:47:54 +0200 Subject: [PATCH] [welcome] Factor out is-this-check-required While here, make it possible for the "screen" (screen-size) check to be mandatory; there's no reason it shouldn't follow the same logic as all the others (although denying users an install because they have a VGA monitor seems a bit weak). --- .../welcome/checker/GeneralRequirements.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp index b9e5db83d..6233eae75 100644 --- a/src/modules/welcome/checker/GeneralRequirements.cpp +++ b/src/modules/welcome/checker/GeneralRequirements.cpp @@ -148,6 +148,7 @@ GeneralRequirements::checkRequirements() Calamares::RequirementsList checkEntries; foreach ( const QString& entry, m_entriesToCheck ) { + const bool required = m_entriesToRequire.contains( entry ); if ( entry == "storage" ) { checkEntries.append( @@ -157,7 +158,7 @@ GeneralRequirements::checkRequirements() [ req = m_requiredStorageGiB ] { return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req ); }, enoughStorage, - m_entriesToRequire.contains( entry ) } ); + required } ); } else if ( entry == "ram" ) { @@ -169,7 +170,7 @@ GeneralRequirements::checkRequirements() .arg( req ); }, enoughRam, - m_entriesToRequire.contains( entry ) } ); + required } ); } else if ( entry == "power" ) { @@ -177,7 +178,7 @@ GeneralRequirements::checkRequirements() [] { return tr( "is plugged in to a power source" ); }, [] { return tr( "The system is not plugged in to a power source." ); }, hasPower, - m_entriesToRequire.contains( entry ) } ); + required } ); } else if ( entry == "internet" ) { @@ -185,7 +186,7 @@ GeneralRequirements::checkRequirements() [] { return tr( "is connected to the Internet" ); }, [] { return tr( "The system is not connected to the Internet." ); }, hasInternet, - m_entriesToRequire.contains( entry ) } ); + required } ); } else if ( entry == "root" ) { @@ -198,7 +199,7 @@ GeneralRequirements::checkRequirements() : tr( "The installer is not running with administrator rights." ); }, isRoot, - m_entriesToRequire.contains( entry ) } ); + required } ); } else if ( entry == "screen" ) { @@ -211,7 +212,7 @@ GeneralRequirements::checkRequirements() : tr( "The screen is too small to display the installer." ); }, enoughScreen, - false } ); + required } ); } #ifdef CALAMARES_VERSION_RC if ( entry == "false" ) @@ -220,7 +221,7 @@ GeneralRequirements::checkRequirements() [] { return tr( "is always false" ); }, [] { return tr( "is always false" ); }, false, - m_entriesToRequire.contains( entry ) } ); + required } ); } if ( entry == "true" ) { @@ -228,7 +229,7 @@ GeneralRequirements::checkRequirements() [] { return tr( "is always true" ); }, [] { return tr( "is always true" ); }, true, - m_entriesToRequire.contains( entry ) } ); + required } ); } if ( entry == "snark" ) { @@ -241,7 +242,7 @@ GeneralRequirements::checkRequirements() "The (some mythological beast) has not been checked three times." ); }, ++snark_count > 3, - m_entriesToRequire.contains( entry ) } ); + required } ); } #endif }