main.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #include <QtGui>
  5. #include <QApplication>
  6. #include <QDeclarativeView>
  7. #include <QDeclarativeContext>
  8. #include <QDeclarativeEngine>
  9. #include <QDebug>
  10. // Lock Symbian orientation
  11. #ifdef Q_OS_SYMBIAN
  12. #include <eikenv.h>
  13. #include <eikappui.h>
  14. #include <aknenv.h>
  15. #include <aknappui.h>
  16. #endif
  17. #include "wateritem.h"
  18. int main(int argc, char *argv[])
  19. {
  20. QApplication a(argc, argv);
  21. // Register WaterItem custom QML item
  22. qmlRegisterType<WaterItem>("CustomItems", 1, 0, "WaterItem");
  23. // Lock Symbian orientation
  24. #ifdef Q_OS_SYMBIAN
  25. CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
  26. TRAP_IGNORE(
  27. if (appUi) {
  28. appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
  29. }
  30. );
  31. #endif
  32. QDeclarativeView* view = new QDeclarativeView();
  33. // Tell the QML side the path of where app exist
  34. view->rootContext()->setContextProperty("appFolder",view->engine()->baseUrl().toString());
  35. view->setSource(QUrl("qrc:/main.qml"));
  36. view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
  37. // For Qt.quit() from QML
  38. QObject::connect((QObject*)view->engine(), SIGNAL(quit()), &a, SLOT(quit()));
  39. view->showFullScreen();
  40. int ret = a.exec();
  41. delete view;
  42. return ret;
  43. }