demos/declarative/calculator/calculator.qml
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
--- a/demos/declarative/calculator/calculator.qml	Tue Jul 06 15:10:48 2010 +0300
+++ b/demos/declarative/calculator/calculator.qml	Wed Aug 18 10:37:55 2010 +0300
@@ -58,10 +58,11 @@
     property string plusminus : "\u00b1"
 
     function doOp(operation) { CalcEngine.doOperation(operation) }
-
+    
     Item {
         id: main
-        state: (runtime.orientation == Orientation.Portrait) ? '' : 'rotated'
+        state: "orientation " + runtime.orientation
+
         width: parent.width; height: parent.height; anchors.centerIn: parent
 
         Column {
@@ -130,16 +131,28 @@
             }
         }
 
-        states: State {
-            name: 'rotated'
-            PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width }
-            PropertyChanges { target: rotateButton; operation: rotateRight }
-        }
+        states: [
+            State {
+                name: "orientation " + Orientation.Landscape
+                PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width }
+                PropertyChanges { target: rotateButton; operation: rotateRight }
+            },
+            State {
+                name: "orientation " + Orientation.PortraitInverted
+                PropertyChanges { target: main; rotation: -180; }
+                PropertyChanges { target: rotateButton; operation: rotateLeft }
+            },
+            State {
+                name: "orientation " + Orientation.LandscapeInverted
+                PropertyChanges { target: main; rotation: -270; width: window.height; height: window.width }
+                PropertyChanges { target: rotateButton; operation: rotateRight }
+            }
+        ]
 
         transitions: Transition {
             SequentialAnimation {
                 PropertyAction { target: rotateButton; property: "operation" }
-                NumberAnimation { properties: "rotation"; duration: 300; easing.type: Easing.InOutQuint }
+                RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint  }
                 NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
             }
         }