aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2020-09-12 14:10:13 +0300
committerlink2xt <link2xt@testrun.org>2020-10-03 00:20:03 +0300
commitb8762ddb38dd975b0acb217b793594dfed83a824 (patch)
tree23ccefbba703fed6c07acce82ff72e32ba77c9ba /main.cpp
downloadkdeltachat-b8762ddb38dd975b0acb217b793594dfed83a824.tar.gz
kdeltachat-b8762ddb38dd975b0acb217b793594dfed83a824.zip
Initial commit
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp69
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();
+}