main.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include <QTranslator>
  2. #include <QLocale>
  3. #include <QtGui/QApplication>
  4. #include "qmlapplicationviewer.h"
  5. #include <QtCore>
  6. #include <QtDeclarative>
  7. int main(int argc, char *argv[])
  8. {
  9. QApplication app(argc, argv);
  10. // Detect system locale and loads the Traditional Chinese / Simplified Chinese / English UIs accordingly
  11. QTranslator translator;
  12. QString locale = getenv("LANG");
  13. if (locale == "zh_HK" || locale == "zh_TW" || locale == "zh_MO") {
  14. // Loading localized translation files from Resources
  15. translator.load("zh_HK.qm", ":/");
  16. app.installTranslator(&translator);
  17. }
  18. else if (locale == "zh_CN" || locale == "zh_SG") {
  19. // Loading localized translation files from Resources
  20. translator.load("zh_CN.qm", ":/");
  21. app.installTranslator(&translator);
  22. }
  23. QmlApplicationViewer viewer;
  24. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  25. viewer.setMainQmlFile(QLatin1String("qml/TimeCalc/main.qml"));
  26. // viewer.showExpanded();
  27. viewer.showFullScreen();
  28. return app.exec();
  29. }