Seems we don't need to unset portraitBackground and landscapeBackground to show our...
[harmattan/cameraplus] / qml / main.qml
1 // -*- qml -*-
2 import QtQuick 1.1
3 import com.nokia.meego 1.1
4 import QtCamera 1.0
5 import CameraPlus 1.0
6
7 PageStackWindow {
8         id: root
9
10         property alias dimmer: camDimmer
11
12         showStatusBar: false
13
14         Component.onCompleted: {
15                 theme.inverted = true;
16                 if (settings.mode == 0) {
17                         openFile("ImagePage.qml");
18                 }
19                 else {
20                         openFile("VideoPage.qml");
21                 }
22         }
23
24         Settings {
25                 id: settings
26         }
27
28         // Stolen from https://qt.gitorious.org/qt-components/qt-components/blobs/master/examples/meego/QmlComponentGallery/qml/ListPage.qml
29         function replacePage(file) {
30                 var component = Qt.createComponent(file)
31
32                 if (component.status == Component.Ready) {
33                         pageStack.replace(component, {cam: cam}, true);
34                 }
35                 else {
36                         console.log("Error loading component:", component.errorString());
37                 }
38         }
39
40         function openFile(file) {
41                 var component = Qt.createComponent(file)
42
43                 if (component.status == Component.Ready) {
44                         pageStack.push(component, {cam: cam});
45                 }
46                 else {
47                         console.log("Error loading component:", component.errorString());
48                 }
49         }
50
51         platformStyle: PageStackWindowStyle {
52                 // TODO: Hack
53                 background: " "
54         }
55
56         Camera {
57                 onDeviceIdChanged: cam.start();
58
59                 id: cam
60                 anchors.fill: parent
61
62                 // TODO: hardcoding
63                 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
64
65                 // TODO: Hack
66                 z: -1
67
68                 Rectangle {
69                         id: camDimmer
70                         z: 1
71                         anchors.fill: parent
72                         opacity: 0
73                         color: "black"
74                 }
75         }
76
77         ModeController {
78                 id: cameraMode
79                 cam: cam
80                 dimmer: root.dimmer
81         }
82
83         Connections {
84                 target: cam
85                 onModeChanged: {
86                         if (cam.mode == Camera.VideoMode) {
87                                 replacePage("VideoPage.qml");
88                         }
89                         else {
90                                 replacePage("ImagePage.qml");
91                         }
92                 }
93         }
94 }