main.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <QGuiApplication>
  2. #include <QObject>
  3. #include <QQmlApplicationEngine>
  4. #include <QQmlComponent>
  5. #include <QQmlContext>
  6. #include <csignal>
  7. #include <cstdio>
  8. #include <cstdlib>
  9. #include <cstring>
  10. #include <iostream>
  11. #include <sys/prctl.h>
  12. #include <sys/wait.h>
  13. #include <thread>
  14. #include <unistd.h>
  15. #include "qmlhandler.h"
  16. using namespace std;
  17. int main(int argc, char *argv[]) {
  18. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  19. // This has to be here to fix warnings
  20. QCoreApplication::setOrganizationName("CCats");
  21. QGuiApplication app(argc, argv);
  22. QQmlApplicationEngine engine;
  23. QMLHandler qmlHandler;
  24. // Set the context for the window, so that the qml files can be connected to
  25. // the qmlHandler
  26. engine.rootContext()->setContextProperty("_qmlHandler", &qmlHandler);
  27. // Load the main window
  28. QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/main.qml")));
  29. QObject *object = component.create();
  30. // Run the main window and save the return of the application in an integer
  31. // ret This is blocking, which means it will block the main program until the
  32. // window is closed
  33. int ret = app.exec();
  34. // If we land here, the window has been closed. Properly disconnect from the
  35. // server now
  36. qmlHandler.onExit();
  37. return ret;
  38. }