[libcalamaresui] Set config object earlier

- The config context object should be set earlier, otherwise
   QML code will try binding to a non-existent config already
 - Document that QMLViewStep::setConfigurationMap() parent implementation
   should be called **last**, at the end of the subclass implementation.
This commit is contained in:
Adriaan de Groot 2020-02-12 22:33:49 +01:00
parent 7e0cc7af41
commit f094cb543b
4 changed files with 12 additions and 11 deletions

View File

@ -210,11 +210,6 @@ QmlViewStep::loadComplete()
// It is marked \internal in the Qt sources, but does exactly
// what is needed: sets up visual parent by replacing the root
// item, and handling resizes.
QObject* config = this->getConfig();
if ( config )
{
m_qmlWidget->engine()->rootContext()->setContextProperty( "config", config );
}
m_qmlWidget->setContent( QUrl( m_qmlFileName ), m_qmlComponent, m_qmlObject );
showQml();
}
@ -320,6 +315,12 @@ QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, m_name );
QObject* config = this->getConfig();
if ( config )
{
m_qmlWidget->engine()->rootContext()->setContextProperty( "config", config );
}
cDebug() << "QmlViewStep" << moduleInstanceKey() << "loading" << m_qmlFileName;
m_qmlComponent = new QQmlComponent(
m_qmlWidget->engine(), QUrl( m_qmlFileName ), QQmlComponent::CompilationMode::Asynchronous );

View File

@ -73,7 +73,7 @@ public:
/// @brief QML widgets don't produce jobs by default
virtual JobList jobs() const override;
/// @brief Configure search paths; subclasses should call this as well
/// @brief Configure search paths; subclasses should call this at the **end** of their own implementation
virtual void setConfigurationMap( const QVariantMap& configurationMap ) override;
protected:

View File

@ -36,9 +36,7 @@ NotesQmlViewStep::prettyName() const
void
NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation
{
bool qmlLabel_ok = false;
auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok );
@ -46,7 +44,8 @@ NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" );
}
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
}
CALAMARES_PLUGIN_FACTORY_DEFINITION( NotesQmlViewStepFactory, registerPlugin< NotesQmlViewStep >(); )

View File

@ -90,7 +90,6 @@ jobOrBrandingSetting( Calamares::Branding::StringEntry e, const QVariantMap& map
void
WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
QmlViewStep::setConfigurationMap( configurationMap );
using Calamares::Branding;
m_config.setHelpUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
@ -146,6 +145,8 @@ WelcomeQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// TODO: figure out where to set this: Config?
}
}
QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
}
Calamares::RequirementsList