2019-02-20 11:48:15 +01:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
#ifndef CALAMARES_REQUIREMENTSCHECKER_H
|
|
|
|
#define CALAMARES_REQUIREMENTSCHECKER_H
|
|
|
|
|
2020-03-31 22:13:30 +02:00
|
|
|
#include "modulesystem/Requirement.h"
|
2019-02-25 12:33:46 +01:00
|
|
|
|
2019-02-23 17:12:55 +01:00
|
|
|
#include <QFutureWatcher>
|
2019-02-20 11:48:15 +01:00
|
|
|
#include <QObject>
|
2019-02-25 12:33:46 +01:00
|
|
|
#include <QTimer>
|
2019-02-20 11:48:15 +01:00
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
namespace Calamares
|
|
|
|
{
|
|
|
|
|
|
|
|
class Module;
|
2020-05-11 15:35:03 +02:00
|
|
|
class RequirementsModel;
|
2019-02-20 11:48:15 +01:00
|
|
|
|
|
|
|
/** @brief A manager-class that checks all the module requirements
|
|
|
|
*
|
|
|
|
* Asynchronously checks the requirements for each module, and
|
|
|
|
* emits progress signals as appropriate.
|
|
|
|
*/
|
|
|
|
class RequirementsChecker : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-05-11 15:35:03 +02:00
|
|
|
RequirementsChecker( QVector< Module* > modules, RequirementsModel* model, QObject* parent = nullptr );
|
2019-02-20 11:48:15 +01:00
|
|
|
virtual ~RequirementsChecker() override;
|
|
|
|
|
2020-03-31 23:13:13 +02:00
|
|
|
public Q_SLOTS:
|
2019-02-25 12:33:46 +01:00
|
|
|
/// @brief Start checking all the requirements
|
2019-02-20 11:48:15 +01:00
|
|
|
void run();
|
|
|
|
|
2019-02-25 12:33:46 +01:00
|
|
|
/// @brief Called when requirements are reported by a module
|
2020-05-11 15:42:27 +02:00
|
|
|
void addCheckedRequirements( Module* );
|
2019-02-23 17:12:55 +01:00
|
|
|
|
2019-02-25 12:33:46 +01:00
|
|
|
/// @brief Called when all requirements have been checked
|
2019-02-23 17:12:55 +01:00
|
|
|
void finished();
|
|
|
|
|
2019-02-25 12:33:46 +01:00
|
|
|
/// @brief Called periodically while requirements are being checked
|
|
|
|
void reportProgress();
|
|
|
|
|
2019-02-20 11:48:15 +01:00
|
|
|
signals:
|
|
|
|
/// @brief Human-readable progress message
|
|
|
|
void requirementsProgress( const QString& );
|
|
|
|
/// @brief Emitted after requirementsComplete
|
|
|
|
void done();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QVector< Module* > m_modules;
|
2019-02-23 17:12:55 +01:00
|
|
|
|
|
|
|
using Watcher = QFutureWatcher< void >;
|
|
|
|
QVector< Watcher* > m_watchers;
|
|
|
|
|
2020-05-11 15:35:03 +02:00
|
|
|
RequirementsModel* m_model;
|
2019-02-25 12:33:46 +01:00
|
|
|
|
2019-06-27 15:15:47 +02:00
|
|
|
QTimer* m_progressTimer;
|
2019-02-25 12:39:50 +01:00
|
|
|
unsigned m_progressTimeouts;
|
2019-06-27 15:15:47 +02:00
|
|
|
};
|
2019-02-20 11:48:15 +01:00
|
|
|
|
2019-06-27 15:15:47 +02:00
|
|
|
} // namespace Calamares
|
2019-02-20 11:48:15 +01:00
|
|
|
|
|
|
|
#endif
|