Block the install process if an entry is required but unsatisfied.
This commit is contained in:
parent
87711c89fc
commit
5434a04ebc
@ -47,11 +47,11 @@ PreparePage::PreparePage( QWidget* parent )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreparePage::init( const QList< QPair< QString, bool > > &checkEntries )
|
PreparePage::init( const QList< PrepareEntry >& checkEntries )
|
||||||
{
|
{
|
||||||
for ( const QPair< QString, bool >& entry : checkEntries )
|
for ( const PrepareEntry& entry : checkEntries )
|
||||||
{
|
{
|
||||||
PrepareCheckWidget* pcw = new PrepareCheckWidget( entry.first, entry.second );
|
PrepareCheckWidget* pcw = new PrepareCheckWidget( entry.text, entry.checked );
|
||||||
m_entriesLayout->addWidget( pcw );
|
m_entriesLayout->addWidget( pcw );
|
||||||
pcw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
pcw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#ifndef PREPAREPAGE_H
|
#ifndef PREPAREPAGE_H
|
||||||
#define PREPAREPAGE_H
|
#define PREPAREPAGE_H
|
||||||
|
|
||||||
|
#include "PrepareViewStep.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ class PreparePage : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit PreparePage( QWidget* parent = nullptr );
|
explicit PreparePage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
void init( const QList< QPair< QString, bool > >& checkEntries );
|
void init( const QList< PrepareEntry >& checkEntries );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QBoxLayout* m_entriesLayout;
|
QBoxLayout* m_entriesLayout;
|
||||||
|
@ -82,43 +82,82 @@ PrepareViewStep::PrepareViewStep( QObject* parent )
|
|||||||
connect( timer, &QTimer::timeout,
|
connect( timer, &QTimer::timeout,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
bool enoughStorage, enoughRam, hasPower, hasInternet;
|
bool enoughStorage = false;
|
||||||
|
bool enoughRam = false;
|
||||||
|
bool hasPower = false;
|
||||||
|
bool hasInternet = false;
|
||||||
|
|
||||||
qint64 requiredStorageB = m_requiredStorageGB * 1073741824L; /*powers of 2*/
|
qint64 requiredStorageB = m_requiredStorageGB * 1073741824L; /*powers of 2*/
|
||||||
cDebug() << "Need at least storage bytes:" << requiredStorageB;
|
cDebug() << "Need at least storage bytes:" << requiredStorageB;
|
||||||
enoughStorage = checkEnoughStorage( requiredStorageB );
|
if ( m_entriesToCheck.contains( "storage" ) )
|
||||||
|
enoughStorage = checkEnoughStorage( requiredStorageB );
|
||||||
|
|
||||||
qint64 requiredRamB = m_requiredRamGB * 1073741824L; /*powers of 2*/
|
qint64 requiredRamB = m_requiredRamGB * 1073741824L; /*powers of 2*/
|
||||||
cDebug() << "Need at least ram bytes:" << requiredRamB;
|
cDebug() << "Need at least ram bytes:" << requiredRamB;
|
||||||
enoughRam = checkEnoughRam( requiredRamB );
|
if ( m_entriesToCheck.contains( "ram" ) )
|
||||||
|
enoughRam = checkEnoughRam( requiredRamB );
|
||||||
|
|
||||||
|
if ( m_entriesToCheck.contains( "power" ) )
|
||||||
|
hasPower = checkHasPower();
|
||||||
|
|
||||||
|
if ( m_entriesToCheck.contains( "internet" ) )
|
||||||
|
hasInternet = checkHasInternet();
|
||||||
|
|
||||||
hasPower = checkHasPower();
|
|
||||||
hasInternet = checkHasInternet();
|
|
||||||
cDebug() << "enoughStorage, enoughRam, hasPower, hasInternet: "
|
cDebug() << "enoughStorage, enoughRam, hasPower, hasInternet: "
|
||||||
<< enoughStorage << enoughRam << hasPower << hasInternet;
|
<< enoughStorage << enoughRam << hasPower << hasInternet;
|
||||||
|
|
||||||
QList< QPair< QString, bool > > checkEntries;
|
QList< PrepareEntry > checkEntries;
|
||||||
checkEntries.append( qMakePair(
|
foreach ( const QString& entry, m_entriesToCheck )
|
||||||
tr( "has at least %1 GB available drive space" )
|
{
|
||||||
.arg( m_requiredStorageGB ),
|
if ( entry == "storage" )
|
||||||
enoughStorage ) );
|
checkEntries.append( {
|
||||||
checkEntries.append( qMakePair(
|
entry,
|
||||||
tr( "has at least %1 GB working memory" )
|
tr( "has at least %1 GB available drive space" )
|
||||||
.arg( m_requiredRamGB ),
|
.arg( m_requiredStorageGB ),
|
||||||
enoughRam ) );
|
enoughStorage,
|
||||||
checkEntries.append( qMakePair(
|
m_entriesToRequire.contains( entry )
|
||||||
tr( "is plugged in to a power source" ),
|
} );
|
||||||
hasPower ) );
|
else if ( entry == "ram" )
|
||||||
checkEntries.append( qMakePair(
|
checkEntries.append( {
|
||||||
tr( "is connected to the Internet" ),
|
entry,
|
||||||
hasInternet ) );
|
tr( "has at least %1 GB working memory" )
|
||||||
|
.arg( m_requiredRamGB ),
|
||||||
|
enoughRam,
|
||||||
|
m_entriesToRequire.contains( entry )
|
||||||
|
} );
|
||||||
|
else if ( entry == "power" )
|
||||||
|
checkEntries.append( {
|
||||||
|
entry,
|
||||||
|
tr( "is plugged in to a power source" ),
|
||||||
|
hasPower,
|
||||||
|
m_entriesToRequire.contains( entry )
|
||||||
|
} );
|
||||||
|
else if ( entry == "internet" )
|
||||||
|
checkEntries.append( {
|
||||||
|
entry,
|
||||||
|
tr( "is connected to the Internet" ),
|
||||||
|
hasInternet,
|
||||||
|
m_entriesToRequire.contains( entry )
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
m_actualWidget->init( checkEntries );
|
m_actualWidget->init( checkEntries );
|
||||||
m_widget->layout()->removeWidget( waitingWidget );
|
m_widget->layout()->removeWidget( waitingWidget );
|
||||||
waitingWidget->deleteLater();
|
waitingWidget->deleteLater();
|
||||||
m_widget->layout()->addWidget( m_actualWidget );
|
m_widget->layout()->addWidget( m_actualWidget );
|
||||||
m_nextEnabled = true;
|
|
||||||
|
bool canGoNext = true;
|
||||||
|
foreach ( const PrepareEntry& entry, checkEntries )
|
||||||
|
{
|
||||||
|
if ( !entry.checked && entry.required )
|
||||||
|
{
|
||||||
|
canGoNext = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_nextEnabled = canGoNext;
|
||||||
emit nextStatusChanged( m_nextEnabled );
|
emit nextStatusChanged( m_nextEnabled );
|
||||||
|
|
||||||
timer->deleteLater();
|
timer->deleteLater();
|
||||||
} );
|
} );
|
||||||
timer->start( 0 );
|
timer->start( 0 );
|
||||||
@ -222,6 +261,20 @@ PrepareViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
{
|
{
|
||||||
m_requiredRamGB = 1.;
|
m_requiredRamGB = 1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( configurationMap.contains( "check" ) &&
|
||||||
|
configurationMap.value( "check" ).type() == QVariant::List )
|
||||||
|
{
|
||||||
|
m_entriesToCheck.clear();
|
||||||
|
m_entriesToCheck.append( configurationMap.value( "check" ).toStringList() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( configurationMap.contains( "required" ) &&
|
||||||
|
configurationMap.value( "required" ).type() == QVariant::List )
|
||||||
|
{
|
||||||
|
m_entriesToRequire.clear();
|
||||||
|
m_entriesToRequire.append( configurationMap.value( "required" ).toStringList() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,12 +20,21 @@
|
|||||||
#define PREPAREPAGEPLUGIN_H
|
#define PREPAREPAGEPLUGIN_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "PluginDllMacro.h"
|
||||||
|
|
||||||
class PreparePage;
|
class PreparePage;
|
||||||
|
|
||||||
|
struct PrepareEntry
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
QString text;
|
||||||
|
bool checked;
|
||||||
|
bool required;
|
||||||
|
};
|
||||||
|
|
||||||
class PLUGINDLLEXPORT PrepareViewStep : public Calamares::ViewStep
|
class PLUGINDLLEXPORT PrepareViewStep : public Calamares::ViewStep
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -56,6 +65,9 @@ public:
|
|||||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QStringList m_entriesToCheck;
|
||||||
|
QStringList m_entriesToRequire;
|
||||||
|
|
||||||
bool checkEnoughStorage( qint64 requiredSpace );
|
bool checkEnoughStorage( qint64 requiredSpace );
|
||||||
bool checkEnoughRam( qint64 requiredRam );
|
bool checkEnoughRam( qint64 requiredRam );
|
||||||
bool checkBatteryExists();
|
bool checkBatteryExists();
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
---
|
---
|
||||||
requiredStorage: 5.5
|
requiredStorage: 5.5
|
||||||
requiredRam: 2.0
|
requiredRam: 2.0
|
||||||
|
check:
|
||||||
|
- storage
|
||||||
|
- ram
|
||||||
|
- power
|
||||||
|
- internet
|
||||||
|
required:
|
||||||
|
- storage
|
||||||
|
- ram
|
Loading…
Reference in New Issue
Block a user