qtmobility/examples/declarative-sfw-dialer/declarative-sfw-dialer/content/DialButton.qml
changeset 11 06b8e2af4411
child 14 6fbed849b4f4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qtmobility/examples/declarative-sfw-dialer/declarative-sfw-dialer/content/DialButton.qml	Fri Jun 11 14:26:25 2010 +0300
@@ -0,0 +1,72 @@
+import Qt 4.6
+
+//Implementation of the dialButton control.
+Item {
+    id: dialButton
+    width: 50
+    height: 50
+    property alias buttonText: innerText.text;
+    property alias color: rectangleButton.color
+    property color hoverColor: "lightsteelblue"
+    property color pressColor: "slategray"
+    signal clicked
+
+    Rectangle {
+        id: rectangleButton
+        anchors.fill: parent
+        radius: 5
+        color: "steelblue"
+        border.width: 3
+        border.color: "black"
+
+        Text {
+            id: innerText
+            font.pointSize: 20
+            anchors.centerIn: parent
+        }
+    }
+   
+    states: [
+        State {
+            name: "Hovering"
+            PropertyChanges {
+                target: rectangleButton
+                color: hoverColor
+            }
+        },
+        State {
+            name: "Pressed"
+            PropertyChanges {
+                target: rectangleButton
+                color: pressColor
+            }
+        }
+    ]
+   
+   
+    transitions: [
+        Transition {
+            from: ""; to: "Hovering"
+            ColorAnimation { duration: 100 }
+        },
+        Transition {
+            from: "*"; to: "Pressed"
+            ColorAnimation { duration: 10 }
+        }
+    ]
+   
+    MouseArea {
+        hoverEnabled: true
+        anchors.fill: dialButton
+        onEntered: { dialButton.state='Hovering'}
+        onExited: { dialButton.state=''}
+        onClicked: { dialButton.clicked();}
+        onPressed: { dialButton.state="Pressed" }
+        onReleased: {
+            if (containsMouse)
+            dialButton.state="Hovering";
+            else
+            dialButton.state="";
+        }
+    }
+}