2020-03-10 22:44:48 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* Copyright 2019-2020, 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 WELCOME_CONFIG_H
|
|
|
|
#define WELCOME_CONFIG_H
|
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
#include "modulesystem/Requirement.h"
|
2020-03-25 12:00:41 +01:00
|
|
|
#include "locale/LabelModel.h"
|
|
|
|
|
2020-03-10 22:44:48 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QUrl>
|
|
|
|
|
2020-03-25 12:00:41 +01:00
|
|
|
// TODO: move this (and modulesystem/Requirement) to libcalamares
|
2020-03-10 22:44:48 +01:00
|
|
|
class RequirementsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-03-25 11:41:39 +01:00
|
|
|
Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL )
|
|
|
|
Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL )
|
2020-03-24 15:26:24 +01:00
|
|
|
Q_PROPERTY( QString warningMessage READ warningMessage NOTIFY warningMessageChanged FINAL )
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
public:
|
2020-03-25 12:00:41 +01:00
|
|
|
using QAbstractListModel::QAbstractListModel;
|
|
|
|
|
2020-03-10 22:44:48 +01:00
|
|
|
enum Roles : short
|
|
|
|
{
|
|
|
|
Name,
|
|
|
|
Satisfied,
|
|
|
|
Mandatory,
|
|
|
|
Details,
|
|
|
|
NegatedText,
|
|
|
|
HasDetails
|
|
|
|
};
|
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
bool satisfiedRequirements() const { return m_satisfiedRequirements; }
|
2020-03-10 22:44:48 +01:00
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
bool satisfiedMandatory() const { return m_satisfiedMandatory; }
|
2020-03-10 22:44:48 +01:00
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
const Calamares::RequirementEntry& getEntry( const int& index ) const
|
2020-03-10 22:44:48 +01:00
|
|
|
{
|
2020-03-25 11:41:39 +01:00
|
|
|
if ( index > count() || index < 0 )
|
|
|
|
{
|
|
|
|
return *( new Calamares::RequirementEntry() );
|
|
|
|
}
|
2020-03-10 22:44:48 +01:00
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
return m_requirements.at( index );
|
2020-03-10 22:44:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setRequirementsList( const Calamares::RequirementsList& requirements );
|
2020-03-25 11:41:39 +01:00
|
|
|
int rowCount( const QModelIndex& ) const override;
|
|
|
|
int count() const { return m_requirements.count(); }
|
2020-03-10 22:44:48 +01:00
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
QString warningMessage() const { return m_warningMessage; }
|
2020-03-24 15:26:24 +01:00
|
|
|
|
|
|
|
void retranslate();
|
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
QVariant data( const QModelIndex& index, int role ) const override;
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
protected:
|
2020-03-25 11:41:39 +01:00
|
|
|
QHash< int, QByteArray > roleNames() const override;
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
private:
|
2020-03-24 16:39:29 +01:00
|
|
|
Calamares::RequirementsList m_requirements;
|
2020-03-10 22:44:48 +01:00
|
|
|
bool m_satisfiedRequirements = false;
|
|
|
|
bool m_satisfiedMandatory = false;
|
|
|
|
|
2020-03-24 15:26:24 +01:00
|
|
|
QString m_warningMessage;
|
|
|
|
|
2020-03-10 22:44:48 +01:00
|
|
|
signals:
|
2020-03-25 11:41:39 +01:00
|
|
|
void satisfiedRequirementsChanged( bool value );
|
2020-03-10 22:44:48 +01:00
|
|
|
void satisfiedMandatoryChanged();
|
2020-03-24 15:26:24 +01:00
|
|
|
void warningMessageChanged();
|
2020-03-10 22:44:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Config : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-03-25 11:41:39 +01:00
|
|
|
Q_PROPERTY( CalamaresUtils::Locale::LabelModel* languagesModel READ languagesModel CONSTANT FINAL )
|
2020-03-10 22:44:48 +01:00
|
|
|
Q_PROPERTY( RequirementsModel* requirementsModel MEMBER m_requirementsModel CONSTANT FINAL )
|
|
|
|
|
|
|
|
Q_PROPERTY( QString languageIcon READ languageIcon CONSTANT FINAL )
|
|
|
|
|
|
|
|
Q_PROPERTY( QString countryCode MEMBER m_countryCode NOTIFY countryCodeChanged FINAL )
|
2020-03-25 11:41:39 +01:00
|
|
|
Q_PROPERTY( int localeIndex READ localeIndex WRITE setLocaleIndex NOTIFY localeIndexChanged )
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
Q_PROPERTY( QString genericWelcomeMessage MEMBER m_genericWelcomeMessage NOTIFY genericWelcomeMessageChanged FINAL )
|
|
|
|
|
2020-03-24 15:26:24 +01:00
|
|
|
Q_PROPERTY( QString supportUrl MEMBER m_supportUrl NOTIFY supportUrlChanged FINAL )
|
|
|
|
Q_PROPERTY( QString knownIssuesUrl MEMBER m_knownIssuesUrl NOTIFY knownIssuesUrlChanged FINAL )
|
|
|
|
Q_PROPERTY( QString releaseNotesUrl MEMBER m_releaseNotesUrl NOTIFY releaseNotesUrlChanged FINAL )
|
2020-03-25 11:41:39 +01:00
|
|
|
Q_PROPERTY( QString donateUrl MEMBER m_donateUrl NOTIFY donateUrlChanged FINAL )
|
2020-03-24 15:26:24 +01:00
|
|
|
|
|
|
|
Q_PROPERTY( bool isNextEnabled MEMBER m_isNextEnabled NOTIFY isNextEnabledChanged FINAL )
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
Config( QObject* parent = nullptr );
|
2020-03-25 11:41:39 +01:00
|
|
|
void setCountryCode( const QString& countryCode );
|
|
|
|
void setLanguageIcon( const QString& languageIcon );
|
|
|
|
RequirementsModel& requirementsModel() const;
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
void setIsNextEnabled( const bool& isNextEnabled );
|
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
void setLocaleIndex( const int& index );
|
2020-03-10 22:44:48 +01:00
|
|
|
int localeIndex() const { return m_localeIndex; }
|
|
|
|
|
|
|
|
QString supportUrl() const;
|
2020-03-25 11:41:39 +01:00
|
|
|
void setSupportUrl( const QString& url );
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
QString knownIssuesUrl() const;
|
2020-03-25 11:41:39 +01:00
|
|
|
void setKnownIssuesUrl( const QString& url );
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
QString releaseNotesUrl() const;
|
2020-03-25 11:41:39 +01:00
|
|
|
void setReleaseNotesUrl( const QString& url );
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
QString donateUrl() const;
|
2020-03-25 11:41:39 +01:00
|
|
|
void setDonateUrl( const QString& url );
|
2020-03-10 22:44:48 +01:00
|
|
|
|
2020-03-24 16:39:29 +01:00
|
|
|
QString genericWelcomeMessage();
|
|
|
|
|
|
|
|
|
2020-03-10 22:44:48 +01:00
|
|
|
public slots:
|
|
|
|
CalamaresUtils::Locale::LabelModel* languagesModel() const;
|
|
|
|
void retranslate();
|
|
|
|
QString languageIcon() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initLanguages();
|
|
|
|
QVariantMap m_configurationMap;
|
|
|
|
RequirementsModel* m_requirementsModel;
|
|
|
|
QString m_languageIcon;
|
|
|
|
QString m_countryCode;
|
|
|
|
int m_localeIndex = 0;
|
|
|
|
bool m_isNextEnabled = false;
|
|
|
|
CalamaresUtils::Locale::LabelModel* m_languages;
|
|
|
|
|
2020-03-24 15:26:24 +01:00
|
|
|
QString m_genericWelcomeMessage;
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
QString m_supportUrl;
|
|
|
|
QString m_knownIssuesUrl;
|
|
|
|
QString m_releaseNotesUrl;
|
|
|
|
QString m_donateUrl;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void countryCodeChanged( QString countryCode );
|
|
|
|
void localeIndexChanged( int localeIndex );
|
|
|
|
void isNextEnabledChanged( bool isNextEnabled );
|
|
|
|
void genericWelcomeMessageChanged();
|
2020-03-24 15:26:24 +01:00
|
|
|
void supportUrlChanged();
|
|
|
|
void knownIssuesUrlChanged();
|
|
|
|
void releaseNotesUrlChanged();
|
|
|
|
void donateUrlChanged();
|
2020-03-10 22:44:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|