linphone-desktop/Linphone/core/App.cpp
Julien Wadel 23c0b9bd42 Add an example of Cpp model for views.
Remove qml folder.
Update SDK
2023-10-03 15:44:20 +02:00

40 lines
No EOL
1 KiB
C++

#include "App.hpp"
#include <QCoreApplication>
#include "tool/Constants.hpp"
#include "view/Page/LoginPage.hpp"
App::App(QObject * parent) : QObject(parent) {
init();
}
//-----------------------------------------------------------
// Initializations
//-----------------------------------------------------------
void App::init() {
// Core
mCoreModel = QSharedPointer<CoreModel>::create("", this);
mCoreModel->start();
// QML
mEngine = new QQmlApplicationEngine(this);
mEngine->addImportPath(":/");
initCppInterfaces();
const QUrl url(u"qrc:/Linphone/view/App/Main.qml"_qs);
QObject::connect(mEngine, &QQmlApplicationEngine::objectCreated,
this, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
mEngine->load(url);
}
void App::initCppInterfaces() {
qmlRegisterSingletonType<LoginPage>(Constants::MainQmlUri, 1, 0, "LoginPageCpp", [](QQmlEngine *engine, QJSEngine *) -> QObject *{
return new LoginPage(engine);
});
}