1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /*
- * Copyright (c) 2011 Nokia Corporation.
- */
- import Qt 4.7
- Text {
- id: menuItem
- text: name
- color: "white"
- opacity: 1
- font.family: "Calibri"
- font.pixelSize: menu.width / 8
- x: (parent.width - width )/ 2
- property bool selectedItem: false
- property int type
- signal itemSelected()
- transform: Rotation { id:rotationId; origin.x:width/2; origin.y:height/2; axis { x: 1; y: 0; z: 0 } angle: 0 }
- SequentialAnimation {
- id: toRotateRightAndCenterAnim
- PropertyAnimation { target: rotationId; easing.type: Easing.Linear;
- properties: "angle"; from: 0; to: 180; duration: 300 }
- PropertyAction { target: menuItem; property: "color"; value:"red"}
- PropertyAnimation { target: rotationId; easing.type: Easing.Linear;
- properties: "angle"; from: 180; to: 360; duration: 300 }
- PropertyAction { target: menuItem; property: "color"; value:"white"}
- }
- function selectItem(doSelect) {
- if (!toRotateRightAndCenterAnim.running) {
- GameEngine.playInternalSound(0)
- toRotateRightAndCenterAnim.restart()
- if (doSelect) {
- GameEngine.playInternalSound(1)
- selectionTimer.restart()
- }
- }
- }
- Timer {
- id: selectionTimer
- interval: 1000; running: false; repeat: false
- onTriggered: menuItem.itemSelected()
- }
- MouseArea {
- id: mouseArea;
- anchors.fill: parent
- onClicked: {
- selectItem(true)
- }
- }
- Keys.onSpacePressed: { selectItem(true) }
- Keys.onSelectPressed: { selectItem(true) }
- Keys.onEnterPressed: { selectItem(true) }
- Keys.onReleased: {
- if (event.key == Qt.Key_Down || event.key == Qt.Key_Up) {
- selectItem(false)
- }
- event.accepted = false
- }
- }
|