-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (28 loc) · 1.06 KB
/
Copy pathmain.cpp
File metadata and controls
39 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// TODO license note into all sources
#include <QtQml>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <gmime/gmime.h>
#include "notmuch/database.h"
#include "mime/fileentity.h"
notmuch::DatabaseProxy *proxy = 0;
static QObject* databaseSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return proxy; // owned by QML anyway despite of setObjectOwnership, so proxying
}
int main(int argc, char *argv[])
{
g_mime_init(0);
atexit(g_mime_shutdown);
notmuch::Database db;
db.open();
proxy = new notmuch::DatabaseProxy(&db); // owned by QML, so GC-ed later
qmlRegisterSingletonType<notmuch::Database>("Notquick", 1, 0, "NotmuchDatabase", databaseSingleton);
qmlRegisterType<mime::FileEntity>("Notquick", 1, 0, "MimeFileEntity");
QApplication app(argc, argv); // TODO maybe switch to QGuiApplication
QQmlApplicationEngine engine; // TODO maybe switch to QQmlEngine
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}