main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include <QApplication>
  2. #include <QQmlEngine>
  3. #include <QQuickView>
  4. #include <QQmlContext>
  5. #include <githandler.h>
  6. #include <gitrepository.h>
  7. #include <repositorymodel.h>
  8. #include <gitbranch.h>
  9. #include <commitmodel.h>
  10. #include <QDebug>
  11. int main(int argc, char *argv[])
  12. {
  13. QApplication app(argc, argv);
  14. QQuickView view;
  15. qmlRegisterUncreatableType<GitHandler>("org.semlanik.nicegit", 1, 0, "GitHandler", "Global for qml");
  16. qmlRegisterUncreatableType<GitRepository>("org.semlanik.nicegit", 1, 0, "GitRepository", "Owned only by GitHandler");
  17. qmlRegisterUncreatableType<GitBranch>("org.semlanik.nicegit", 1, 0, "GitRepository", "Owned only by GitHandler");
  18. qmlRegisterUncreatableType<RepositoryModel>("org.semlanik.nicegit", 1, 0, "RepositoryModel", "Owned only by GitHandler");
  19. qmlRegisterUncreatableType<CommitModel>("org.semlanik.nicegit", 1, 0, "CommitModel", "Owned only by GitHandler");
  20. GitHandler handler;
  21. handler.open("/home/semlanik/Projects/testrepo/");
  22. view.rootContext()->setContextProperty("_handler", &handler);
  23. view.setSource(QUrl("qrc:/qml/MainView.qml"));
  24. view.setResizeMode(QQuickView::SizeRootObjectToView);
  25. view.showMaximized();
  26. return app.exec();
  27. }