main.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2010 Nokia Corporation.
  3. */
  4. #include <QtGui/QApplication>
  5. #include <QDesktopWidget>
  6. #include "mainwindow.h"
  7. // Lock S60 orientation
  8. #ifdef Q_OS_SYMBIAN
  9. #include <eikenv.h>
  10. #include <eikappui.h>
  11. #include <aknenv.h>
  12. #include <aknappui.h>
  13. #endif
  14. #ifndef QT_NO_OPENGL
  15. #include <QGLWidget>
  16. #endif
  17. int main(int argc, char *argv[])
  18. {
  19. QApplication a(argc, argv);
  20. // Lock S60 orientation
  21. #ifdef Q_OS_SYMBIAN
  22. CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
  23. TRAPD(error,
  24. if (appUi) {
  25. appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
  26. }
  27. );
  28. #endif
  29. MainWindow w;
  30. #ifndef QT_NO_OPENGL
  31. // Use QGLWidget to get the opengl support if available
  32. QGLFormat format = QGLFormat::defaultFormat();
  33. format.setSampleBuffers(false);
  34. QGLWidget *glWidget = new QGLWidget(format);
  35. glWidget->setAutoFillBackground(false);
  36. w.setViewport(glWidget); // ownership of glWidget is taken
  37. #endif
  38. QObject *rootObject = dynamic_cast<QObject*>(w.rootObject());
  39. // For Qt.exit() from QML
  40. QObject::connect((QObject*)w.engine(), SIGNAL(quit()), &a, SLOT(quit()));
  41. // Level activation signal from QML
  42. QObject::connect(rootObject, SIGNAL(levelActivated(int)), &w, SLOT(levelActivated(int)));
  43. #if defined (Q_OS_SYMBIAN) || defined (Q_WS_MAEMO_5)
  44. w.setGeometry(QApplication::desktop()->screenGeometry());
  45. w.showFullScreen();
  46. #else
  47. w.setGeometry(100,100,360,640);
  48. w.setFixedSize(360,640);
  49. w.show();
  50. #endif
  51. return a.exec();
  52. }