main.cpp 886 B

12345678910111213141516171819202122232425262728
  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 <QDebug>
  9. int main(int argc, char *argv[])
  10. {
  11. QApplication app(argc, argv);
  12. QQuickView view;
  13. qmlRegisterUncreatableType<GitHandler>("org.semlanik.nicegit", 1, 0, "GitHandler", "Global for qml");
  14. qmlRegisterUncreatableType<GitRepository>("org.semlanik.nicegit", 1, 0, "GitRepository", "Owned only by GitHandler");
  15. qmlRegisterUncreatableType<RepositoryModel>("org.semlanik.nicegit", 1, 0, "RepositoryModel", "Owned only by GitHandler");
  16. GitHandler handler;
  17. handler.open("/home/semlanik/Projects/testrepo/");
  18. view.rootContext()->setContextProperty("_handler", &handler);
  19. view.setSource(QUrl("qrc:/qml/MainView.qml"));
  20. view.showMaximized();
  21. return app.exec();
  22. }