-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
80 lines (64 loc) · 3.08 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QFont>
#include <QIcon>
#include <QQmlContext>
#include "ftpclient.h"
#include "allfileslistmodel.h"
#include "selectpathlistmodel.h"
#include "uploadlistmodel.h"
#include "downloadlistmodel.h"
#include "completelistmodel.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QCoreApplication::setOrganizationName("KukaCloudDisk");
QCoreApplication::setApplicationName("Config");
//设置全局字体
QFont font;
font.setFamily(u8"微软雅黑");
app.setFont(font);
app.setWindowIcon(QIcon(":res/main.ico"));
QQmlApplicationEngine engine;
qmlRegisterSingletonType<AllFilesListModel>("AllFilesListModel", 1, 0,
"AllFilesListModel",
[](QQmlEngine*, QJSEngine*) -> QObject* {
return new AllFilesListModel();
});
qmlRegisterSingletonType<UploadListModel>("UploadListModel", 1, 0,
"UploadListModel",
[](QQmlEngine*, QJSEngine*) -> QObject* {
return new UploadListModel();
});
qmlRegisterSingletonType<DownloadListModel>("DownloadListModel", 1, 0,
"DownloadListModel",
[](QQmlEngine*, QJSEngine*) -> QObject* {
return new DownloadListModel();
});
qmlRegisterSingletonType<CompleteListModel>("CompleteListModel", 1, 0,
"CompleteListModel",
[](QQmlEngine*, QJSEngine*) -> QObject* {
return new CompleteListModel();
});
qmlRegisterSingletonType<SelectPathListModel>("SelectPathListModel", 1, 0,
"SelectPathListModel",
[](QQmlEngine*, QJSEngine*) -> QObject* {
return new SelectPathListModel();
});
std::shared_ptr<FtpClient> pClient = std::make_shared<FtpClient>();
engine.rootContext()->setContextProperty("FtpClient", pClient.get());
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);
engine.load(url);
//获取根目录列表
pClient->getDirList(true, false,false, "");
return app.exec();
}