From 28c2da12ae773f6170cf1a9b09f357199b56384a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Mar 2020 17:40:03 +0100 Subject: [PATCH] [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 --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 9 ++++++++- src/modules/welcomeq/WelcomeQmlViewStep.cpp | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index a37dfda21..a437c2aeb 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -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(); + } ); } } diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.cpp b/src/modules/welcomeq/WelcomeQmlViewStep.cpp index 6a0767e47..7570de4ae 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.cpp +++ b/src/modules/welcomeq/WelcomeQmlViewStep.cpp @@ -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(); } ); }