Add close icon for Symbian; add all-orientation support for Harmattan.
[jaffas-playground:bedside.git] / qml / Bedside / qtc-root.qml
1 import QtQuick 1.0
2 import com.nokia.meego 1.0
3 import QtMobility.sensors 1.2
4
5 PageStackWindow {
6     id: window
7     showStatusBar: false
8     showToolBar: false
9
10     initialPage: Page {
11         id: page
12         Rectangle {
13             color: "#555555"
14             anchors.fill: parent
15
16             Main {
17                 id: root
18                 anchors.fill: parent
19
20                 states: State  {
21                     name: "FLIPPED"
22                     PropertyChanges { target: root; rotation: 180}
23                 }
24
25                 transitions: Transition {
26                     NumberAnimation { properties: "rotation"; duration: 200; easing.type: Easing.InQuad }
27                 }
28             }
29         }
30     }
31
32     /**
33      * Allow "upside down" display.
34      */
35     OrientationSensor {
36         active: activeMonitor.active
37
38         onReadingChanged: {
39             if (reading.orientation == OrientationReading.LeftUp) {
40                 page.orientationLock = PageOrientation.LockLandscape
41                 root.state = 'FLIPPED'
42             } else if (reading.orientation == OrientationReading.TopDown) {
43                 page.orientationLock = PageOrientation.LockPortrait
44                 root.state = 'FLIPPED'
45             } else {
46                 page.orientationLock = PageOrientation.Automatic
47                 root.state = ''
48             }
49
50             console.log(reading.orientation + " at " + root.rotation)
51         }
52     }
53
54     Component.onCompleted: {
55         if (platformWindow)
56             activeMonitor.external = true
57         console.log("Set activeMonitor external modification = " + activeMonitor.external)
58     }
59
60     Connections {
61         target: platformWindow
62         onVisibleChanged: updateVisible()
63         onActiveChanged: updateVisible()
64     }
65
66     function updateVisible() {
67         console.log("PW Visible ["+ platformWindow.visible +"], active [" + platformWindow.active + "]")
68
69         activeMonitor.visible = platformWindow.visible
70         activeMonitor.active  = platformWindow.active
71     }
72 }