-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (51 loc) · 2.03 KB
/
Copy pathmain.cpp
File metadata and controls
58 lines (51 loc) · 2.03 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
#include "Backend/metricsservice.h"
#include "Backend/FileWatcherService.h"
#include "Backend/SyscallTracerService.h"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
// Create MetricsService as a pointer and expose to QML
MetricsService *metricsService = new MetricsService(&app);
if (metricsService) {
// Register as singleton for Qt 6 modules
qmlRegisterSingletonInstance("SmartPersonalDashboard", 1, 0, "Metrics",
metricsService);
// Fallback for existing QML code using lowercase 'metrics'
engine.rootContext()->setContextProperty("metrics", metricsService);
} else {
qCritical() << "Failed to create MetricsService!";
}
// Create FileWatcherService and expose to QML
FileWatcherService fileWatcher;
engine.rootContext()->setContextProperty("fileWatcherService", &fileWatcher);
fileWatcher.start();
// Create SyscallTracerService and expose to QML
SyscallTracerService syscallTracer;
engine.rootContext()->setContextProperty("syscallTracerService", &syscallTracer);
// Parse command line trace arguments
QString traceBinary;
QStringList traceArgs;
QStringList cmdArgs = QCoreApplication::arguments();
for (int i = 1; i < cmdArgs.size(); ++i) {
if (cmdArgs[i] == "--trace" && i + 1 < cmdArgs.size()) {
traceBinary = cmdArgs[i + 1];
i++;
} else if (cmdArgs[i] == "--trace-args" && i + 1 < cmdArgs.size()) {
traceArgs = cmdArgs[i + 1].split(' ');
i++;
}
}
if (!traceBinary.isEmpty()) {
qDebug() << "Auto-tracing binary from command-line:" << traceBinary << "with args:" << traceArgs;
syscallTracer.traceBinary(traceBinary, traceArgs);
}
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
engine.loadFromModule("SmartPersonalDashboard", "Main");
return app.exec();
}