[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.
main
Adriaan de Groot 5 years ago
parent 7e0cc7af41
commit f094cb543b

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

@ -73,7 +73,7 @@ public:
/// @brief QML widgets don't produce jobs by default /// @brief QML widgets don't produce jobs by default
virtual JobList jobs() const override; 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; virtual void setConfigurationMap( const QVariantMap& configurationMap ) override;
protected: protected:

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

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

Loading…
Cancel
Save