main.cpp 1.2 KB

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