main.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <graphlistmodel.h>
  19. #include <branchlistmodel.h>
  20. #include <taglistmodel.h>
  21. #include <QDebug>
  22. static TooltipViewModel* ttmodel = nullptr;
  23. int main(int argc, char *argv[])
  24. {
  25. QApplication app(argc, argv);
  26. QFontDatabase::addApplicationFont(":/fonts/Inconsolata.otf");
  27. QQuickView view;
  28. qmlRegisterUncreatableType<GitOid>("org.semlanik.nicegit", 1, 0, "GitOid", "Owned only by GitHandler");
  29. qmlRegisterUncreatableType<CommitModel>("org.semlanik.nicegit", 1, 0, "CommitModel", "Owned only by GitHandler");
  30. qmlRegisterUncreatableType<CommitGraph>("org.semlanik.nicegit", 1, 0, "CommitGraph", "Owned only by GitHandler");
  31. qmlRegisterUncreatableType<GraphPoint>("org.semlanik.nicegit", 1, 0, "GraphPoint", "Owned only by GitHandler");
  32. qmlRegisterUncreatableType<RepositoryModel>("org.semlanik.nicegit", 1, 0, "RepositoryModel", "Owned only by GitHandler");
  33. qmlRegisterUncreatableType<GitRepository>("org.semlanik.nicegit", 1, 0, "GitRepository", "Owned only by GitHandler");
  34. qmlRegisterUncreatableType<GitBranch>("org.semlanik.nicegit", 1, 0, "GitBranch", "Owned only by GitHandler");
  35. qmlRegisterUncreatableType<GitHandler>("org.semlanik.nicegit", 1, 0, "GitHandler", "Global for qml");
  36. qmlRegisterUncreatableType<GitTag>("org.semlanik.nicegit", 1, 0, "GitTag", "Global for qml");
  37. qmlRegisterUncreatableType<GitDiff>("org.semlanik.nicegit", 1, 0, "GitDiff", "Global for qml");
  38. qmlRegisterUncreatableType<GitCommit>("org.semlanik.nicegit", 1, 0, "GitCommit", "Global for qml");
  39. qmlRegisterUncreatableType<GraphListModel>("org.semlanik.nicegit", 1, 0, "GraphListModel", "Owned only by GitHandler");
  40. qmlRegisterUncreatableType<BranchListModel>("org.semlanik.nicegit", 1, 0, "BranchListModel", "Owned only by GitHandler");
  41. qmlRegisterUncreatableType<TagListModel>("org.semlanik.nicegit", 1, 0, "TagListModel", "Owned only by GitHandler");
  42. qmlRegisterUncreatableType<GitConsole>("org.semlanik.nicegit", 1, 0, "GitConsole", "Owned only by GitHandler");
  43. qmlRegisterSingletonType<TooltipViewModel>("org.semlanik.nicegit", 1, 0,"TooltipViewModel",
  44. [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject*
  45. {
  46. Q_UNUSED(engine)
  47. Q_UNUSED(scriptEngine)
  48. if(!ttmodel) {
  49. ttmodel = new TooltipViewModel;
  50. }
  51. return ttmodel;
  52. });
  53. GitHandler handler;
  54. handler.open("/home/semlanik/Projects/HCAT/hmi_hcat/demo/default/HCAT/");
  55. view.rootContext()->setContextProperty("_handler", &handler);
  56. view.setSource(QUrl("qrc:/qml/MainView.qml"));
  57. view.setResizeMode(QQuickView::SizeRootObjectToView);
  58. view.showMaximized();
  59. return app.exec();
  60. }