-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
52 lines (39 loc) · 1.52 KB
/
main.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QIcon>
#include <QDebug>
#include "mnoteshandler.h"
#include "mnotesnetwork.h"
#include "mnotesconfig.h"
int main(int argc, char *argv[])
{
qmlRegisterType<MNotesHandler>("de.bibuweb.mnotes",1,0,"MNotesHandler");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
app.setWindowIcon(QIcon(QPixmap("qrc:/images/notes.png")));
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
QQmlContext *context = new QQmlContext(engine.rootContext());
QQmlComponent component(&engine,url);
MNotesHandler mnotes;
MNotesNetwork network;
MnotesConfig config;
context->setContextProperty("document",&mnotes);
context->setContextProperty("netWork",&network);
context->setContextProperty("configData",&config);
QObject *appWindow = component.create(context);
if (component.isError())
{
qDebug() << component.errorString();
}
mnotes.setTextObject(appWindow);
QObject::connect(appWindow,SIGNAL(searchSignal(QString, QString)),&mnotes,SLOT(searchSignal(QString, QString)));
QObject::connect(appWindow,SIGNAL(findNext()),&mnotes,SLOT(findNext()));
return app.exec();
}