Add close icon for Symbian; add all-orientation support for Harmattan.
[jaffas-playground:bedside.git] / main.cpp
1 #include <QtGui/QApplication>
2 #include <QtDeclarative>
3 #include "visibilityawareqmlapplicationviewer.h"
4 #include "activemonitor.h"
5 #include "backlightcontrol.h"
6 #include "applicationdata.h"
7 #include <qplatformdefs.h>
8
9 int main(int argc, char *argv[])
10 {
11     QApplication app(argc, argv);
12     ApplicationData data;
13     data.initialize();
14     VisibilityAwareQmlApplicationViewer viewer;
15     viewer.engine()->addImportPath("/opt/qtm12/imports");
16     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
17
18     ActiveMonitor *monitor = new ActiveMonitor(&viewer);
19     QObject::connect(&viewer, SIGNAL(activeChanged(bool)),
20                      monitor, SLOT(activeChanged(bool)));
21
22     BacklightControl *backlight = new BacklightControl(&viewer);
23     QObject::connect(&app, SIGNAL(aboutToQuit()), backlight, SLOT(reset()));
24
25     viewer.rootContext()->setContextProperty("activeMonitor", monitor);
26     viewer.rootContext()->setContextProperty("backlight", backlight);
27     viewer.rootContext()->setContextProperty("viewer", &viewer);
28     viewer.rootContext()->setContextProperty("applicationData", &data);
29     viewer.rootContext()->setContextProperty("ampm", data.twelveHourClock());
30
31     #ifdef MEEGO_EDITION_HARMATTAN
32         viewer.rootContext()->setContextProperty("needCloseIcon", "false"); // `false' bool comes through as `null'
33         viewer.setMainQmlFile("qml/Bedside/qtc-root.qml");
34     #else
35         viewer.rootContext()->setContextProperty("needCloseIcon", "true");
36         viewer.setMainQmlFile("qml/Bedside/Main.qml");
37     #endif
38     viewer.showFullScreen();
39
40     return app.exec();
41 }