-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqmlengine.cpp
More file actions
29 lines (28 loc) · 860 Bytes
/
Copy pathqmlengine.cpp
File metadata and controls
29 lines (28 loc) · 860 Bytes
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
#include <QQmlContext>
#include <QQmlEngine>
#include <QtQml>
#include <QUrl>
#include <QFile>
#include <QString>
#include <QTextStream>
#include "qmlengine.h"
#include "file.h"
void QmlEngine::initialize(FileBackend &backend)
{
#ifdef QT_DEBUG
this->rootContext()->setContextProperty("DEBUG", true);
#else
this->rootContext()->setContextProperty("DEBUG", false);
#endif
QString aboutContents;
QFile about(":/about.html");
if (about.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&about);
aboutContents = in.readAll();
}
this->rootContext()->setContextProperty("aboutContents", aboutContents);
this->rootContext()->setContextProperty("backend", &backend);
qmlRegisterType<File>("com.github.galymzhan", 0, 1, "File");
qmlRegisterType<FileBackend>("com.github.galymzhan", 0, 1, "FileBackend");
this->load(QUrl("qrc:/main.qml"));
}