Merge branch 'milohr-master'

FIXES #1336
This commit is contained in:
Adriaan de Groot 2020-03-11 15:23:42 +01:00
commit fa9006c677
18 changed files with 797 additions and 444 deletions

View File

@ -28,6 +28,8 @@ calamares_add_plugin( welcome
SOURCES SOURCES
${CHECKER_SOURCES} ${CHECKER_SOURCES}
WelcomeViewStep.cpp WelcomeViewStep.cpp
Config.cpp
Config.h
WelcomePage.cpp WelcomePage.cpp
UI UI
WelcomePage.ui WelcomePage.ui

View File

@ -0,0 +1,273 @@
/* === 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/>.
*/
#include "Config.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include "Branding.h"
#include "Settings.h"
#include <QApplication>
void
RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requirements )
{
emit beginResetModel();
m_requierements = requirements;
m_satisfiedRequirements = true;
auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; };
auto isMandatoryAndUnSatisfied = []( const Calamares::RequirementEntry& e ) { return e.mandatory && !e.satisfied; };
m_satisfiedRequirements = std::none_of( m_requierements.begin(), m_requierements.end(), isUnSatisfied );
m_satisfiedMandatory = std::none_of( m_requierements.begin(), m_requierements.end(), isMandatoryAndUnSatisfied );
emit satisfiedRequirementsChanged(m_satisfiedRequirements);
emit satisfiedMandatoryChanged();
emit endResetModel();
}
int
RequirementsModel::rowCount( const QModelIndex& ) const
{
return m_requierements.count();
}
QVariant
RequirementsModel::data( const QModelIndex& index, int role ) const
{
const auto requirement = m_requierements.at( index.row() );
switch ( role )
{
case Roles::Name:
return requirement.name;
case Roles::Details:
return requirement.enumerationText();
case Roles::NegatedText:
return requirement.negatedText();
case Roles::Satisfied:
return requirement.satisfied;
case Roles::Mandatory:
return requirement.mandatory;
default:
return QVariant();
}
}
QHash<int, QByteArray>
RequirementsModel::roleNames() const
{
static QHash<int, QByteArray> roles;
roles[Roles::Name] = "name";
roles[Roles::Details] = "details";
roles[Roles::NegatedText] = "negatedText";
roles[Roles::Satisfied] = "satisfied";
roles[Roles::Mandatory] = "mandatory";
return roles;
}
Config::Config( QObject* parent ) : QObject( parent )
, m_requirementsModel( new RequirementsModel( this ))
, m_languages( CalamaresUtils::Locale::availableTranslations() )
{
connect(m_requirementsModel, &RequirementsModel::satisfiedRequirementsChanged, this, &Config::setIsNextEnabled);
initLanguages();
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate )
}
void
Config::retranslate()
{
QString message;
if ( Calamares::Settings::instance()->isSetupMode() )
{
message = Calamares::Branding::instance()->welcomeStyleCalamares()
? tr( "<h1>Welcome to the Calamares setup program for %1.</h1>" )
: tr( "<h1>Welcome to %1 setup.</h1>" );
}
else
{
message = Calamares::Branding::instance()->welcomeStyleCalamares()
? tr( "<h1>Welcome to the Calamares installer for %1.</h1>" )
: tr( "<h1>Welcome to the %1 installer.</h1>" );
}
m_genericWelcomeMessage = message.arg( *Calamares::Branding::VersionedName );
emit genericWelcomeMessageChanged();
// ui->supportButton->setText( tr( "%1 support" ).arg( *Calamares::Branding::ShortProductName ) );
}
CalamaresUtils::Locale::LabelModel*
Config::languagesModel() const
{
return m_languages;
}
QString
Config::languageIcon() const
{
return m_languageIcon;
}
void
Config::initLanguages()
{
// Find the best initial translation
QLocale defaultLocale = QLocale( QLocale::system().name() );
cDebug() << "Matching locale" << defaultLocale;
int matchedLocaleIndex = m_languages->find( [&]( const QLocale& x ) {
return x.language() == defaultLocale.language() && x.country() == defaultLocale.country();
} );
if ( matchedLocaleIndex < 0 )
{
cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
matchedLocaleIndex
= m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } );
}
if ( matchedLocaleIndex < 0 )
{
QLocale en_us( QLocale::English, QLocale::UnitedStates );
cDebug() << Logger::SubEntry << "Matching English (US)";
matchedLocaleIndex = m_languages->find( en_us );
// Now, if it matched, because we didn't match the system locale, switch to the one found
if ( matchedLocaleIndex >= 0 )
{
QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() );
}
}
if ( matchedLocaleIndex >= 0 )
{
QString name = m_languages->locale( matchedLocaleIndex ).name();
cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsDirectory(), qApp );
setLocaleIndex( matchedLocaleIndex );
}
else
{
cWarning() << "No available translation matched" << defaultLocale;
}
}
void
Config::setCountryCode( const QString& countryCode )
{
m_countryCode = countryCode;
setLocaleIndex(CalamaresUtils::Locale::availableTranslations()->find( m_countryCode ));
emit countryCodeChanged( m_countryCode );
}
void
Config::setLanguageIcon(const QString &languageIcon )
{
m_languageIcon = languageIcon;
}
void
Config::setLocaleIndex(const int& index)
{
if(index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount(QModelIndex()) || index < 0)
return;
m_localeIndex = index;
const auto& selectedLocale = m_languages->locale( m_localeIndex ).locale();
cDebug() << "Selected locale" << selectedLocale;
QLocale::setDefault( selectedLocale );
CalamaresUtils::installTranslator(
selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
emit localeIndexChanged( m_localeIndex );
}
RequirementsModel&
Config::requirementsModel() const
{
return *m_requirementsModel;
}
void
Config::setIsNextEnabled( const bool& isNextEnabled )
{
m_isNextEnabled = isNextEnabled;
emit isNextEnabledChanged( m_isNextEnabled );
}
QString Config::donateUrl() const
{
return m_donateUrl;
}
void Config::setDonateUrl(const QString& url)
{
m_donateUrl = url;
}
QString Config::knownIssuesUrl() const
{
return m_knownIssuesUrl;
}
void Config::setKnownIssuesUrl(const QString& url)
{
m_knownIssuesUrl = url;
}
void Config::setReleaseNotesUrl(const QString& url)
{
m_releaseNotesUrl = url;
}
QString Config::releaseNotesUrl() const
{
return m_releaseNotesUrl;
}
QString Config::supportUrl() const
{
return m_supportUrl;
}
void Config::setSupportUrl(const QString& url)
{
m_supportUrl = url;
}

View File

@ -0,0 +1,163 @@
/* === 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
#include <QObject>
#include <QUrl>
#include "modulesystem/Requirement.h"
#include "locale/LabelModel.h"
class RequirementsModel : public QAbstractListModel
{
Q_OBJECT
using QAbstractListModel::QAbstractListModel;
Q_PROPERTY(bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL)
Q_PROPERTY(bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL)
public:
enum Roles : short
{
Name,
Satisfied,
Mandatory,
Details,
NegatedText,
HasDetails
};
bool satisfiedRequirements() const
{
return m_satisfiedRequirements;
}
bool satisfiedMandatory() const
{
return m_satisfiedMandatory;
}
const Calamares::RequirementEntry& getEntry(const int& index) const
{
if(index > count() || index < 0)
return *(new Calamares::RequirementEntry());
return m_requierements.at(index);
}
void setRequirementsList( const Calamares::RequirementsList& requirements );
int rowCount(const QModelIndex&) const override;
int count() const
{
return m_requierements.count();
}
QVariant data(const QModelIndex& index, int role) const override;
protected:
QHash<int, QByteArray> roleNames() const override;
private:
Calamares::RequirementsList m_requierements;
bool m_satisfiedRequirements = false;
bool m_satisfiedMandatory = false;
signals:
void satisfiedRequirementsChanged(bool value);
void satisfiedMandatoryChanged();
};
class Config : public QObject
{
Q_OBJECT
Q_PROPERTY( CalamaresUtils::Locale::LabelModel* languagesModel READ languagesModel CONSTANT FINAL)
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 )
Q_PROPERTY (int localeIndex READ localeIndex WRITE setLocaleIndex NOTIFY localeIndexChanged)
Q_PROPERTY( QString genericWelcomeMessage MEMBER m_genericWelcomeMessage NOTIFY genericWelcomeMessageChanged FINAL )
Q_PROPERTY( QString warningMessage MEMBER m_warningMessage CONSTANT FINAL )
Q_PROPERTY(QString supportUrl MEMBER m_supportUrl CONSTANT FINAL)
Q_PROPERTY(QString knownIssuesUrl MEMBER m_knownIssuesUrl CONSTANT FINAL)
Q_PROPERTY(QString releaseNotesUrl MEMBER m_releaseNotesUrl CONSTANT FINAL)
Q_PROPERTY(QString donateUrl MEMBER m_donateUrl CONSTANT FINAL)
public:
Config( QObject* parent = nullptr );
void setCountryCode( const QString &countryCode );
void setLanguageIcon( const QString &languageIcon );
RequirementsModel& requirementsModel () const;
void setIsNextEnabled( const bool& isNextEnabled );
void setLocaleIndex(const int &index);
int localeIndex() const { return m_localeIndex; }
QString supportUrl() const;
void setSupportUrl(const QString &url);
QString knownIssuesUrl() const;
void setKnownIssuesUrl(const QString &url);
QString releaseNotesUrl() const;
void setReleaseNotesUrl(const QString &url);
QString donateUrl() const;
void setDonateUrl(const QString &url);
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;
QString m_genericWelcomeMessage = tr("This program will ask you some questions and set up your installation");
QString m_warningMessage = tr("This program does not satisfy the minimum requirements for installing.\nInstallation can not continue");
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();
};
#endif

View File

@ -27,6 +27,7 @@
#include "CalamaresVersion.h" #include "CalamaresVersion.h"
#include "Settings.h" #include "Settings.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "Config.h"
#include "locale/LabelModel.h" #include "locale/LabelModel.h"
#include "modulesystem/ModuleManager.h" #include "modulesystem/ModuleManager.h"
@ -43,16 +44,14 @@
#include <QLabel> #include <QLabel>
#include <QMessageBox> #include <QMessageBox>
WelcomePage::WelcomePage( QWidget* parent ) WelcomePage::WelcomePage( Config *conf, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::WelcomePage ) , ui( new Ui::WelcomePage )
, m_checkingWidget( new CheckerContainer( this ) ) , m_checkingWidget( new CheckerContainer( conf->requirementsModel(), this ) )
, m_languages( nullptr ) , m_languages( nullptr )
, m_conf( conf )
{ {
connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsResult,
m_checkingWidget,
&CheckerContainer::requirementsChecked );
connect( Calamares::ModuleManager::instance(), connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsComplete, &Calamares::ModuleManager::requirementsComplete,
m_checkingWidget, m_checkingWidget,
@ -85,6 +84,21 @@ WelcomePage::WelcomePage( QWidget* parent )
ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget ); ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget );
} }
void WelcomePage::init()
{
//setup the url buttons
setupButton( WelcomePage::Button::Support, m_conf->supportUrl());
setupButton( WelcomePage::Button::KnownIssues, m_conf->knownIssuesUrl() );
setupButton( WelcomePage::Button::ReleaseNotes, m_conf->releaseNotesUrl() );
setupButton( WelcomePage::Button::Donate, m_conf->donateUrl());
//language icon
auto icon = Calamares::Branding::instance()->image( m_conf->languageIcon(), QSize( 48, 48 ) );
if ( !icon.isNull() )
{
setLanguageIcon( icon );
}
}
void void
WelcomePage::initLanguages() WelcomePage::initLanguages()
@ -93,67 +107,15 @@ WelcomePage::initLanguages()
ui->languageWidget->clear(); ui->languageWidget->clear();
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom ); ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
m_languages = CalamaresUtils::Locale::availableTranslations(); ui->languageWidget->setModel( m_conf->languagesModel() );
ui->languageWidget->setModel( m_languages );
ui->languageWidget->setItemDelegate( new LocaleTwoColumnDelegate( ui->languageWidget ) ); ui->languageWidget->setItemDelegate( new LocaleTwoColumnDelegate( ui->languageWidget ) );
// Find the best initial translation ui->languageWidget->setCurrentIndex( m_conf->localeIndex() );
QLocale defaultLocale = QLocale( QLocale::system().name() );
cDebug() << "Matching locale" << defaultLocale;
int matchedLocaleIndex = m_languages->find( [&]( const QLocale& x ) {
return x.language() == defaultLocale.language() && x.country() == defaultLocale.country();
} );
if ( matchedLocaleIndex < 0 )
{
cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
matchedLocaleIndex
= m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } );
}
if ( matchedLocaleIndex < 0 )
{
QLocale en_us( QLocale::English, QLocale::UnitedStates );
cDebug() << Logger::SubEntry << "Matching English (US)";
matchedLocaleIndex = m_languages->find( en_us );
// Now, if it matched, because we didn't match the system locale, switch to the one found
if ( matchedLocaleIndex >= 0 )
{
QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() );
}
}
if ( matchedLocaleIndex >= 0 )
{
QString name = m_languages->locale( matchedLocaleIndex ).name();
cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsDirectory(), qApp );
ui->languageWidget->setCurrentIndex( matchedLocaleIndex );
}
else
{
cWarning() << "No available translation matched" << defaultLocale;
}
connect( ui->languageWidget, connect( ui->languageWidget,
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), m_conf, &Config::setLocaleIndex );
this,
[&]( int newIndex ) {
const auto& selectedLocale = m_languages->locale( newIndex ).locale();
cDebug() << "Selected locale" << selectedLocale;
QLocale::setDefault( selectedLocale );
CalamaresUtils::installTranslator(
selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
} );
} }
void void
WelcomePage::setupButton( Button role, const QString& url ) WelcomePage::setupButton( Button role, const QString& url )
{ {

View File

@ -31,12 +31,12 @@ class WelcomePage;
} }
class CheckerContainer; class CheckerContainer;
class Config;
class WelcomePage : public QWidget class WelcomePage : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WelcomePage( QWidget* parent = nullptr ); explicit WelcomePage( Config *conf, QWidget* parent = nullptr );
enum class Button enum class Button
{ {
@ -58,6 +58,8 @@ public:
/// @brief Change the language from an external source. /// @brief Change the language from an external source.
void externallySelectedLanguage( int row ); void externallySelectedLanguage( int row );
void init();
public slots: public slots:
void retranslate(); void retranslate();
void showAboutBox(); void showAboutBox();
@ -72,6 +74,8 @@ private:
Ui::WelcomePage* ui; Ui::WelcomePage* ui;
CheckerContainer* m_checkingWidget; CheckerContainer* m_checkingWidget;
CalamaresUtils::Locale::LabelModel* m_languages; CalamaresUtils::Locale::LabelModel* m_languages;
Config *m_conf;
}; };
/** @brief Delegate to display language information in two columns. /** @brief Delegate to display language information in two columns.

View File

@ -18,6 +18,7 @@
*/ */
#include "WelcomeViewStep.h" #include "WelcomeViewStep.h"
#include "Config.h"
#include "WelcomePage.h" #include "WelcomePage.h"
#include "checker/GeneralRequirements.h" #include "checker/GeneralRequirements.h"
@ -38,14 +39,16 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeViewStepFactory, registerPlugin< Wel
WelcomeViewStep::WelcomeViewStep( QObject* parent ) WelcomeViewStep::WelcomeViewStep( QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
, m_requirementsChecker( new GeneralRequirements( this ) ) , m_requirementsChecker( new GeneralRequirements( this ) )
, m_conf( new Config(this) )
{ {
connect( Calamares::ModuleManager::instance(), connect( Calamares::ModuleManager::instance(),
&Calamares::ModuleManager::requirementsComplete, &Calamares::ModuleManager::requirementsComplete,
this, this,
&WelcomeViewStep::nextStatusChanged ); &WelcomeViewStep::nextStatusChanged );
m_widget = new WelcomePage();
}
// the instance of the qqc2 or qwidgets page
m_widget = new WelcomePage(m_conf);
}
WelcomeViewStep::~WelcomeViewStep() WelcomeViewStep::~WelcomeViewStep()
{ {
@ -55,7 +58,6 @@ WelcomeViewStep::~WelcomeViewStep()
} }
} }
QString QString
WelcomeViewStep::prettyName() const WelcomeViewStep::prettyName() const
{ {
@ -142,19 +144,17 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
using Calamares::Branding; using Calamares::Branding;
m_widget->setupButton( WelcomePage::Button::Support, m_conf->setSupportUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) ); m_conf->setKnownIssuesUrl( jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
m_widget->setupButton( WelcomePage::Button::KnownIssues, m_conf->setReleaseNotesUrl( jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) ); m_conf->setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
m_widget->setupButton( WelcomePage::Button::ReleaseNotes,
jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
m_widget->setupButton( WelcomePage::Button::Donate,
CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
if ( configurationMap.contains( "requirements" ) if ( configurationMap.contains( "requirements" )
&& configurationMap.value( "requirements" ).type() == QVariant::Map ) && configurationMap.value( "requirements" ).type() == QVariant::Map )
{ {
m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() );
m_conf->requirementsModel().setRequirementsList( checkRequirements() );
} }
else else
cWarning() << "no valid requirements map found in welcome " cWarning() << "no valid requirements map found in welcome "
@ -188,16 +188,14 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
} }
} }
QString language = CalamaresUtils::getString( configurationMap, "languageIcon" ); QString language = CalamaresUtils::getString( configurationMap, "languageIcon" );
if ( !language.isEmpty() ) if ( !language.isEmpty() )
{ {
auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) ); m_conf->setLanguageIcon( language );
if ( !icon.isNull() )
{
m_widget->setLanguageIcon( icon );
}
} }
//here init the qml or qwidgets needed bits
m_widget->init();
} }
Calamares::RequirementsList Calamares::RequirementsList
@ -240,9 +238,9 @@ WelcomeViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::
{ {
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)"; cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";
} }
if ( ( r >= 0 ) && m_widget ) if ( ( r >= 0 ) && m_conf )
{ {
m_widget->externallySelectedLanguage( r ); m_conf->setCountryCode( countryCode );
} }
} }
} }

