2014-08-21 17:50:37 +02:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
2017-02-03 15:17:11 +01:00
|
|
|
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
2014-08-21 17:50:37 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
#ifndef REQUIREMENTSCHECKER_H
|
|
|
|
#define REQUIREMENTSCHECKER_H
|
2014-11-13 16:51:23 +01:00
|
|
|
|
2014-08-21 17:50:37 +02:00
|
|
|
#include <QObject>
|
2014-08-26 17:26:40 +02:00
|
|
|
#include <QStringList>
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2014-11-13 16:51:23 +01:00
|
|
|
#include <functional>
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
class CheckerWidget;
|
|
|
|
class QWidget;
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2017-11-20 14:18:39 +01:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
2014-08-26 17:26:40 +02:00
|
|
|
struct PrepareEntry
|
|
|
|
{
|
|
|
|
QString name;
|
2015-05-15 13:09:30 +02:00
|
|
|
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.
|
2014-08-26 17:26:40 +02:00
|
|
|
bool checked;
|
|
|
|
bool required;
|
|
|
|
};
|
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
class RequirementsChecker : public QObject
|
2014-08-21 17:50:37 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-05-14 18:00:26 +02:00
|
|
|
explicit RequirementsChecker( QObject* parent = nullptr );
|
|
|
|
virtual ~RequirementsChecker();
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
QWidget* widget() const;
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
void setConfigurationMap( const QVariantMap& configurationMap );
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
bool verdict() const;
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
signals:
|
|
|
|
void verdictChanged( bool );
|
2014-08-21 17:50:37 +02:00
|
|
|
|
|
|
|
private:
|
2014-08-26 17:26:40 +02:00
|
|
|
QStringList m_entriesToCheck;
|
|
|
|
QStringList m_entriesToRequire;
|
|
|
|
|
2014-08-22 15:16:45 +02:00
|
|
|
bool checkEnoughStorage( qint64 requiredSpace );
|
|
|
|
bool checkEnoughRam( qint64 requiredRam );
|
2014-08-25 15:02:09 +02:00
|
|
|
bool checkBatteryExists();
|
2014-08-21 17:50:37 +02:00
|
|
|
bool checkHasPower();
|
|
|
|
bool checkHasInternet();
|
2015-06-09 02:13:22 +02:00
|
|
|
bool checkIsRoot();
|
2014-11-19 13:58:18 +01:00
|
|
|
void detectFirmwareType();
|
2014-08-21 17:50:37 +02:00
|
|
|
|
|
|
|
QWidget* m_widget;
|
2014-08-22 15:16:45 +02:00
|
|
|
qreal m_requiredStorageGB;
|
|
|
|
qreal m_requiredRamGB;
|
2017-02-03 15:17:11 +01:00
|
|
|
QString m_checkHasInternetUrl;
|
2014-08-21 17:50:37 +02:00
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
CheckerWidget* m_actualWidget;
|
|
|
|
bool m_verdict;
|
2014-08-21 17:50:37 +02:00
|
|
|
};
|
|
|
|
|
2015-05-14 18:00:26 +02:00
|
|
|
#endif // REQUIREMENTSCHECKER_H
|