demos/declarative/calculator/calculator.qml
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    56     property string multiplication : "\u00d7"
    56     property string multiplication : "\u00d7"
    57     property string squareRoot : "\u221a"
    57     property string squareRoot : "\u221a"
    58     property string plusminus : "\u00b1"
    58     property string plusminus : "\u00b1"
    59 
    59 
    60     function doOp(operation) { CalcEngine.doOperation(operation) }
    60     function doOp(operation) { CalcEngine.doOperation(operation) }
    61 
    61     
    62     Item {
    62     Item {
    63         id: main
    63         id: main
    64         state: (runtime.orientation == Orientation.Portrait) ? '' : 'rotated'
    64         state: "orientation " + runtime.orientation
       
    65 
    65         width: parent.width; height: parent.height; anchors.centerIn: parent
    66         width: parent.width; height: parent.height; anchors.centerIn: parent
    66 
    67 
    67         Column {
    68         Column {
    68             id: box; spacing: 8
    69             id: box; spacing: 8
    69 
    70 
   128                     Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
   129                     Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
   129                 }
   130                 }
   130             }
   131             }
   131         }
   132         }
   132 
   133 
   133         states: State {
   134         states: [
   134             name: 'rotated'
   135             State {
   135             PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width }
   136                 name: "orientation " + Orientation.Landscape
   136             PropertyChanges { target: rotateButton; operation: rotateRight }
   137                 PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width }
   137         }
   138                 PropertyChanges { target: rotateButton; operation: rotateRight }
       
   139             },
       
   140             State {
       
   141                 name: "orientation " + Orientation.PortraitInverted
       
   142                 PropertyChanges { target: main; rotation: -180; }
       
   143                 PropertyChanges { target: rotateButton; operation: rotateLeft }
       
   144             },
       
   145             State {
       
   146                 name: "orientation " + Orientation.LandscapeInverted
       
   147                 PropertyChanges { target: main; rotation: -270; width: window.height; height: window.width }
       
   148                 PropertyChanges { target: rotateButton; operation: rotateRight }
       
   149             }
       
   150         ]
   138 
   151 
   139         transitions: Transition {
   152         transitions: Transition {
   140             SequentialAnimation {
   153             SequentialAnimation {
   141                 PropertyAction { target: rotateButton; property: "operation" }
   154                 PropertyAction { target: rotateButton; property: "operation" }
   142                 NumberAnimation { properties: "rotation"; duration: 300; easing.type: Easing.InOutQuint }
   155                 RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint  }
   143                 NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
   156                 NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
   144             }
   157             }
   145         }
   158         }
   146     }
   159     }
   147 }
   160 }