source: calamares/trunk/fuentes/src/modules/welcome/checker/RequirementsChecker.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 2.6 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef REQUIREMENTSCHECKER_H
21#define REQUIREMENTSCHECKER_H
22
23#include <QObject>
24#include <QStringList>
25
26#include <functional>
27
28class CheckerWidget;
29class QWidget;
30
31/**
32 * An indication of a requirement, which is checked in preparation
33 * for system installation. An entry has a name and some explanation,
34 * as well as three meaningful states:
35 *  - checked = true, the requirement is met (green)
36 *  - checked = false, the requirement is not met
37 *      - required = false, warn about it (yellow), no failure
38 *      - required = true, prohibit installation (red)
39 */
40struct PrepareEntry
41{
42    QString name;
43    std::function< QString() > enumerationText; //Partial string, inserted in a
44                                                //list of requirements to satisfy.
45    std::function< QString() > negatedText;     //Complete sentence about this requirement
46                                                //not having been met.
47    bool checked;
48    bool required;
49};
50
51class RequirementsChecker : public QObject
52{
53    Q_OBJECT
54public:
55    explicit RequirementsChecker( QObject* parent = nullptr );
56    virtual ~RequirementsChecker();
57
58    QWidget* widget() const;
59
60    void setConfigurationMap( const QVariantMap& configurationMap );
61
62    bool verdict() const;
63
64signals:
65    void verdictChanged( bool );
66
67private:
68    QStringList m_entriesToCheck;
69    QStringList m_entriesToRequire;
70
71    bool checkEnoughStorage( qint64 requiredSpace );
72    bool checkEnoughRam( qint64 requiredRam );
73    bool checkBatteryExists();
74    bool checkHasPower();
75    bool checkHasInternet();
76    bool checkIsRoot();
77    void detectFirmwareType();
78
79    QWidget* m_widget;
80    qreal m_requiredStorageGB;
81    qreal m_requiredRamGB;
82    QString m_checkHasInternetUrl;
83
84    CheckerWidget* m_actualWidget;
85    bool m_verdict;
86};
87
88#endif // REQUIREMENTSCHECKER_H
Note: See TracBrowser for help on using the repository browser.