-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (48 loc) · 1.73 KB
/
main.cpp
File metadata and controls
59 lines (48 loc) · 1.73 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "src/spice/spice.h"
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "src/settings.h"
#include "src/server.h"
#include "src/startup.h"
#include "src/power.h"
#include "src/virt.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QQmlApplicationEngine engine;
// get username
QString username = qgetenv("USER");
if (username.isEmpty())
username = qgetenv("USERNAME");
engine.rootContext()->setContextProperty("username", username);
// libvirt
virConnectPtr conn = nullptr;
virDomainPtr domain = nullptr;
Virt(&username, &conn, &domain);
// Server
Server server(&username);
engine.rootContext()->setContextProperty("serverBackend", &server);
// Spice
Spice spice(QString("/home/%1/.config/ECO/display.sock").arg(username), &server);
engine.rootContext()->setContextProperty("spiceBackend", &spice);
// Startup
Startup startup(&username);
engine.rootContext()->setContextProperty("startupBackend", &startup);
// Settings
Settings settings(&username, &conn, &domain);
engine.rootContext()->setContextProperty("settingsBackend", &settings);
// Power
Power power(&username, conn, domain);
engine.rootContext()->setContextProperty("powerBackend", &power);
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);
spice.connectToGuest();
return app.exec();
}