[welcome] using config for both qcc2 or qwidgets
This commit is contained in:
parent
7ec6dff352
commit
d7f7c16958
@ -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
|
||||||
|
273
src/modules/welcome/Config.cpp
Normal file
273
src/modules/welcome/Config.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
162
src/modules/welcome/Config.h
Normal file
162
src/modules/welcome/Config.h
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/* === 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( bool isNextEnabled MEMBER m_isNextEnabled NOTIFY isNextEnabledChanged 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
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
@ -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.
|
||||||
|
@ -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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 )
|
||||||
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
@ -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
|
||||||
|
@ -47,13 +47,15 @@
|
|||||||
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++ )
|
||||||
{
|
{
|
||||||
|
const auto &entry = model.getEntry(i);
|
||||||
if ( !predicate(entry))
|
if ( !predicate(entry))
|
||||||
{
|
{
|
||||||
resultWidgets.append( nullptr );
|
resultWidgets.append( nullptr );
|
||||||
@ -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/>"
|
||||||
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
# This is a re-write of the welcome module using QML view steps
|
# This is a re-write of the welcome module using QML view steps
|
||||||
# instead of widgets.
|
# instead of widgets.
|
||||||
|
|
||||||
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 ${_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 )
|
||||||
|
|
||||||
find_package( LIBPARTED )
|
#find_package( LIBPARTED )
|
||||||
if ( LIBPARTED_FOUND )
|
#if ( LIBPARTED_FOUND )
|
||||||
set( PARTMAN_SRC ${_welcome}/checker/partman_devices.c )
|
# set( PARTMAN_SRC ${_welcome}/checker/partman_devices.c )
|
||||||
set( CHECKER_LINK_LIBRARIES ${LIBPARTED_LIBRARY} )
|
# set( CHECKER_LINK_LIBRARIES ${LIBPARTED_LIBRARY} )
|
||||||
else()
|
#else()
|
||||||
set( PARTMAN_SRC )
|
# set( PARTMAN_SRC )
|
||||||
set( CHECKER_LINK_LIBRARIES )
|
# set( CHECKER_LINK_LIBRARIES )
|
||||||
add_definitions( -DWITHOUT_LIBPARTED )
|
# add_definitions( -DWITHOUT_LIBPARTED )
|
||||||
endif()
|
#endif()
|
||||||
|
|
||||||
set( CHECKER_SOURCES
|
#set( CHECKER_SOURCES
|
||||||
${_welcome}/checker/CheckerContainer.cpp
|
# ${_welcome}/checker/CheckerContainer.cpp
|
||||||
${_welcome}/checker/GeneralRequirements.cpp
|
# ${_welcome}/checker/GeneralRequirements.cpp
|
||||||
${_welcome}/checker/ResultWidget.cpp
|
# ${_welcome}/checker/ResultWidget.cpp
|
||||||
${_welcome}/checker/ResultsListWidget.cpp
|
# ${_welcome}/checker/ResultsListWidget.cpp
|
||||||
${PARTMAN_SRC}
|
# ${PARTMAN_SRC}
|
||||||
)
|
#)
|
||||||
|
|
||||||
calamares_add_plugin( welcomeq
|
#calamares_add_plugin( welcomeq
|
||||||
TYPE viewmodule
|
# TYPE viewmodule
|
||||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
# EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||||
SOURCES
|
# SOURCES
|
||||||
${CHECKER_SOURCES}
|
# ${CHECKER_SOURCES}
|
||||||
WelcomeQmlViewStep.cpp
|
# WelcomeQmlViewStep.cpp
|
||||||
Config.cpp
|
# Config.cpp
|
||||||
RESOURCES
|
# RESOURCES
|
||||||
welcomeq.qrc
|
# welcomeq.qrc
|
||||||
LINK_PRIVATE_LIBRARIES
|
# LINK_PRIVATE_LIBRARIES
|
||||||
calamaresui
|
# calamaresui
|
||||||
${CHECKER_LINK_LIBRARIES}
|
# ${CHECKER_LINK_LIBRARIES}
|
||||||
Qt5::DBus
|
# Qt5::DBus
|
||||||
Qt5::Network
|
# Qt5::Network
|
||||||
SHARED_LIB
|
# SHARED_LIB
|
||||||
)
|
#)
|
||||||
|
Loading…
Reference in New Issue
Block a user