WWW update
[ubi] / main.cpp
1 #include <QtGui/QApplication>
2 #include <QDeclarativeContext>
3 #include <QtDeclarative>
4 #include <QTranslator>
5 #include <QtGui/QDirModel>
6 #include <QSettings>
7 #include "qmlapplicationviewer.h"
8 #include "utils.h"
9 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
10
11 Q_DECL_EXPORT int main(int argc, char *argv[])
12 {
13     QScopedPointer<QApplication> app(createApplication(argc, argv));
14
15     QmlApplicationViewer viewer;
16     QSettings settings("MK","Ubi");
17     Utils utils(&viewer,&settings);
18
19     QString locale = settings.value("locale").toString();
20     if(locale!="pl_PL" && locale!="en_US" && locale!="it_IT") {
21         locale = QLocale::system().name();
22         if(locale!="pl_PL" && locale!="it_IT") {
23             locale="en_US";
24         }
25         settings.setValue("locale",locale);
26     }
27     QTranslator translator;
28     QString dir = "translations";
29     //dir = ":/translations";
30 #if defined(MEEGO_EDITION_HARMATTAN)
31     dir = ":/translations";
32 #endif
33 #if defined(Q_WS_MAEMO_5)
34     //dir = "/opt/ubi/translations";
35     dir = ":/translations";
36 #endif
37     if (translator.load(QString("ubi.")+locale,dir)) {
38         app->installTranslator(&translator);
39     } else {
40         locale="en_US";
41         settings.setValue("locale",locale);
42     }
43
44     QDeclarativeContext *context = viewer.rootContext();
45     context->setContextProperty("Utils", &utils);
46
47 #if defined(MEEGO_EDITION_HARMATTAN)
48     //viewer.setMainQmlFile(QLatin1String("qml/ubi/meego_main.qml"));
49     viewer.setSource(QUrl("qrc:///qml/ubi/meego_main.qml"));
50     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
51 #endif
52
53 #if defined(Q_WS_MAEMO_5)
54     qputenv("N900_PORTRAIT_SENSORS", "1");
55     //viewer.setMainQmlFile(QLatin1String("qml/ubi/meego_main.qml"));
56     viewer.setSource(QUrl("qrc:///qml/ubi/meego_main.qml"));
57     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
58     viewer.setGeometry(QRect(0,0,800,480));
59 #endif
60
61 #if !defined(MEEGO_EDITION_HARMATTAN) && !defined(Q_WS_MAEMO_5)
62     //viewer.setMainQmlFile(QLatin1String("qml/ubi/main.qml"));
63     viewer.setSource(QUrl("qrc:///qml/ubi/main.qml"));
64     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
65 #endif
66
67     viewer.setWindowTitle(QString("Ubi"));
68     viewer.showExpanded();
69
70 /*
71 #if defined(Q_WS_MAEMO_5)
72     viewer.setGeometry(QRect(0,0,800,480));
73     viewer.showFullScreen();
74 #else
75     viewer.showExpanded();
76 #endif
77 */
78
79     return app->exec();
80 }