main.cpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.cutegit", 1, 0, "GitOid", "Owned only by GitHandler");
  30. qmlRegisterUncreatableType<CommitModel>("org.semlanik.cutegit", 1, 0, "CommitModel", "Owned only by GitHandler");
  31. qmlRegisterUncreatableType<CommitGraph>("org.semlanik.cutegit", 1, 0, "CommitGraph", "Owned only by GitHandler");
  32. qmlRegisterUncreatableType<GraphPoint>("org.semlanik.cutegit", 1, 0, "GraphPoint", "Owned only by GitHandler");
  33. qmlRegisterUncreatableType<RepositoryModel>("org.semlanik.cutegit", 1, 0, "RepositoryModel", "Owned only by GitHandler");
  34. qmlRegisterUncreatableType<GitRepository>("org.semlanik.cutegit", 1, 0, "GitRepository", "Owned only by GitHandler");
  35. qmlRegisterUncreatableType<GitBranch>("org.semlanik.cutegit", 1, 0, "GitBranch", "Owned only by GitHandler");
  36. qmlRegisterUncreatableType<GitHandler>("org.semlanik.cutegit", 1, 0, "GitHandler", "Global for qml");
  37. qmlRegisterUncreatableType<GitTag>("org.semlanik.cutegit", 1, 0, "GitTag", "Global for qml");
  38. qmlRegisterUncreatableType<GitDiff>("org.semlanik.cutegit", 1, 0, "GitDiff", "Global for qml");
  39. qmlRegisterUncreatableType<GitCommit>("org.semlanik.cutegit", 1, 0, "GitCommit", "Global for qml");
  40. qmlRegisterUncreatableType<GraphListModel>("org.semlanik.cutegit", 1, 0, "GraphListModel", "Owned only by GitHandler");
  41. qmlRegisterUncreatableType<BranchListModel>("org.semlanik.cutegit", 1, 0, "BranchListModel", "Owned only by GitHandler");
  42. qmlRegisterUncreatableType<TagListModel>("org.semlanik.cutegit", 1, 0, "TagListModel", "Owned only by GitHandler");
  43. qmlRegisterUncreatableType<GitConsole>("org.semlanik.cutegit", 1, 0, "GitConsole", "Owned only by GitHandler");
  44. qmlRegisterUncreatableType<DiffModel>("org.semlanik.cutegit", 1, 0, "DiffModel", "Owned only by GitHandler");
  45. qmlRegisterSingletonType<TooltipViewModel>("org.semlanik.cutegit", 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. view.rootContext()->setContextProperty("_handler", &handler);
  57. view.setSource(QUrl("qrc:/qml/MainView.qml"));
  58. view.setResizeMode(QQuickView::SizeRootObjectToView);
  59. view.showMaximized();
  60. return app.exec();
  61. }