main.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <QtGui/QApplication>
  2. #include <QDesktopServices>
  3. #include <QDeclarativeContext>
  4. #include <QDesktopServices>
  5. #include <QDesktopWidget>
  6. #include <QTranslator>
  7. #include <QLocale>
  8. #include <QDebug>
  9. #include "qmlapplicationviewer.h"
  10. Q_DECL_EXPORT int main(int argc, char *argv[])
  11. {
  12. QScopedPointer<QApplication> app(createApplication(argc, argv));
  13. QmlApplicationViewer viewer;
  14. QTranslator translator;
  15. if (translator.load(QLatin1String("i18n/thekarmaway_" )+QLocale::system().name(), ":/"))
  16. app->installTranslator(&translator);
  17. else
  18. qDebug()<< "can't find translation "+QLatin1String("i18n/thekarmaway_" )+QLocale::system().name();
  19. QDeclarativeContext *context = viewer.rootContext();
  20. //This is a trick to detect if the app is running in the simulator
  21. if (QDesktopServices::storageLocation(QDesktopServices::PicturesLocation).startsWith("/home/"))
  22. context->setContextProperty("isSimulator", false);
  23. else
  24. context->setContextProperty("isSimulator", true);
  25. context->setContextProperty("screen", QApplication::desktop()->screenGeometry());
  26. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  27. viewer.setMainQmlFile(QLatin1String("qml/TheKarmaWay/main.qml"));
  28. viewer.showExpanded();
  29. return app->exec();
  30. }