View File

@ -19,16 +19,19 @@
#ifndef WELCOMEPAGEPLUGIN_H #ifndef WELCOMEPAGEPLUGIN_H
#define WELCOMEPAGEPLUGIN_H #define WELCOMEPAGEPLUGIN_H
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h"
#include <QObject> #include <QObject>
#include <modulesystem/Requirement.h>
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <DllMacro.h>
#include <QVariantMap> #include <QVariantMap>
class WelcomePage; class WelcomePage;
class GeneralRequirements; class GeneralRequirements;
class Config;
namespace CalamaresUtils namespace CalamaresUtils
{ {
namespace GeoIP namespace GeoIP
@ -72,6 +75,7 @@ public:
private: private:
WelcomePage* m_widget; WelcomePage* m_widget;
GeneralRequirements* m_requirementsChecker; GeneralRequirements* m_requirementsChecker;
Config *m_conf;
}; };
CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeViewStepFactory ) CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeViewStepFactory )

View File

@ -31,11 +31,12 @@
#include <QHBoxLayout> #include <QHBoxLayout>
CheckerContainer::CheckerContainer( QWidget* parent ) CheckerContainer::CheckerContainer( const RequirementsModel &model, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_waitingWidget( new WaitingWidget( QString(), this ) ) , m_waitingWidget( new WaitingWidget( QString(), this ) )
, m_checkerWidget( nullptr ) , m_checkerWidget( nullptr )
, m_verdict( false ) , m_verdict( false )
, m_model( model )
{ {
QBoxLayout* mainLayout = new QHBoxLayout; QBoxLayout* mainLayout = new QHBoxLayout;
setLayout( mainLayout ); setLayout( mainLayout );
@ -59,18 +60,12 @@ CheckerContainer::requirementsComplete( bool ok )
m_waitingWidget->deleteLater(); m_waitingWidget->deleteLater();
m_waitingWidget = nullptr; // Don't delete in destructor m_waitingWidget = nullptr; // Don't delete in destructor
m_checkerWidget = new ResultsListWidget( this, m_requirements ); m_checkerWidget = new ResultsListWidget( m_model, this);
layout()->addWidget( m_checkerWidget ); layout()->addWidget( m_checkerWidget );
m_verdict = ok; m_verdict = ok;
} }
void
CheckerContainer::requirementsChecked( const Calamares::RequirementsList& l )
{
m_requirements.append( l );
}
void void
CheckerContainer::requirementsProgress( const QString& message ) CheckerContainer::requirementsProgress( const QString& message )
{ {

View File

@ -24,8 +24,7 @@
#define CHECKERCONTAINER_H #define CHECKERCONTAINER_H
#include <QWidget> #include <QWidget>
#include "Config.h"
#include "modulesystem/Requirement.h"
class ResultsListWidget; class ResultsListWidget;
class WaitingWidget; class WaitingWidget;
@ -36,18 +35,17 @@ class WaitingWidget;
* a (list) diplay of the results, plus some explanation of the * a (list) diplay of the results, plus some explanation of the
* overall state of the entire list of results. * overall state of the entire list of results.
*/ */
class CheckerContainer : public QWidget class CheckerContainer : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CheckerContainer( QWidget* parent = nullptr ); explicit CheckerContainer(const RequirementsModel &model, QWidget* parent = nullptr );
virtual ~CheckerContainer(); virtual ~CheckerContainer();
bool verdict() const; bool verdict() const;
public slots: public slots:
void requirementsChecked( const Calamares::RequirementsList& );
/** @brief All the requirements are complete, switch to list view */ /** @brief All the requirements are complete, switch to list view */
void requirementsComplete( bool ); void requirementsComplete( bool );
@ -57,8 +55,10 @@ protected:
WaitingWidget *m_waitingWidget; WaitingWidget *m_waitingWidget;
ResultsListWidget *m_checkerWidget; ResultsListWidget *m_checkerWidget;
Calamares::RequirementsList m_requirements;
bool m_verdict; bool m_verdict;
private:
const RequirementsModel &m_model;
} ; } ;
#endif #endif

View File

@ -47,14 +47,16 @@
static void static void
createResultWidgets( QLayout* layout, createResultWidgets( QLayout* layout,
QList< ResultWidget* >& resultWidgets, QList< ResultWidget* >& resultWidgets,
const Calamares::RequirementsList& checkEntries, const RequirementsModel &model,
std::function< bool( const Calamares::RequirementEntry& ) > predicate ) std::function< bool( const Calamares::RequirementEntry& ) > predicate
)
{ {
resultWidgets.clear(); resultWidgets.clear();
resultWidgets.reserve( checkEntries.count() ); resultWidgets.reserve( model.count() );
for ( const auto& entry : checkEntries ) for ( auto i = 0; i < model.count(); i++ )
{ {
if ( !predicate( entry ) ) const auto &entry = model.getEntry(i);
if ( !predicate(entry))
{ {
resultWidgets.append( nullptr ); resultWidgets.append( nullptr );
continue; continue;
@ -91,27 +93,27 @@ public:
* The list must continue to exist for the lifetime of the dialog, * The list must continue to exist for the lifetime of the dialog,
* or UB happens. * or UB happens.
*/ */
ResultsListDialog( QWidget* parent, const Calamares::RequirementsList& checkEntries ); ResultsListDialog( const RequirementsModel& model, QWidget* parent );
virtual ~ResultsListDialog(); virtual ~ResultsListDialog();
private: private:
QLabel* m_title; QLabel* m_title;
QList< ResultWidget* > m_resultWidgets; ///< One widget for each entry with details available QList< ResultWidget* > m_resultWidgets; ///< One widget for each entry with details available
const Calamares::RequirementsList& m_entries; const RequirementsModel& m_model;
void retranslate(); void retranslate();
}; };
ResultsListDialog::ResultsListDialog( QWidget* parent, const Calamares::RequirementsList& checkEntries ) ResultsListDialog::ResultsListDialog( const RequirementsModel& model, QWidget* parent)
: QDialog( parent ) : QDialog( parent )
, m_entries( checkEntries ) , m_model( model )
{ {
auto* mainLayout = new QVBoxLayout; auto* mainLayout = new QVBoxLayout;
auto* entriesLayout = new QVBoxLayout; auto* entriesLayout = new QVBoxLayout;
m_title = new QLabel( this ); m_title = new QLabel( this );
createResultWidgets( entriesLayout, m_resultWidgets, checkEntries, []( const Calamares::RequirementEntry& e ) { createResultWidgets( entriesLayout, m_resultWidgets, model, []( const Calamares::RequirementEntry& e ) {
return e.hasDetails(); return e.hasDetails();
} ); } );
@ -137,21 +139,20 @@ ResultsListDialog::retranslate()
m_title->setText( tr( "For best results, please ensure that this computer:" ) ); m_title->setText( tr( "For best results, please ensure that this computer:" ) );
setWindowTitle( tr( "System requirements" ) ); setWindowTitle( tr( "System requirements" ) );
int i = 0; for ( auto i = 0; i < m_model.count(); i++ )
for ( const auto& entry : m_entries )
{ {
const auto &entry = m_model.getEntry(i);
if ( m_resultWidgets[ i ] ) if ( m_resultWidgets[ i ] )
{ {
m_resultWidgets[ i ]->setText( entry.enumerationText() ); m_resultWidgets[ i ]->setText( entry.enumerationText() );
} }
i++;
} }
} }
ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::RequirementsList& checkEntries ) ResultsListWidget::ResultsListWidget( const RequirementsModel &model, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_entries( checkEntries ) , m_model( model )
{ {
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
@ -178,10 +179,11 @@ ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::Requirem
// Check that all are satisfied (gives warnings if not) and // Check that all are satisfied (gives warnings if not) and
// all *mandatory* entries are satisfied (gives errors if not). // all *mandatory* entries are satisfied (gives errors if not).
auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; };
const bool requirementsSatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isUnSatisfied );
createResultWidgets( entriesLayout, m_resultWidgets, checkEntries, isUnSatisfied ); const bool requirementsSatisfied = m_model.satisfiedRequirements();
auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; };
createResultWidgets( entriesLayout, m_resultWidgets, model, isUnSatisfied );
if ( !requirementsSatisfied ) if ( !requirementsSatisfied )
{ {
@ -228,7 +230,7 @@ ResultsListWidget::linkClicked( const QString& link )
{ {
if ( link == "#details" ) if ( link == "#details" )
{ {
auto* dialog = new ResultsListDialog( this, m_entries ); auto* dialog = new ResultsListDialog( m_model, this );
dialog->exec(); dialog->exec();
dialog->deleteLater(); dialog->deleteLater();
} }
@ -237,28 +239,23 @@ ResultsListWidget::linkClicked( const QString& link )
void void
ResultsListWidget::retranslate() ResultsListWidget::retranslate()
{ {
int i = 0; for ( auto i = 0; i < m_model.count(); i++ )
for ( const auto& entry : m_entries )
{ {
const auto &entry = m_model.getEntry(i);
if ( m_resultWidgets[ i ] ) if ( m_resultWidgets[ i ] )
{ {
m_resultWidgets[ i ]->setText( entry.negatedText() ); m_resultWidgets[ i ]->setText( entry.negatedText() );
} }
i++;
} }
// Check that all are satisfied (gives warnings if not) and // Check that all are satisfied (gives warnings if not) and
// all *mandatory* entries are satisfied (gives errors if not). // all *mandatory* entries are satisfied (gives errors if not).
auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; };
auto isMandatoryAndUnSatisfied = []( const Calamares::RequirementEntry& e ) { return e.mandatory && !e.satisfied; };
const bool requirementsSatisfied = std::none_of( m_entries.begin(), m_entries.end(), isUnSatisfied );
const bool mandatorySatisfied = std::none_of( m_entries.begin(), m_entries.end(), isMandatoryAndUnSatisfied );
if ( !requirementsSatisfied ) if ( !m_model.satisfiedRequirements() )
{ {
QString message; QString message;
const bool setup = Calamares::Settings::instance()->isSetupMode(); const bool setup = Calamares::Settings::instance()->isSetupMode();
if ( !mandatorySatisfied ) if ( !m_model.satisfiedMandatory() )
{ {
message = setup ? tr( "This computer does not satisfy the minimum " message = setup ? tr( "This computer does not satisfy the minimum "
"requirements for setting up %1.<br/>" "requirements for setting up %1.<br/>"

View File

@ -22,17 +22,15 @@
#include "ResultWidget.h" #include "ResultWidget.h"
#include "modulesystem/Requirement.h" #include "Config.h"
#include <QWidget> #include <QWidget>
class QLabel; class QLabel;
class ResultsListWidget : public QWidget class ResultsListWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ResultsListWidget( QWidget* parent, const Calamares::RequirementsList& checkEntries ); explicit ResultsListWidget(const RequirementsModel &model, QWidget* parent);
private: private:
/// @brief A link in the explanatory text has been clicked /// @brief A link in the explanatory text has been clicked
@ -40,7 +38,7 @@ private:
void retranslate(); void retranslate();
QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link
const Calamares::RequirementsList& m_entries; const RequirementsModel &m_model;
QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry
}; };

View File

@ -3,7 +3,7 @@
set( _welcome ${CMAKE_CURRENT_SOURCE_DIR}/../welcome ) set( _welcome ${CMAKE_CURRENT_SOURCE_DIR}/../welcome )
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ${_welcome} ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ${CMAKE_CURRENT_SOURCE_DIR}/../../libcalamares ${_welcome} )
# DUPLICATED WITH WELCOME MODULE # DUPLICATED WITH WELCOME MODULE
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus Network ) find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus Network )
@ -19,10 +19,7 @@ else()
endif() endif()
set( CHECKER_SOURCES set( CHECKER_SOURCES
${_welcome}/checker/CheckerContainer.cpp
${_welcome}/checker/GeneralRequirements.cpp ${_welcome}/checker/GeneralRequirements.cpp
${_welcome}/checker/ResultWidget.cpp
${_welcome}/checker/ResultsListWidget.cpp
${PARTMAN_SRC} ${PARTMAN_SRC}
) )
@ -32,7 +29,7 @@ calamares_add_plugin( welcomeq
SOURCES SOURCES
${CHECKER_SOURCES} ${CHECKER_SOURCES}
WelcomeQmlViewStep.cpp WelcomeQmlViewStep.cpp
Config.cpp ${_welcome}/Config.cpp
RESOURCES RESOURCES
welcomeq.qrc welcomeq.qrc
LINK_PRIVATE_LIBRARIES LINK_PRIVATE_LIBRARIES
@ -42,3 +39,13 @@ calamares_add_plugin( welcomeq
Qt5::Network Qt5::Network
SHARED_LIB SHARED_LIB
) )
# add_executable( welcomeqmltest qmlmain.cpp Config.cpp WelcomeQmlViewStep.cpp ${CHECKER_SOURCES} )
# target_link_libraries( welcomeqmltest PRIVATE calamaresui Qt5::Core Qt5::Network Qt5::DBus ${CHECKER_LINK_LIBRARIES})
# set_target_properties( welcomeqmltest
# PROPERTIES
# ENABLE_EXPORTS TRUE
# RUNTIME_OUTPUT_NAME welcomeqmltest
# )
# calamares_automoc( welcomeqmltest )
# calamares_autouic( welcomeqmltest )

View File

@ -1,23 +0,0 @@
/* === 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/>.
*/
#include "Config.h"
Config::Config() {}
Config::~Config() {}

View File

@ -1,51 +0,0 @@
/* === 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 WELCOMEQ_CONFIG_H
#define WELCOMEQ_CONFIG_H
#include <QObject>
#include <QUrl>
class Config : public QObject
{
Q_OBJECT
Q_PROPERTY( QUrl helpUrl READ helpUrl CONSTANT FINAL )
Q_PROPERTY( QUrl issuesUrl READ issuesUrl CONSTANT FINAL )
Q_PROPERTY( QUrl notesUrl READ notesUrl CONSTANT FINAL )
Q_PROPERTY( QUrl donateUrl READ donateUrl CONSTANT FINAL )
public:
Config();
virtual ~Config();
void setHelpUrl( const QUrl& url ) { m_helpUrl = url; }
void setIssuesUrl( const QUrl& url ) { m_issuesUrl = url; }
void setNotesUrl( const QUrl& url ) { m_notesUrl = url; }
void setDonateUrl( const QUrl& url ) { m_donateUrl = url; }
public slots:
QUrl helpUrl() const { return m_helpUrl; }
QUrl issuesUrl() const { return m_issuesUrl; }
QUrl notesUrl() const { return m_notesUrl; }
QUrl donateUrl() const { return m_donateUrl; }
private:
QUrl m_helpUrl, m_issuesUrl, m_notesUrl, m_donateUrl;
};
#endif

View File

@ -26,9 +26,12 @@
#include "locale/Lookup.h" #include "locale/Lookup.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Variant.h" #include "utils/Variant.h"
#include "utils/Dirs.h"
#include "Branding.h" #include "Branding.h"
#include "modulesystem/ModuleManager.h" #include "modulesystem/ModuleManager.h"
#include <QQmlEngine>
#include "utils/Yaml.h"
#include <QFutureWatcher> #include <QFutureWatcher>
#include <QPixmap> #include <QPixmap>
@ -37,54 +40,64 @@
CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin< WelcomeQmlViewStep >(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin< WelcomeQmlViewStep >(); )
WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent ) WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent )
: Calamares::QmlViewStep( QStringLiteral( "welcomeq" ), parent ) : Calamares::QmlViewStep("welcomeq", parent )
, m_config( new Config( ) ) // the qml singleton takes ownership and deletes it
// , m_nextEnabled( false )
, m_requirementsChecker( new GeneralRequirements( this ) ) , m_requirementsChecker( new GeneralRequirements( this ) )
{ {
connect( Calamares::ModuleManager::instance(), // connect( m_config,
&Calamares::ModuleManager::requirementsComplete, // &Config::isNextEnabledChanged,
this, // this,
&WelcomeQmlViewStep::nextStatusChanged ); // &WelcomeQmlViewStep::nextStatusChanged );
// emit nextStatusChanged(true);
qmlRegisterSingletonType< Config >( "io.calamares.module", 1, 0, "Welcome", [&](QQmlEngine*, QJSEngine*) -> QObject* { return m_config; } );
qmlRegisterSingletonType< Calamares::Branding >( "io.calamares.ui", 1, 0, "Branding", [](QQmlEngine*, QJSEngine*) -> QObject* { return Calamares::Branding::instance(); } );
} }
WelcomeQmlViewStep::~WelcomeQmlViewStep() {}
QString QString
WelcomeQmlViewStep::prettyName() const WelcomeQmlViewStep::prettyName() const
{ {
return tr( "Welcome" ); return tr( "Welcome" );
} }
/** @brief Look up a URL for a button bool
* WelcomeQmlViewStep::isNextEnabled() const
* Looks up @p key in @p map; if it is a *boolean* value, then
* assume an old-style configuration, and fetch the string from
* the branding settings @p e. If it is a string, not a boolean,
* use it as-is. If not found, or a weird type, returns empty.
*
* This allows switching the showKnownIssuesUrl and similar settings
* in welcome.conf from a boolean (deferring to branding) to an
* actual string for immediate use. Empty strings, as well as
* "false" as a setting, will hide the buttons as before.
*/
static QString
jobOrBrandingSetting( Calamares::Branding::StringEntry e, const QVariantMap& map, const QString& key )
{ {
if ( !map.contains( key ) ) // TODO: should return true
{ // return m_config->property("isNextEnabled").toBool();
return QString(); return true;
} }
auto v = map.value( key );
if ( v.type() == QVariant::Bool )
{
return v.toBool() ? ( *e ) : QString();
}
if ( v.type() == QVariant::String )
{
return v.toString();
}
return QString(); bool
WelcomeQmlViewStep::isBackEnabled() const
{
// TODO: should return true (it's weird that you are not allowed to have welcome *after* anything
return false;
}
bool
WelcomeQmlViewStep::isAtBeginning() const
{
// TODO: adjust to "pages" in the QML
return true;
}
bool
WelcomeQmlViewStep::isAtEnd() const
{
// TODO: adjust to "pages" in the QML
return true;
}
Calamares::JobList
WelcomeQmlViewStep::jobs() const
{
return Calamares::JobList();
} }
void void
@ -92,17 +105,16 @@ WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
using Calamares::Branding; using Calamares::Branding;
m_config.setHelpUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) ); // TODO: expand Config class and set the remaining fields // with the configurationMap all those properties can be accesed withouth having to declare a property, get and setter for each
m_config.setIssuesUrl( jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
m_config.setNotesUrl( jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
m_config.setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
// TODO: figure out how the requirements (held by ModuleManager) should be accessible // TODO: figure out how the requirements (held by ModuleManager) should be accessible
// to QML as a odel. // to QML as a odel. //will be model as a qvariantmap containing a alert level and the message string
if ( configurationMap.contains( "requirements" ) if ( configurationMap.contains( "requirements" )
&& configurationMap.value( "requirements" ).type() == QVariant::Map ) && configurationMap.value( "requirements" ).type() == QVariant::Map )
{ {
m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() ); m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() );
m_config->requirementsModel().setRequirementsList( checkRequirements() );
} }
else else
cWarning() << "no valid requirements map found in welcome " cWarning() << "no valid requirements map found in welcome "
@ -142,11 +154,11 @@ WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) ); auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) );
if ( !icon.isNull() ) if ( !icon.isNull() )
{ {
// TODO: figure out where to set this: Config? m_config->setLanguageIcon(language);
} }
} }
QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
} }
Calamares::RequirementsList Calamares::RequirementsList
@ -155,6 +167,12 @@ WelcomeQmlViewStep::checkRequirements()
return m_requirementsChecker->checkRequirements(); return m_requirementsChecker->checkRequirements();
} }
Config*
WelcomeQmlViewStep::config() const
{
return m_config;
}
static inline void static inline void
logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler ) logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler )
{ {
@ -192,12 +210,7 @@ WelcomeQmlViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoI
if ( ( r >= 0 ) ) if ( ( r >= 0 ) )
{ {
// TODO: update Config to point to selected language // TODO: update Config to point to selected language
m_config->setCountryCode( countryCode );
} }
} }
} }
QObject*
WelcomeQmlViewStep::getConfig()
{
return &m_config;
}

