[welcome] Switch to using the message from the Config object
- The Config object owns the requirements model, and has messages / strings describing the state of the model. Use that message, dropping the duplicate message from the requirements widget. - Re-jig to pass the Config object around rather than the model that it owns. - This does not work, because translation events do not arrive (and the slot isn't called automatically either).
This commit is contained in:
parent
b81bc17560
commit
51c5c9ba26
@ -63,11 +63,11 @@ Config::retranslate()
|
||||
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." )
|
||||
"might be reduced." )
|
||||
: tr( "This computer does not satisfy some of the "
|
||||
"recommended requirements for installing %1.<br/>"
|
||||
"Installation can continue, but some features "
|
||||
"might be disabled." );
|
||||
"might be reduced." );
|
||||
}
|
||||
|
||||
m_warningMessage = message.arg( Calamares::Branding::instance()->shortVersionedName() );
|
||||
|
@ -36,12 +36,12 @@
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
|
||||
WelcomePage::WelcomePage( Config* conf, QWidget* parent )
|
||||
WelcomePage::WelcomePage( Config* config, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::WelcomePage )
|
||||
, m_checkingWidget( new CheckerContainer( *( conf->requirementsModel() ), this ) )
|
||||
, m_checkingWidget( new CheckerContainer( config, this ) )
|
||||
, m_languages( nullptr )
|
||||
, m_conf( conf )
|
||||
, m_conf( config )
|
||||
{
|
||||
using Branding = Calamares::Branding;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class WelcomePage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WelcomePage( Config* conf, QWidget* parent = nullptr );
|
||||
WelcomePage( Config* config, QWidget* parent = nullptr );
|
||||
|
||||
enum class Button
|
||||
{
|
||||
|
@ -22,12 +22,12 @@
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
CheckerContainer::CheckerContainer( const Calamares::RequirementsModel& model, QWidget* parent )
|
||||
CheckerContainer::CheckerContainer( Config* config, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_waitingWidget( new WaitingWidget( QString(), this ) )
|
||||
, m_checkerWidget( nullptr )
|
||||
, m_verdict( false )
|
||||
, m_model( model )
|
||||
, m_config( config )
|
||||
{
|
||||
QBoxLayout* mainLayout = new QHBoxLayout;
|
||||
setLayout( mainLayout );
|
||||
@ -49,13 +49,14 @@ CheckerContainer::requirementsComplete( bool ok )
|
||||
{
|
||||
if ( !ok )
|
||||
{
|
||||
cDebug() << "Requirements not satisfied" << m_model.count() << "entries:";
|
||||
for ( int i = 0; i < m_model.count(); ++i )
|
||||
auto& model = *( m_config->requirementsModel() );
|
||||
cDebug() << "Requirements not satisfied" << model.count() << "entries:";
|
||||
for ( int i = 0; i < model.count(); ++i )
|
||||
{
|
||||
auto index = m_model.index( i );
|
||||
cDebug() << Logger::SubEntry << i << m_model.data( index, Calamares::RequirementsModel::Name ).toString()
|
||||
<< "set?" << m_model.data( index, Calamares::RequirementsModel::Satisfied ).toBool() << "req?"
|
||||
<< m_model.data( index, Calamares::RequirementsModel::Mandatory ).toBool();
|
||||
auto index = model.index( i );
|
||||
cDebug() << Logger::SubEntry << i << model.data( index, Calamares::RequirementsModel::Name ).toString()
|
||||
<< "set?" << model.data( index, Calamares::RequirementsModel::Satisfied ).toBool() << "req?"
|
||||
<< model.data( index, Calamares::RequirementsModel::Mandatory ).toBool();
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ CheckerContainer::requirementsComplete( bool ok )
|
||||
m_waitingWidget->deleteLater();
|
||||
m_waitingWidget = nullptr; // Don't delete in destructor
|
||||
|
||||
m_checkerWidget = new ResultsListWidget( m_model, this );
|
||||
m_checkerWidget = new ResultsListWidget( m_config, this );
|
||||
m_checkerWidget->setObjectName( "requirementsChecker" );
|
||||
layout()->addWidget( m_checkerWidget );
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define CHECKERCONTAINER_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ResultsListWidget;
|
||||
@ -31,7 +32,7 @@ class CheckerContainer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheckerContainer( const Calamares::RequirementsModel& model, QWidget* parent = nullptr );
|
||||
explicit CheckerContainer( Config* config, QWidget* parent = nullptr );
|
||||
~CheckerContainer() override;
|
||||
|
||||
bool verdict() const;
|
||||
@ -49,7 +50,7 @@ protected:
|
||||
bool m_verdict;
|
||||
|
||||
private:
|
||||
const Calamares::RequirementsModel& m_model;
|
||||
Config* m_config = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -149,9 +149,9 @@ ResultsListDialog::retranslate()
|
||||
}
|
||||
|
||||
|
||||
ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model, QWidget* parent )
|
||||
ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_model( model )
|
||||
, m_config( config )
|
||||
{
|
||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
@ -169,23 +169,25 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model,
|
||||
spacerLayout->addSpacing( paddingSize );
|
||||
CalamaresUtils::unmarginLayout( spacerLayout );
|
||||
|
||||
m_explanation = new QLabel;
|
||||
m_explanation->setWordWrap( true );
|
||||
m_explanation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||
m_explanation->setOpenExternalLinks( false );
|
||||
m_explanation->setObjectName( "resultsExplanation" );
|
||||
connect( m_explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked );
|
||||
entriesLayout->addWidget( m_explanation );
|
||||
auto* explanation = new QLabel;
|
||||
explanation->setWordWrap( true );
|
||||
explanation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||
explanation->setOpenExternalLinks( false );
|
||||
explanation->setObjectName( "resultsExplanation" );
|
||||
connect( explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked );
|
||||
entriesLayout->addWidget( explanation );
|
||||
|
||||
connect( config, &Config::warningMessageChanged, explanation, &QLabel::setText );
|
||||
|
||||
// Check that all are satisfied (gives warnings if not) and
|
||||
// all *mandatory* entries are satisfied (gives errors if not).
|
||||
|
||||
const bool requirementsSatisfied = m_model.satisfiedRequirements();
|
||||
const bool requirementsSatisfied = config->requirementsModel()->satisfiedRequirements();
|
||||
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) {
|
||||
return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool();
|
||||
};
|
||||
|
||||
createResultWidgets( entriesLayout, m_resultWidgets, model, isUnSatisfied );
|
||||
createResultWidgets( entriesLayout, m_resultWidgets, *( config->requirementsModel() ), isUnSatisfied );
|
||||
|
||||
if ( !requirementsSatisfied )
|
||||
{
|
||||
@ -220,7 +222,7 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model,
|
||||
mainLayout->addWidget( imageLabel );
|
||||
}
|
||||
}
|
||||
m_explanation->setAlignment( Qt::AlignCenter );
|
||||
explanation->setAlignment( Qt::AlignCenter );
|
||||
}
|
||||
|
||||
CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate );
|
||||
@ -233,7 +235,7 @@ ResultsListWidget::linkClicked( const QString& link )
|
||||
{
|
||||
if ( link == "#details" )
|
||||
{
|
||||
auto* dialog = new ResultsListDialog( m_model, this );
|
||||
auto* dialog = new ResultsListDialog( *( m_config->requirementsModel() ), this );
|
||||
dialog->exec();
|
||||
dialog->deleteLater();
|
||||
}
|
||||
@ -242,52 +244,15 @@ ResultsListWidget::linkClicked( const QString& link )
|
||||
void
|
||||
ResultsListWidget::retranslate()
|
||||
{
|
||||
for ( auto i = 0; i < m_model.count(); i++ )
|
||||
const auto& model = *( m_config->requirementsModel() );
|
||||
for ( auto i = 0; i < model.count(); i++ )
|
||||
{
|
||||
if ( m_resultWidgets[ i ] )
|
||||
{
|
||||
m_resultWidgets[ i ]->setText(
|
||||
m_model.data( m_model.index( i ), Calamares::RequirementsModel::NegatedText ).toString() );
|
||||
model.data( model.index( i ), Calamares::RequirementsModel::NegatedText ).toString() );
|
||||
}
|
||||
}
|
||||
|
||||
// Check that all are satisfied (gives warnings if not) and
|
||||
// all *mandatory* entries are satisfied (gives errors if not).
|
||||
|
||||
if ( !m_model.satisfiedRequirements() )
|
||||
{
|
||||
QString message;
|
||||
const bool setup = Calamares::Settings::instance()->isSetupMode();
|
||||
if ( !m_model.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_explanation->setText( message.arg( Calamares::Branding::instance()->shortVersionedName() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_explanation->setText( tr( "This program will ask you some questions and "
|
||||
"set up %2 on your computer." )
|
||||
.arg( Calamares::Branding::instance()->productName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
#include "utils/moc-warnings.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "ResultWidget.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
@ -21,16 +22,15 @@ class ResultsListWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ResultsListWidget( const Calamares::RequirementsModel& model, QWidget* parent );
|
||||
explicit ResultsListWidget( Config* config, QWidget* parent );
|
||||
|
||||
private:
|
||||
/// @brief A link in the explanatory text has been clicked
|
||||
void linkClicked( const QString& link );
|
||||
void retranslate();
|
||||
|
||||
QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link
|
||||
const Calamares::RequirementsModel& m_model;
|
||||
QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry
|
||||
Config* m_config = nullptr;
|
||||
};
|
||||
|
||||
#endif // CHECKER_RESULTSLISTWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user