[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 "
|
message = setup ? tr( "This computer does not satisfy some of the "
|
||||||
"recommended requirements for setting up %1.<br/>"
|
"recommended requirements for setting up %1.<br/>"
|
||||||
"Setup can continue, but some features "
|
"Setup can continue, but some features "
|
||||||
"might be disabled." )
|
"might be reduced." )
|
||||||
: tr( "This computer does not satisfy some of the "
|
: tr( "This computer does not satisfy some of the "
|
||||||
"recommended requirements for installing %1.<br/>"
|
"recommended requirements for installing %1.<br/>"
|
||||||
"Installation can continue, but some features "
|
"Installation can continue, but some features "
|
||||||
"might be disabled." );
|
"might be reduced." );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_warningMessage = message.arg( Calamares::Branding::instance()->shortVersionedName() );
|
m_warningMessage = message.arg( Calamares::Branding::instance()->shortVersionedName() );
|
||||||
|
@ -36,12 +36,12 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
WelcomePage::WelcomePage( Config* conf, QWidget* parent )
|
WelcomePage::WelcomePage( Config* config, 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( config, this ) )
|
||||||
, m_languages( nullptr )
|
, m_languages( nullptr )
|
||||||
, m_conf( conf )
|
, m_conf( config )
|
||||||
{
|
{
|
||||||
using Branding = Calamares::Branding;
|
using Branding = Calamares::Branding;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class WelcomePage : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit WelcomePage( Config* conf, QWidget* parent = nullptr );
|
WelcomePage( Config* config, QWidget* parent = nullptr );
|
||||||
|
|
||||||
enum class Button
|
enum class Button
|
||||||
{
|
{
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
CheckerContainer::CheckerContainer( const Calamares::RequirementsModel& model, QWidget* parent )
|
CheckerContainer::CheckerContainer( Config* config, 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 )
|
, m_config( config )
|
||||||
{
|
{
|
||||||
QBoxLayout* mainLayout = new QHBoxLayout;
|
QBoxLayout* mainLayout = new QHBoxLayout;
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
@ -49,13 +49,14 @@ CheckerContainer::requirementsComplete( bool ok )
|
|||||||
{
|
{
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
{
|
{
|
||||||
cDebug() << "Requirements not satisfied" << m_model.count() << "entries:";
|
auto& model = *( m_config->requirementsModel() );
|
||||||
for ( int i = 0; i < m_model.count(); ++i )
|
cDebug() << "Requirements not satisfied" << model.count() << "entries:";
|
||||||
|
for ( int i = 0; i < model.count(); ++i )
|
||||||
{
|
{
|
||||||
auto index = m_model.index( i );
|
auto index = model.index( i );
|
||||||
cDebug() << Logger::SubEntry << i << m_model.data( index, Calamares::RequirementsModel::Name ).toString()
|
cDebug() << Logger::SubEntry << i << model.data( index, Calamares::RequirementsModel::Name ).toString()
|
||||||
<< "set?" << m_model.data( index, Calamares::RequirementsModel::Satisfied ).toBool() << "req?"
|
<< "set?" << model.data( index, Calamares::RequirementsModel::Satisfied ).toBool() << "req?"
|
||||||
<< m_model.data( index, Calamares::RequirementsModel::Mandatory ).toBool();
|
<< model.data( index, Calamares::RequirementsModel::Mandatory ).toBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ 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( m_model, this );
|
m_checkerWidget = new ResultsListWidget( m_config, this );
|
||||||
m_checkerWidget->setObjectName( "requirementsChecker" );
|
m_checkerWidget->setObjectName( "requirementsChecker" );
|
||||||
layout()->addWidget( m_checkerWidget );
|
layout()->addWidget( m_checkerWidget );
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define CHECKERCONTAINER_H
|
#define CHECKERCONTAINER_H
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class ResultsListWidget;
|
class ResultsListWidget;
|
||||||
@ -31,7 +32,7 @@ class CheckerContainer : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CheckerContainer( const Calamares::RequirementsModel& model, QWidget* parent = nullptr );
|
explicit CheckerContainer( Config* config, QWidget* parent = nullptr );
|
||||||
~CheckerContainer() override;
|
~CheckerContainer() override;
|
||||||
|
|
||||||
bool verdict() const;
|
bool verdict() const;
|
||||||
@ -49,7 +50,7 @@ protected:
|
|||||||
bool m_verdict;
|
bool m_verdict;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Calamares::RequirementsModel& m_model;
|
Config* m_config = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -149,9 +149,9 @@ ResultsListDialog::retranslate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model, QWidget* parent )
|
ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_model( model )
|
, m_config( config )
|
||||||
{
|
{
|
||||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||||
|
|
||||||
@ -169,23 +169,25 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model,
|
|||||||
spacerLayout->addSpacing( paddingSize );
|
spacerLayout->addSpacing( paddingSize );
|
||||||
CalamaresUtils::unmarginLayout( spacerLayout );
|
CalamaresUtils::unmarginLayout( spacerLayout );
|
||||||
|
|
||||||
m_explanation = new QLabel;
|
auto* explanation = new QLabel;
|
||||||
m_explanation->setWordWrap( true );
|
explanation->setWordWrap( true );
|
||||||
m_explanation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
explanation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||||
m_explanation->setOpenExternalLinks( false );
|
explanation->setOpenExternalLinks( false );
|
||||||
m_explanation->setObjectName( "resultsExplanation" );
|
explanation->setObjectName( "resultsExplanation" );
|
||||||
connect( m_explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked );
|
connect( explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked );
|
||||||
entriesLayout->addWidget( m_explanation );
|
entriesLayout->addWidget( explanation );
|
||||||
|
|
||||||
|
connect( config, &Config::warningMessageChanged, explanation, &QLabel::setText );
|
||||||
|
|
||||||
// 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).
|
||||||
|
|
||||||
const bool requirementsSatisfied = m_model.satisfiedRequirements();
|
const bool requirementsSatisfied = config->requirementsModel()->satisfiedRequirements();
|
||||||
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) {
|
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) {
|
||||||
return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool();
|
return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool();
|
||||||
};
|
};
|
||||||
|
|
||||||
createResultWidgets( entriesLayout, m_resultWidgets, model, isUnSatisfied );
|
createResultWidgets( entriesLayout, m_resultWidgets, *( config->requirementsModel() ), isUnSatisfied );
|
||||||
|
|
||||||
if ( !requirementsSatisfied )
|
if ( !requirementsSatisfied )
|
||||||
{
|
{
|
||||||
@ -220,7 +222,7 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model,
|
|||||||
mainLayout->addWidget( imageLabel );
|
mainLayout->addWidget( imageLabel );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_explanation->setAlignment( Qt::AlignCenter );
|
explanation->setAlignment( Qt::AlignCenter );
|
||||||
}
|
}
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate );
|
CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate );
|
||||||
@ -233,7 +235,7 @@ ResultsListWidget::linkClicked( const QString& link )
|
|||||||
{
|
{
|
||||||
if ( link == "#details" )
|
if ( link == "#details" )
|
||||||
{
|
{
|
||||||
auto* dialog = new ResultsListDialog( m_model, this );
|
auto* dialog = new ResultsListDialog( *( m_config->requirementsModel() ), this );
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
}
|
}
|
||||||
@ -242,52 +244,15 @@ ResultsListWidget::linkClicked( const QString& link )
|
|||||||
void
|
void
|
||||||
ResultsListWidget::retranslate()
|
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 ] )
|
if ( m_resultWidgets[ i ] )
|
||||||
{
|
{
|
||||||
m_resultWidgets[ i ]->setText(
|
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"
|
#include "utils/moc-warnings.h"
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "ResultWidget.h"
|
#include "ResultWidget.h"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
@ -21,16 +22,15 @@ class ResultsListWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ResultsListWidget( const Calamares::RequirementsModel& model, QWidget* parent );
|
explicit ResultsListWidget( Config* config, QWidget* parent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief A link in the explanatory text has been clicked
|
/// @brief A link in the explanatory text has been clicked
|
||||||
void linkClicked( const QString& link );
|
void linkClicked( const QString& link );
|
||||||
void retranslate();
|
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
|
QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry
|
||||||
|
Config* m_config = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHECKER_RESULTSLISTWIDGET_H
|
#endif // CHECKER_RESULTSLISTWIDGET_H
|
||||||
|
Loading…
Reference in New Issue
Block a user