main.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include <QDeclarativeEngine>
  2. #include <QDeclarativeContext>
  3. #include <QtGui/QApplication>
  4. #include <QIcon>
  5. #include <QSettings>
  6. #include <QTranslator>
  7. #include <QLocale>
  8. #include <QGraphicsObject>
  9. #include "qmlapplicationviewer.h"
  10. #include "EvidenceHuntGame.h"
  11. #include <QDesktopWidget>
  12. #include <QDebug>
  13. Q_DECL_EXPORT int main(int argc, char *argv[]) {
  14. QApplication app(argc, argv);
  15. app.setOrganizationName("BlackWiCKED");
  16. app.setOrganizationDomain("blackwicked.com");
  17. app.setApplicationName("EvidenceHunt Game");
  18. app.setApplicationName("EvidenceHunt Game");
  19. app.setApplicationVersion("1.4.4");
  20. app.setWindowIcon(QIcon(":/qml/EvidencehuntCore/pics/icon.ico"));
  21. QmlApplicationViewer canvas;
  22. qmlRegisterType<TileData>();
  23. qmlRegisterType<SuspectData>();
  24. qmlRegisterType<TopPlayerData>();
  25. qmlRegisterType<EvidenceType>();
  26. qmlRegisterType<EvidenceInfo>();
  27. EvidencehuntGame* game = new EvidencehuntGame(&app);
  28. canvas.engine()->rootContext()->setContextObject(game);
  29. #if defined(Q_EVHUNT_MAEMO) || defined(Q_EVHUNT_MEEGO)
  30. canvas.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
  31. canvas.setSource(QUrl("qrc:///qml/harmattan.qml"));
  32. canvas.setGeometry(QRect(0, 0, 854, 480));
  33. canvas.showFullScreen();
  34. qDebug() << "Harmattan";
  35. #elif defined(Q_EVHUNT_SYMBIAN)
  36. canvas.setSource(QUrl("qrc:///qml/harmattan.qml"));
  37. canvas.setGeometry(QRect(0, 0, 854, 480));
  38. canvas.showFullScreen();
  39. qDebug() << "Symbian";
  40. #elif defined(Q_EVHUNT_BLACKBERRY)
  41. canvas.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
  42. canvas.setSource(QUrl("qrc:///qml/blackberry.qml"));
  43. canvas.showFullScreen();
  44. //qDebug() << "Blackberry";
  45. #else
  46. canvas.setSource(QUrl("qrc:///qml/desktop.qml"));
  47. int width = 854;
  48. int height = 482;
  49. QRect screenGeometry = app.desktop()->screenGeometry();
  50. int screenWidth = screenGeometry.width();
  51. int screenHeight = screenGeometry.height();
  52. QRect geometry = QRect((screenWidth - width)/2, (screenHeight - height)/2, width, height);
  53. canvas.setGeometry(geometry);
  54. canvas.setWindowTitle("EvidenceHunt Game - " + app.applicationVersion());
  55. canvas.setFixedSize(width,height);
  56. canvas.showExpanded();
  57. #if defined(Q_EVHUNT_WINDOWS)
  58. qDebug() << "Windows Desktop";
  59. #else
  60. qDebug() << "Linux Desktop";
  61. #endif
  62. #endif
  63. QObject *rootObject = dynamic_cast<QObject*>(canvas.rootObject());
  64. QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit()));
  65. QObject::connect(game, SIGNAL(openWelcomeDialog()), rootObject, SLOT(openWelcomeDialog()));
  66. QObject::connect(game, SIGNAL(scoreboardLoaded()), rootObject, SLOT(scoreBoardLoaded()));
  67. QObject::connect(game, SIGNAL(openBoardErrorDialog()), rootObject, SLOT(openBoardErrorDialog()));
  68. return app.exec();
  69. }