main.cpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <QApplication>
  2. #include <QQmlEngine>
  3. #include <QQuickView>
  4. #include <QQmlContext>
  5. #include <QFontDatabase>
  6. #include <githandler.h>
  7. #include <gitconsole.h>
  8. #include <gitrepository.h>
  9. #include <repositorymodel.h>
  10. #include <gitbranch.h>
  11. #include <commitmodel.h>
  12. #include <graphpoint.h>
  13. #include <commitgraph.h>
  14. #include <gittag.h>
  15. #include <gitdiff.h>
  16. #include <gitoid.h>
  17. #include <tooltipviewmodel.h>
  18. #include <diffmodel.h>
  19. #include <graphlistmodel.h>
  20. #include <branchlistmodel.h>
  21. #include <taglistmodel.h>
  22. #include <QDebug>
  23. static TooltipViewModel* ttmodel = nullptr;
  24. int main(int argc, char *argv[])
  25. {
  26. QApplication app(argc, argv);
  27. QFontDatabase::addApplicationFont(":/fonts/Inconsolata.otf");
  28. QQuickView view;
  29. qmlRegisterUncreatableType<GitOid>("org.semlanik.nicegit", 1, 0, "GitOid", "Owned only by GitHandler");
  30. qmlRegisterUncreatableType<CommitModel>("org.semlanik.nicegit", 1, 0, "CommitModel", "Owned only by GitHandler");
  31. qmlRegisterUncreatableType<CommitGraph>("org.semlanik.nicegit", 1, 0, "CommitGraph", "Owned only by GitHandler");
  32. qmlRegisterUncreatableType<GraphPoint>("org.semlanik.nicegit", 1, 0, "GraphPoint", "Owned only by GitHandler");
  33. qmlRegisterUncreatableType<RepositoryModel>("org.semlanik.nicegit", 1, 0, "RepositoryModel", "Owned only by GitHandler");
  34. qmlRegisterUncreatableType<GitRepository>("org.semlanik.nicegit", 1, 0, "GitRepository", "Owned only by GitHandler");
  35. qmlRegisterUncreatableType<GitBranch>("org.semlanik.nicegit", 1, 0, "GitBranch", "Owned only by GitHandler");
  36. qmlRegisterUncreatableType<GitHandler>("org.semlanik.nicegit", 1, 0, "GitHandler", "Global for qml");
  37. qmlRegisterUncreatableType<GitTag>("org.semlanik.nicegit", 1, 0, "GitTag", "Global for qml");
  38. qmlRegisterUncreatableType<GitDiff>("org.semlanik.nicegit", 1, 0, "GitDiff", "Global for qml");
  39. qmlRegisterUncreatableType<GitCommit>("org.semlanik.nicegit", 1, 0, "GitCommit", "Global for qml");
  40. qmlRegisterUncreatableType<GraphListModel>("org.semlanik.nicegit", 1, 0, "GraphListModel", "Owned only by GitHandler");
  41. qmlRegisterUncreatableType<BranchListModel>("org.semlanik.nicegit", 1, 0, "BranchListModel", "Owned only by GitHandler");
  42. qmlRegisterUncreatableType<TagListModel>("org.semlanik.nicegit", 1, 0, "TagListModel", "Owned only by GitHandler");
  43. qmlRegisterUncreatableType<GitConsole>("org.semlanik.nicegit", 1, 0, "GitConsole", "Owned only by GitHandler");
  44. qmlRegisterUncreatableType<DiffModel>("org.semlanik.nicegit", 1, 0, "DiffModel", "Owned only by GitHandler");
  45. qmlRegisterSingletonType<TooltipViewModel>("org.semlanik.nicegit", 1, 0,"TooltipViewModel",
  46. [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject*
  47. {
  48. Q_UNUSED(engine)
  49. Q_UNUSED(scriptEngine)
  50. if(!ttmodel) {
  51. ttmodel = new TooltipViewModel;
  52. }
  53. return ttmodel;
  54. });
  55. GitHandler handler;
  56. handler.open("/home/semlanik/Projects/HCAT/hmi_hcat/demo/default/HCAT/");
  57. view.rootContext()->setContextProperty("_handler", &handler);
  58. view.setSource(QUrl("qrc:/qml/MainView.qml"));
  59. view.setResizeMode(QQuickView::SizeRootObjectToView);
  60. view.showMaximized();
  61. return app.exec();
  62. }