commit
de5c97af11
@ -12,8 +12,6 @@ else()
|
|||||||
add_definitions( -DWITHOUT_LIBPARTED )
|
add_definitions( -DWITHOUT_LIBPARTED )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
|
||||||
|
|
||||||
set( CHECKER_SOURCES
|
set( CHECKER_SOURCES
|
||||||
checker/CheckerContainer.cpp
|
checker/CheckerContainer.cpp
|
||||||
checker/GeneralRequirements.cpp
|
checker/GeneralRequirements.cpp
|
||||||
|
@ -17,27 +17,27 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "utils/Logger.h"
|
|
||||||
#include "utils/Retranslator.h"
|
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
#include <QApplication>
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requirements )
|
RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requirements )
|
||||||
{
|
{
|
||||||
|
CALAMARES_RETRANSLATE_SLOT( &RequirementsModel::retranslate )
|
||||||
|
|
||||||
emit beginResetModel();
|
emit beginResetModel();
|
||||||
m_requierements = requirements;
|
m_requirements = requirements;
|
||||||
m_satisfiedRequirements = true;
|
|
||||||
|
|
||||||
auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; };
|
auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; };
|
||||||
auto isMandatoryAndUnSatisfied = []( const Calamares::RequirementEntry& e ) { return e.mandatory && !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_satisfiedRequirements = std::none_of( m_requirements.begin(), m_requirements.end(), isUnSatisfied );
|
||||||
m_satisfiedMandatory = std::none_of( m_requierements.begin(), m_requierements.end(), isMandatoryAndUnSatisfied );
|
m_satisfiedMandatory = std::none_of( m_requirements.begin(), m_requirements.end(), isMandatoryAndUnSatisfied );
|
||||||
|
|
||||||
emit satisfiedRequirementsChanged(m_satisfiedRequirements);
|
emit satisfiedRequirementsChanged( m_satisfiedRequirements );
|
||||||
emit satisfiedMandatoryChanged();
|
emit satisfiedMandatoryChanged();
|
||||||
emit endResetModel();
|
emit endResetModel();
|
||||||
}
|
}
|
||||||
@ -45,89 +45,74 @@ RequirementsModel::setRequirementsList( const Calamares::RequirementsList& requi
|
|||||||
int
|
int
|
||||||
RequirementsModel::rowCount( const QModelIndex& ) const
|
RequirementsModel::rowCount( const QModelIndex& ) const
|
||||||
{
|
{
|
||||||
return m_requierements.count();
|
return m_requirements.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
RequirementsModel::data( const QModelIndex& index, int role ) const
|
RequirementsModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
const auto requirement = m_requierements.at( index.row() );
|
const auto requirement = m_requirements.at( index.row() );
|
||||||
|
|
||||||
switch ( role )
|
switch ( role )
|
||||||
{
|
{
|
||||||
case Roles::Name:
|
case Roles::Name:
|
||||||
return requirement.name;
|
return requirement.name;
|
||||||
case Roles::Details:
|
case Roles::Details:
|
||||||
return requirement.enumerationText();
|
return requirement.enumerationText();
|
||||||
case Roles::NegatedText:
|
case Roles::NegatedText:
|
||||||
return requirement.negatedText();
|
return requirement.negatedText();
|
||||||
case Roles::Satisfied:
|
case Roles::Satisfied:
|
||||||
return requirement.satisfied;
|
return requirement.satisfied;
|
||||||
case Roles::Mandatory:
|
case Roles::Mandatory:
|
||||||
return requirement.mandatory;
|
return requirement.mandatory;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray>
|
QHash< int, QByteArray >
|
||||||
RequirementsModel::roleNames() const
|
RequirementsModel::roleNames() const
|
||||||
{
|
{
|
||||||
static QHash<int, QByteArray> roles;
|
static QHash< int, QByteArray > roles;
|
||||||
roles[Roles::Name] = "name";
|
roles[ Roles::Name ] = "name";
|
||||||
roles[Roles::Details] = "details";
|
roles[ Roles::Details ] = "details";
|
||||||
roles[Roles::NegatedText] = "negatedText";
|
roles[ Roles::NegatedText ] = "negatedText";
|
||||||
roles[Roles::Satisfied] = "satisfied";
|
roles[ Roles::Satisfied ] = "satisfied";
|
||||||
roles[Roles::Mandatory] = "mandatory";
|
roles[ Roles::Mandatory ] = "mandatory";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::Config( QObject* parent ) : QObject( parent )
|
Config::Config( QObject* parent )
|
||||||
, m_requirementsModel( new RequirementsModel( this ))
|
: QObject( parent )
|
||||||
|
, m_requirementsModel( new RequirementsModel( this ) )
|
||||||
, m_languages( CalamaresUtils::Locale::availableTranslations() )
|
, m_languages( CalamaresUtils::Locale::availableTranslations() )
|
||||||
{
|
{
|
||||||
connect(m_requirementsModel, &RequirementsModel::satisfiedRequirementsChanged, this, &Config::setIsNextEnabled);
|
connect( m_requirementsModel, &RequirementsModel::satisfiedRequirementsChanged, this, &Config::setIsNextEnabled );
|
||||||
|
|
||||||
initLanguages();
|
initLanguages();
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate )
|
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::retranslate()
|
Config::retranslate()
|
||||||
{
|
{
|
||||||
QString message;
|
m_genericWelcomeMessage = genericWelcomeMessage().arg( *Calamares::Branding::VersionedName );
|
||||||
|
|
||||||
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();
|
emit genericWelcomeMessageChanged();
|
||||||
|
|
||||||
// ui->supportButton->setText( tr( "%1 support" ).arg( *Calamares::Branding::ShortProductName ) );
|
m_requirementsModel->retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
CalamaresUtils::Locale::LabelModel*
|
CalamaresUtils::Locale::LabelModel*
|
||||||
Config::languagesModel() const
|
Config::languagesModel() const
|
||||||
{
|
{
|
||||||
return m_languages;
|
return m_languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Config::languageIcon() const
|
Config::languageIcon() const
|
||||||
{
|
{
|
||||||
return m_languageIcon;
|
return m_languageIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -146,7 +131,7 @@ Config::initLanguages()
|
|||||||
cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
|
cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
|
||||||
|
|
||||||
matchedLocaleIndex
|
matchedLocaleIndex
|
||||||
= m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } );
|
= m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( matchedLocaleIndex < 0 )
|
if ( matchedLocaleIndex < 0 )
|
||||||
@ -168,8 +153,8 @@ Config::initLanguages()
|
|||||||
QString name = m_languages->locale( matchedLocaleIndex ).name();
|
QString name = m_languages->locale( matchedLocaleIndex ).name();
|
||||||
cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
|
cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
|
||||||
|
|
||||||
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsDirectory(), qApp );
|
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsDirectory() );
|
||||||
setLocaleIndex( matchedLocaleIndex );
|
setLocaleIndex( matchedLocaleIndex );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -180,23 +165,26 @@ Config::initLanguages()
|
|||||||
void
|
void
|
||||||
Config::setCountryCode( const QString& countryCode )
|
Config::setCountryCode( const QString& countryCode )
|
||||||
{
|
{
|
||||||
m_countryCode = countryCode;
|
m_countryCode = countryCode;
|
||||||
setLocaleIndex(CalamaresUtils::Locale::availableTranslations()->find( m_countryCode ));
|
setLocaleIndex( CalamaresUtils::Locale::availableTranslations()->find( m_countryCode ) );
|
||||||
|
|
||||||
emit countryCodeChanged( m_countryCode );
|
emit countryCodeChanged( m_countryCode );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setLanguageIcon(const QString &languageIcon )
|
Config::setLanguageIcon( const QString& languageIcon )
|
||||||
{
|
{
|
||||||
m_languageIcon = languageIcon;
|
m_languageIcon = languageIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setLocaleIndex(const int& index)
|
Config::setLocaleIndex( const int& index )
|
||||||
{
|
{
|
||||||
if(index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount(QModelIndex()) || index < 0)
|
if ( index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount( QModelIndex() )
|
||||||
|
|| index < 0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_localeIndex = index;
|
m_localeIndex = index;
|
||||||
|
|
||||||
@ -204,8 +192,7 @@ Config::setLocaleIndex(const int& index)
|
|||||||
cDebug() << "Selected locale" << selectedLocale;
|
cDebug() << "Selected locale" << selectedLocale;
|
||||||
|
|
||||||
QLocale::setDefault( selectedLocale );
|
QLocale::setDefault( selectedLocale );
|
||||||
CalamaresUtils::installTranslator(
|
CalamaresUtils::installTranslator( selectedLocale, Calamares::Branding::instance()->translationsDirectory() );
|
||||||
selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
|
|
||||||
|
|
||||||
emit localeIndexChanged( m_localeIndex );
|
emit localeIndexChanged( m_localeIndex );
|
||||||
}
|
}
|
||||||
@ -223,51 +210,118 @@ Config::setIsNextEnabled( const bool& isNextEnabled )
|
|||||||
emit isNextEnabledChanged( m_isNextEnabled );
|
emit isNextEnabledChanged( m_isNextEnabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Config::donateUrl() const
|
QString
|
||||||
|
Config::donateUrl() const
|
||||||
{
|
{
|
||||||
return m_donateUrl;
|
return m_donateUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setDonateUrl(const QString& url)
|
void
|
||||||
|
Config::setDonateUrl( const QString& url )
|
||||||
{
|
{
|
||||||
m_donateUrl = url;
|
m_donateUrl = url;
|
||||||
|
emit donateUrlChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Config::knownIssuesUrl() const
|
QString
|
||||||
|
Config::knownIssuesUrl() const
|
||||||
{
|
{
|
||||||
return m_knownIssuesUrl;
|
return m_knownIssuesUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setKnownIssuesUrl(const QString& url)
|
void
|
||||||
|
Config::setKnownIssuesUrl( const QString& url )
|
||||||
{
|
{
|
||||||
m_knownIssuesUrl = url;
|
m_knownIssuesUrl = url;
|
||||||
|
emit knownIssuesUrlChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setReleaseNotesUrl(const QString& url)
|
void
|
||||||
|
Config::setReleaseNotesUrl( const QString& url )
|
||||||
{
|
{
|
||||||
m_releaseNotesUrl = url;
|
m_releaseNotesUrl = url;
|
||||||
|
emit releaseNotesUrlChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Config::releaseNotesUrl() const
|
QString
|
||||||
|
Config::releaseNotesUrl() const
|
||||||
{
|
{
|
||||||
return m_releaseNotesUrl;
|
return m_releaseNotesUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Config::supportUrl() const
|
QString
|
||||||
|
Config::supportUrl() const
|
||||||
{
|
{
|
||||||
return m_supportUrl;
|
return m_supportUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setSupportUrl(const QString& url)
|
void
|
||||||
|
Config::setSupportUrl( const QString& url )
|
||||||
{
|
{
|
||||||
m_supportUrl = url;
|
m_supportUrl = url;
|
||||||
|
emit supportUrlChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RequirementsModel::retranslate()
|
||||||
|
{
|
||||||
|
if ( !m_satisfiedRequirements )
|
||||||
|
{
|
||||||
|
QString message;
|
||||||
|
const bool setup = Calamares::Settings::instance()->isSetupMode();
|
||||||
|
|
||||||
|
if ( !m_satisfiedMandatory )
|
||||||
|
{
|
||||||
|
message = setup ? tr( "This computer does not satisfy the minimum "
|
||||||
|
"requirements for setting up %1.<br/>"
|
||||||
|
"Setup cannot continue. "
|
||||||
|
"<a href=\"#details\">Details...</a>" )
|
||||||
|
: tr( "This computer does not satisfy the minimum "
|
||||||
|
"requirements for installing %1.<br/>"
|
||||||
|
"Installation cannot continue. "
|
||||||
|
"<a href=\"#details\">Details...</a>" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = setup ? tr( "This computer does not satisfy some of the "
|
||||||
|
"recommended requirements for setting up %1.<br/>"
|
||||||
|
"Setup can continue, but some features "
|
||||||
|
"might be disabled." )
|
||||||
|
: tr( "This computer does not satisfy some of the "
|
||||||
|
"recommended requirements for installing %1.<br/>"
|
||||||
|
"Installation can continue, but some features "
|
||||||
|
"might be disabled." );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_warningMessage = message.arg( *Calamares::Branding::ShortVersionedName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_warningMessage = tr( "This program will ask you some questions and "
|
||||||
|
"set up %2 on your computer." )
|
||||||
|
.arg( *Calamares::Branding::ProductName );
|
||||||
|
}
|
||||||
|
|
||||||
|
emit warningMessageChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
Config::genericWelcomeMessage()
|
||||||
|
{
|
||||||
|
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>" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
@ -19,21 +19,23 @@
|
|||||||
#ifndef WELCOME_CONFIG_H
|
#ifndef WELCOME_CONFIG_H
|
||||||
#define WELCOME_CONFIG_H
|
#define WELCOME_CONFIG_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QUrl>
|
|
||||||
#include "modulesystem/Requirement.h"
|
#include "modulesystem/Requirement.h"
|
||||||
|
|
||||||
#include "locale/LabelModel.h"
|
#include "locale/LabelModel.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
// TODO: move this (and modulesystem/Requirement) to libcalamares
|
||||||
class RequirementsModel : public QAbstractListModel
|
class RequirementsModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
using QAbstractListModel::QAbstractListModel;
|
Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL )
|
||||||
Q_PROPERTY(bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL)
|
Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL )
|
||||||
|
Q_PROPERTY( QString warningMessage READ warningMessage NOTIFY warningMessageChanged FINAL )
|
||||||
Q_PROPERTY(bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using QAbstractListModel::QAbstractListModel;
|
||||||
|
|
||||||
enum Roles : short
|
enum Roles : short
|
||||||
{
|
{
|
||||||
Name,
|
Name,
|
||||||
@ -44,90 +46,92 @@ public:
|
|||||||
HasDetails
|
HasDetails
|
||||||
};
|
};
|
||||||
|
|
||||||
bool satisfiedRequirements() const
|
bool satisfiedRequirements() const { return m_satisfiedRequirements; }
|
||||||
|
|
||||||
|
bool satisfiedMandatory() const { return m_satisfiedMandatory; }
|
||||||
|
|
||||||
|
const Calamares::RequirementEntry& getEntry( const int& index ) const
|
||||||
{
|
{
|
||||||
return m_satisfiedRequirements;
|
if ( index > count() || index < 0 )
|
||||||
}
|
{
|
||||||
|
return *( new Calamares::RequirementEntry() );
|
||||||
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);
|
|
||||||
|
|
||||||
|
return m_requirements.at( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRequirementsList( const Calamares::RequirementsList& requirements );
|
void setRequirementsList( const Calamares::RequirementsList& requirements );
|
||||||
int rowCount(const QModelIndex&) const override;
|
int rowCount( const QModelIndex& ) const override;
|
||||||
int count() const
|
int count() const { return m_requirements.count(); }
|
||||||
{
|
|
||||||
return m_requierements.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant data(const QModelIndex& index, int role) const override;
|
QString warningMessage() const { return m_warningMessage; }
|
||||||
|
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
|
QVariant data( const QModelIndex& index, int role ) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash< int, QByteArray > roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Calamares::RequirementsList m_requierements;
|
Calamares::RequirementsList m_requirements;
|
||||||
bool m_satisfiedRequirements = false;
|
bool m_satisfiedRequirements = false;
|
||||||
bool m_satisfiedMandatory = false;
|
bool m_satisfiedMandatory = false;
|
||||||
|
|
||||||
|
QString m_warningMessage;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void satisfiedRequirementsChanged(bool value);
|
void satisfiedRequirementsChanged( bool value );
|
||||||
void satisfiedMandatoryChanged();
|
void satisfiedMandatoryChanged();
|
||||||
|
void warningMessageChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Config : public QObject
|
class Config : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( CalamaresUtils::Locale::LabelModel* languagesModel READ languagesModel CONSTANT FINAL)
|
Q_PROPERTY( CalamaresUtils::Locale::LabelModel* languagesModel READ languagesModel CONSTANT FINAL )
|
||||||
Q_PROPERTY( RequirementsModel* requirementsModel MEMBER m_requirementsModel CONSTANT FINAL )
|
Q_PROPERTY( RequirementsModel* requirementsModel MEMBER m_requirementsModel CONSTANT FINAL )
|
||||||
|
|
||||||
Q_PROPERTY( QString languageIcon READ languageIcon CONSTANT FINAL )
|
Q_PROPERTY( QString languageIcon READ languageIcon CONSTANT FINAL )
|
||||||
|
|
||||||
Q_PROPERTY( QString countryCode MEMBER m_countryCode NOTIFY countryCodeChanged FINAL )
|
Q_PROPERTY( QString countryCode MEMBER m_countryCode NOTIFY countryCodeChanged FINAL )
|
||||||
Q_PROPERTY (int localeIndex READ localeIndex WRITE setLocaleIndex NOTIFY localeIndexChanged)
|
Q_PROPERTY( int localeIndex READ localeIndex WRITE setLocaleIndex NOTIFY localeIndexChanged )
|
||||||
|
|
||||||
Q_PROPERTY( QString genericWelcomeMessage MEMBER m_genericWelcomeMessage NOTIFY genericWelcomeMessageChanged FINAL )
|
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 supportUrl MEMBER m_supportUrl NOTIFY supportUrlChanged FINAL )
|
||||||
Q_PROPERTY(QString knownIssuesUrl MEMBER m_knownIssuesUrl CONSTANT FINAL)
|
Q_PROPERTY( QString knownIssuesUrl MEMBER m_knownIssuesUrl NOTIFY knownIssuesUrlChanged FINAL )
|
||||||
Q_PROPERTY(QString releaseNotesUrl MEMBER m_releaseNotesUrl CONSTANT FINAL)
|
Q_PROPERTY( QString releaseNotesUrl MEMBER m_releaseNotesUrl NOTIFY releaseNotesUrlChanged FINAL )
|
||||||
Q_PROPERTY(QString donateUrl MEMBER m_donateUrl CONSTANT FINAL)
|
Q_PROPERTY( QString donateUrl MEMBER m_donateUrl NOTIFY donateUrlChanged FINAL )
|
||||||
|
|
||||||
|
Q_PROPERTY( bool isNextEnabled MEMBER m_isNextEnabled NOTIFY isNextEnabledChanged FINAL )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config( QObject* parent = nullptr );
|
Config( QObject* parent = nullptr );
|
||||||
void setCountryCode( const QString &countryCode );
|
void setCountryCode( const QString& countryCode );
|
||||||
void setLanguageIcon( const QString &languageIcon );
|
void setLanguageIcon( const QString& languageIcon );
|
||||||
RequirementsModel& requirementsModel () const;
|
RequirementsModel& requirementsModel() const;
|
||||||
|
|
||||||
void setIsNextEnabled( const bool& isNextEnabled );
|
void setIsNextEnabled( const bool& isNextEnabled );
|
||||||
|
|
||||||
void setLocaleIndex(const int &index);
|
void setLocaleIndex( const int& index );
|
||||||
int localeIndex() const { return m_localeIndex; }
|
int localeIndex() const { return m_localeIndex; }
|
||||||
|
|
||||||
QString supportUrl() const;
|
QString supportUrl() const;
|
||||||
void setSupportUrl(const QString &url);
|
void setSupportUrl( const QString& url );
|
||||||
|
|
||||||
QString knownIssuesUrl() const;
|
QString knownIssuesUrl() const;
|
||||||
void setKnownIssuesUrl(const QString &url);
|
void setKnownIssuesUrl( const QString& url );
|
||||||
|
|
||||||
QString releaseNotesUrl() const;
|
QString releaseNotesUrl() const;
|
||||||
void setReleaseNotesUrl(const QString &url);
|
void setReleaseNotesUrl( const QString& url );
|
||||||
|
|
||||||
QString donateUrl() const;
|
QString donateUrl() const;
|
||||||
void setDonateUrl(const QString &url);
|
void setDonateUrl( const QString& url );
|
||||||
|
|
||||||
|
QString genericWelcomeMessage();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
CalamaresUtils::Locale::LabelModel* languagesModel() const;
|
CalamaresUtils::Locale::LabelModel* languagesModel() const;
|
||||||
@ -144,9 +148,7 @@ private:
|
|||||||
bool m_isNextEnabled = false;
|
bool m_isNextEnabled = false;
|
||||||
CalamaresUtils::Locale::LabelModel* m_languages;
|
CalamaresUtils::Locale::LabelModel* m_languages;
|
||||||
|
|
||||||
QString m_genericWelcomeMessage = tr("This program will ask you some questions and set up your installation");
|
QString m_genericWelcomeMessage;
|
||||||
|
|
||||||
QString m_warningMessage = tr("This program does not satisfy the minimum requirements for installing.\nInstallation can not continue");
|
|
||||||
|
|
||||||
QString m_supportUrl;
|
QString m_supportUrl;
|
||||||
QString m_knownIssuesUrl;
|
QString m_knownIssuesUrl;
|
||||||
@ -158,6 +160,10 @@ signals:
|
|||||||
void localeIndexChanged( int localeIndex );
|
void localeIndexChanged( int localeIndex );
|
||||||
void isNextEnabledChanged( bool isNextEnabled );
|
void isNextEnabledChanged( bool isNextEnabled );
|
||||||
void genericWelcomeMessageChanged();
|
void genericWelcomeMessageChanged();
|
||||||
|
void supportUrlChanged();
|
||||||
|
void knownIssuesUrlChanged();
|
||||||
|
void releaseNotesUrlChanged();
|
||||||
|
void donateUrlChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
#include "CalamaresVersion.h"
|
#include "CalamaresVersion.h"
|
||||||
|
#include "Config.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"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
WelcomePage::WelcomePage( Config *conf, QWidget* parent )
|
WelcomePage::WelcomePage( Config* conf, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::WelcomePage )
|
, ui( new Ui::WelcomePage )
|
||||||
, m_checkingWidget( new CheckerContainer( conf->requirementsModel(), this ) )
|
, m_checkingWidget( new CheckerContainer( conf->requirementsModel(), this ) )
|
||||||
@ -84,13 +84,14 @@ WelcomePage::WelcomePage( Config *conf, QWidget* parent )
|
|||||||
ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget );
|
ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget );
|
||||||
}
|
}
|
||||||
|
|
||||||
void WelcomePage::init()
|
void
|
||||||
|
WelcomePage::init()
|
||||||
{
|
{
|
||||||
//setup the url buttons
|
//setup the url buttons
|
||||||
setupButton( WelcomePage::Button::Support, m_conf->supportUrl());
|
setupButton( WelcomePage::Button::Support, m_conf->supportUrl() );
|
||||||
setupButton( WelcomePage::Button::KnownIssues, m_conf->knownIssuesUrl() );
|
setupButton( WelcomePage::Button::KnownIssues, m_conf->knownIssuesUrl() );
|
||||||
setupButton( WelcomePage::Button::ReleaseNotes, m_conf->releaseNotesUrl() );
|
setupButton( WelcomePage::Button::ReleaseNotes, m_conf->releaseNotesUrl() );
|
||||||
setupButton( WelcomePage::Button::Donate, m_conf->donateUrl());
|
setupButton( WelcomePage::Button::Donate, m_conf->donateUrl() );
|
||||||
|
|
||||||
//language icon
|
//language icon
|
||||||
auto icon = Calamares::Branding::instance()->image( m_conf->languageIcon(), QSize( 48, 48 ) );
|
auto icon = Calamares::Branding::instance()->image( m_conf->languageIcon(), QSize( 48, 48 ) );
|
||||||
@ -113,7 +114,9 @@ WelcomePage::initLanguages()
|
|||||||
ui->languageWidget->setCurrentIndex( m_conf->localeIndex() );
|
ui->languageWidget->setCurrentIndex( m_conf->localeIndex() );
|
||||||
|
|
||||||
connect( ui->languageWidget,
|
connect( ui->languageWidget,
|
||||||
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), m_conf, &Config::setLocaleIndex );
|
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
||||||
|
m_conf,
|
||||||
|
&Config::setLocaleIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -36,7 +36,7 @@ class WelcomePage : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit WelcomePage( Config *conf, QWidget* parent = nullptr );
|
explicit WelcomePage( Config* conf, QWidget* parent = nullptr );
|
||||||
|
|
||||||
enum class Button
|
enum class Button
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ private:
|
|||||||
CheckerContainer* m_checkingWidget;
|
CheckerContainer* m_checkingWidget;
|
||||||
CalamaresUtils::Locale::LabelModel* m_languages;
|
CalamaresUtils::Locale::LabelModel* m_languages;
|
||||||
|
|
||||||
Config *m_conf;
|
Config* m_conf;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Delegate to display language information in two columns.
|
/** @brief Delegate to display language information in two columns.
|
||||||
|
@ -18,92 +18,91 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "WelcomeViewStep.h"
|
#include "WelcomeViewStep.h"
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
#include "WelcomePage.h"
|
#include "WelcomePage.h"
|
||||||
#include "checker/GeneralRequirements.h"
|
#include "checker/GeneralRequirements.h"
|
||||||
|
|
||||||
|
#include "Branding.h"
|
||||||
#include "geoip/Handler.h"
|
#include "geoip/Handler.h"
|
||||||
#include "locale/Lookup.h"
|
#include "locale/Lookup.h"
|
||||||
|
#include "modulesystem/ModuleManager.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include "Branding.h"
|
|
||||||
#include "modulesystem/ModuleManager.h"
|
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeViewStepFactory, registerPlugin< WelcomeViewStep >(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeViewStepFactory, registerPlugin< WelcomeViewStep >(); )
|
||||||
|
|
||||||
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) )
|
, 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 );
|
||||||
|
|
||||||
// the instance of the qqc2 or qwidgets page
|
// the instance of the qqc2 or qwidgets page
|
||||||
m_widget = new WelcomePage(m_conf);
|
m_widget = new WelcomePage( m_conf );
|
||||||
}
|
}
|
||||||
|
|
||||||
WelcomeViewStep::~WelcomeViewStep()
|
WelcomeViewStep::~WelcomeViewStep()
|
||||||
{
|
{
|
||||||
if ( m_widget && m_widget->parent() == nullptr )
|
if ( m_widget && m_widget->parent() == nullptr )
|
||||||
{
|
{
|
||||||
m_widget->deleteLater();
|
m_widget->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
WelcomeViewStep::prettyName() const
|
WelcomeViewStep::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "Welcome" );
|
return tr( "Welcome" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget*
|
QWidget*
|
||||||
WelcomeViewStep::widget()
|
WelcomeViewStep::widget()
|
||||||
{
|
{
|
||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WelcomeViewStep::isNextEnabled() const
|
WelcomeViewStep::isNextEnabled() const
|
||||||
{
|
{
|
||||||
return m_widget->verdict();
|
return m_widget->verdict();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WelcomeViewStep::isBackEnabled() const
|
WelcomeViewStep::isBackEnabled() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WelcomeViewStep::isAtBeginning() const
|
WelcomeViewStep::isAtBeginning() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WelcomeViewStep::isAtEnd() const
|
WelcomeViewStep::isAtEnd() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Calamares::JobList
|
Calamares::JobList
|
||||||
WelcomeViewStep::jobs() const
|
WelcomeViewStep::jobs() const
|
||||||
{
|
{
|
||||||
return Calamares::JobList();
|
return Calamares::JobList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,125 +121,127 @@ WelcomeViewStep::jobs() const
|
|||||||
static QString
|
static QString
|
||||||
jobOrBrandingSetting( Calamares::Branding::StringEntry e, const QVariantMap& map, const QString& key )
|
jobOrBrandingSetting( Calamares::Branding::StringEntry e, const QVariantMap& map, const QString& key )
|
||||||
{
|
{
|
||||||
if ( !map.contains( key ) )
|
if ( !map.contains( key ) )
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
auto v = map.value( key );
|
auto v = map.value( key );
|
||||||
if ( v.type() == QVariant::Bool )
|
if ( v.type() == QVariant::Bool )
|
||||||
{
|
{
|
||||||
return v.toBool() ? ( *e ) : QString();
|
return v.toBool() ? ( *e ) : QString();
|
||||||
}
|
}
|
||||||
if ( v.type() == QVariant::String )
|
if ( v.type() == QVariant::String )
|
||||||
{
|
{
|
||||||
return v.toString();
|
return v.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
using Calamares::Branding;
|
using Calamares::Branding;
|
||||||
|
|
||||||
m_conf->setSupportUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
|
m_conf->setSupportUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
|
||||||
m_conf->setKnownIssuesUrl( jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
|
m_conf->setKnownIssuesUrl(
|
||||||
m_conf->setReleaseNotesUrl( jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
|
jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
|
||||||
m_conf->setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
|
m_conf->setReleaseNotesUrl(
|
||||||
|
jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
|
||||||
|
m_conf->setDonateUrl( 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() );
|
m_conf->requirementsModel().setRequirementsList( checkRequirements() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cWarning() << "no valid requirements map found in welcome "
|
cWarning() << "no valid requirements map found in welcome "
|
||||||
"module configuration.";
|
"module configuration.";
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok );
|
QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok );
|
||||||
if ( ok )
|
if ( ok )
|
||||||
{
|
{
|
||||||
using FWString = QFutureWatcher< QString >;
|
using FWString = QFutureWatcher< QString >;
|
||||||
|
|
||||||
auto* handler = new CalamaresUtils::GeoIP::Handler( CalamaresUtils::getString( geoip, "style" ),
|
auto* handler = new CalamaresUtils::GeoIP::Handler( CalamaresUtils::getString( geoip, "style" ),
|
||||||
CalamaresUtils::getString( geoip, "url" ),
|
CalamaresUtils::getString( geoip, "url" ),
|
||||||
CalamaresUtils::getString( geoip, "selector" ) );
|
CalamaresUtils::getString( geoip, "selector" ) );
|
||||||
if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None )
|
if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None )
|
||||||
{
|
{
|
||||||
auto* future = new FWString();
|
auto* future = new FWString();
|
||||||
connect( future, &FWString::finished, [view = this, f = future, h = handler]() {
|
connect( future, &FWString::finished, [view = this, f = future, h = handler]() {
|
||||||
QString countryResult = f->future().result();
|
QString countryResult = f->future().result();
|
||||||
cDebug() << "GeoIP result for welcome=" << countryResult;
|
cDebug() << "GeoIP result for welcome=" << countryResult;
|
||||||
view->setCountry( countryResult, h );
|
view->setCountry( countryResult, h );
|
||||||
f->deleteLater();
|
f->deleteLater();
|
||||||
delete h;
|
delete h;
|
||||||
} );
|
} );
|
||||||
future->setFuture( handler->queryRaw() );
|
future->setFuture( handler->queryRaw() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Would not produce useful country code anyway.
|
// Would not produce useful country code anyway.
|
||||||
delete handler;
|
delete handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString language = CalamaresUtils::getString( configurationMap, "languageIcon" );
|
QString language = CalamaresUtils::getString( configurationMap, "languageIcon" );
|
||||||
if ( !language.isEmpty() )
|
if ( !language.isEmpty() )
|
||||||
{
|
{
|
||||||
m_conf->setLanguageIcon( language );
|
m_conf->setLanguageIcon( language );
|
||||||
}
|
}
|
||||||
|
|
||||||
//here init the qml or qwidgets needed bits
|
//here init the qml or qwidgets needed bits
|
||||||
m_widget->init();
|
m_widget->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::RequirementsList
|
Calamares::RequirementsList
|
||||||
WelcomeViewStep::checkRequirements()
|
WelcomeViewStep::checkRequirements()
|
||||||
{
|
{
|
||||||
return m_requirementsChecker->checkRequirements();
|
return m_requirementsChecker->checkRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler )
|
logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler )
|
||||||
{
|
{
|
||||||
if ( handler )
|
if ( handler )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " ("
|
cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " ("
|
||||||
<< static_cast< int >( handler->type() ) << handler->selector() << ')';
|
<< static_cast< int >( handler->type() ) << handler->selector() << ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WelcomeViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::Handler* handler )
|
WelcomeViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::Handler* handler )
|
||||||
{
|
{
|
||||||
if ( countryCode.length() != 2 )
|
if ( countryCode.length() != 2 )
|
||||||
{
|
{
|
||||||
cDebug() << "Unusable country code" << countryCode;
|
cDebug() << "Unusable country code" << countryCode;
|
||||||
logGeoIPHandler( handler );
|
logGeoIPHandler( handler );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto c_l = CalamaresUtils::Locale::countryData( countryCode );
|
auto c_l = CalamaresUtils::Locale::countryData( countryCode );
|
||||||
if ( c_l.first == QLocale::Country::AnyCountry )
|
if ( c_l.first == QLocale::Country::AnyCountry )
|
||||||
{
|
{
|
||||||
cDebug() << "Unusable country code" << countryCode;
|
cDebug() << "Unusable country code" << countryCode;
|
||||||
logGeoIPHandler( handler );
|
logGeoIPHandler( handler );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode );
|
int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode );
|
||||||
if ( r < 0 )
|
if ( r < 0 )
|
||||||
{
|
{
|
||||||
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";
|
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";
|
||||||
}
|
}
|
||||||
if ( ( r >= 0 ) && m_conf )
|
if ( ( r >= 0 ) && m_conf )
|
||||||
{
|
{
|
||||||
m_conf->setCountryCode( countryCode );
|
m_conf->setCountryCode( countryCode );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,22 +16,22 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WELCOMEPAGEPLUGIN_H
|
#ifndef WELCOMEVIEWSTEP_H
|
||||||
#define WELCOMEPAGEPLUGIN_H
|
#define WELCOMEVIEWSTEP_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
#include "modulesystem/Requirement.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;
|
class Config;
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace CalamaresUtils
|
||||||
{
|
{
|
||||||
namespace GeoIP
|
namespace GeoIP
|
||||||
@ -75,9 +75,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
WelcomePage* m_widget;
|
WelcomePage* m_widget;
|
||||||
GeneralRequirements* m_requirementsChecker;
|
GeneralRequirements* m_requirementsChecker;
|
||||||
Config *m_conf;
|
Config* m_conf;
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( WelcomeViewStepFactory )
|
||||||
|
|
||||||
#endif // WELCOMEPAGEPLUGIN_H
|
#endif // WELCOMEVIEWSTEP_H
|
||||||
|
@ -41,7 +41,7 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin<
|
|||||||
|
|
||||||
WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent )
|
WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent )
|
||||||
: Calamares::QmlViewStep(parent )
|
: Calamares::QmlViewStep(parent )
|
||||||
, m_config( new Config( ) ) // the qml singleton takes ownership and deletes it
|
, m_config( new Config( this ) ) // the qml singleton takes ownership and deletes it
|
||||||
// , m_nextEnabled( false )
|
// , m_nextEnabled( false )
|
||||||
, m_requirementsChecker( new GeneralRequirements( this ) )
|
, m_requirementsChecker( new GeneralRequirements( this ) )
|
||||||
|
|
||||||
@ -98,10 +98,46 @@ WelcomeQmlViewStep::jobs() const
|
|||||||
return Calamares::JobList();
|
return Calamares::JobList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Look up a URL for a button
|
||||||
|
*
|
||||||
|
* 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 ) )
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
using Calamares::Branding;
|
using Calamares::Branding;
|
||||||
|
m_config->setSupportUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
|
||||||
|
m_config->setKnownIssuesUrl( jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
|
||||||
|
m_config->setReleaseNotesUrl( jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
|
||||||
|
m_config->setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
|
||||||
|
|
||||||
// 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
|
// 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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user