[libcalamaresui] Register in io.calamares namespace

- Register both Branding and ViewManager for QML
- Note that this changes the name of Branding
- Add code-docs about object ownership
This commit is contained in:
Adriaan de Groot 2020-03-11 17:40:03 +01:00
parent 7a8eb09cdb
commit 28c2da12ae
2 changed files with 8 additions and 2 deletions

View File

@ -74,10 +74,17 @@ registerCalamaresModels()
if ( !done )
{
done = true;
// Because branding and viewmanager have a parent (CalamaresApplication
// and CalamaresWindow), they will not be deleted by QmlEngine.
// https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
qmlRegisterSingletonType< Calamares::Branding >(
"calamares.ui", 1, 0, "Branding", []( QQmlEngine*, QJSEngine* ) -> QObject* {
"io.calamares.ui", 1, 0, "Branding", []( QQmlEngine*, QJSEngine* ) -> QObject* {
return Calamares::Branding::instance();
} );
qmlRegisterSingletonType< Calamares::Branding >(
"io.calamares.core", 1, 0, "ViewManager", []( QQmlEngine*, QJSEngine* ) -> QObject* {
return Calamares::ViewManager::instance();
} );
}
}

View File

@ -52,7 +52,6 @@ WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent )
// &WelcomeQmlViewStep::nextStatusChanged );
// emit nextStatusChanged(true);
qmlRegisterSingletonType< Config >( "io.calamares.module", 1, 0, "Welcome", [&](QQmlEngine*, QJSEngine*) -> QObject* { return m_config; } );
qmlRegisterSingletonType< Calamares::Branding >( "io.calamares.ui", 1, 0, "Branding", [](QQmlEngine*, QJSEngine*) -> QObject* { return Calamares::Branding::instance(); } );
}