diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
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 <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QMetaType> + +#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<AccountsModel>("DeltaChat", 1, 0, "AccountsModel") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<Context>("DeltaChat", 1, 0, "DcContext") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<DcChatlist>("DeltaChat", 1, 0, "DcChatlist") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<DcChat>("DeltaChat", 1, 0, "DcChat") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<DcMessage>("DeltaChat", 1, 0, "DcMessage") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<DcContact>("DeltaChat", 1, 0, "DcContact") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<DcLot>("DeltaChat", 1, 0, "DcLot") == -1) + { + QCoreApplication::exit(-1); + } + if (qmlRegisterType<DcAccountsEventEmitter>("DeltaChat", 1, 0, "DcAccountsEventEmitter") == -1) + { + QCoreApplication::exit(-1); + } + qRegisterMetaType<size_t>("size_t"); + qRegisterMetaType<uint32_t>("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(); +} |