From b8762ddb38dd975b0acb217b793594dfed83a824 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 12 Sep 2020 14:10:13 +0300 Subject: Initial commit --- main.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6c9af57 --- /dev/null +++ b/main.cpp @@ -0,0 +1,69 @@ +#include +#include +#include + +#include "accounts_model.h" +#include "message.h" +#include "chat.h" +#include "chatlist.h" +#include "context.h" +#include "contact.h" +#include "eventemitter.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + + QGuiApplication app(argc, argv); + + app.setApplicationName("DeltaChat"); + app.setOrganizationName("DeltaChat"); + app.setOrganizationDomain("delta.chat"); + + // TODO: switch to using Qt 5.15 QML_ELEMENT macro + if (qmlRegisterType("DeltaChat", 1, 0, "AccountsModel") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcContext") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcChatlist") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcChat") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcMessage") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcContact") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcLot") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType("DeltaChat", 1, 0, "DcAccountsEventEmitter") == -1) + { + QCoreApplication::exit(-1); + } + qRegisterMetaType("size_t"); + qRegisterMetaType("uint32_t"); + + QQmlApplicationEngine engine; + const QUrl url(QStringLiteral("qrc:/qml/main.qml")); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, + &app, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +} -- cgit v1.2.3-70-g09d2