View File

@ -21,11 +21,12 @@
#include "Config.h" #include "Config.h"
#include "DllMacro.h"
#include "modulesystem/Requirement.h" #include "modulesystem/Requirement.h"
#include "utils/PluginFactory.h" #include "utils/PluginFactory.h"
#include "viewpages/QmlViewStep.h" #include "viewpages/QmlViewStep.h"
#include <DllMacro.h>
#include <QObject> #include <QObject>
#include <QVariantMap> #include <QVariantMap>
@ -39,16 +40,26 @@ class Handler;
class GeneralRequirements; class GeneralRequirements;
// TODO: Needs a generic Calamares::QmlViewStep as base class
// TODO: refactor and move what makes sense to base class
class PLUGINDLLEXPORT WelcomeQmlViewStep : public Calamares::QmlViewStep class PLUGINDLLEXPORT WelcomeQmlViewStep : public Calamares::QmlViewStep
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WelcomeQmlViewStep( QObject* parent = nullptr ); explicit WelcomeQmlViewStep( QObject* parent = nullptr );
virtual ~WelcomeQmlViewStep() override;
QString prettyName() const override; QString prettyName() const override;
bool isNextEnabled() const override;
bool isBackEnabled() const override;
bool isAtBeginning() const override;
bool isAtEnd() const override;
Calamares::JobList jobs() const override;
void setConfigurationMap( const QVariantMap& configurationMap ) override; void setConfigurationMap( const QVariantMap& configurationMap ) override;
/** @brief Sets the country that Calamares is running in. /** @brief Sets the country that Calamares is running in.
@ -60,13 +71,11 @@ public:
void setCountry( const QString&, CalamaresUtils::GeoIP::Handler* handler ); void setCountry( const QString&, CalamaresUtils::GeoIP::Handler* handler );
Calamares::RequirementsList checkRequirements() override; Calamares::RequirementsList checkRequirements() override;
Config* config() const;
protected:
QObject* getConfig() override;
private: private:
// TODO: a generic QML viewstep should return a config object from a method // TODO: a generic QML viewstep should return a config object from a method
Config m_config; Config *m_config;
GeneralRequirements* m_requirementsChecker; GeneralRequirements* m_requirementsChecker;
}; };

View File

@ -6,6 +6,8 @@
# In addition to displaying the welcome page, this module # In addition to displaying the welcome page, this module
# can check requirements for installation. # can check requirements for installation.
--- ---
# Setting for QML loading
search: both
# Display settings for various buttons on the welcome page. # Display settings for various buttons on the welcome page.
# The URLs themselves come from branding.desc is the setting # The URLs themselves come from branding.desc is the setting
# here is "true". If the setting is false, the button is hidden. # here is "true". If the setting is false, the button is hidden.