Запускается E:\testQtProjects\cupBoard\debug\cupBoard.exe...
Qml debugging is enabled. Only use this in a safe environment!
LEAK: 220 Structure // при закрытии программы
E:\testQtProjects\cupBoard\debug\cupBoard.exe завершился с кодом 0
Весь текст программы:
import QtQuick 1.0
/*!
The base canvas for all QML drawing.
*/
Rectangle {
id: dial
property int value: 0
width: 200
height: 400
//color: "transparent"
Keys.onPressed: {
if (event.key >= Qt.Key_0 && event.key <= Qt.Key_9) {
dial.value = event.key - Qt.Key_0
event.accepted = true;
}
}
Image {
id: background
smooth: true
source: dial.focus ? "./newImages/ArrowBackground_focused.png"
: mouseArea.containsMouse ? "./newImages/ArrowBackground_hovered.png"
: "./newImages/ArrowBackground.png"
width: parent.width
height: parent.height / 2
Image {
id: arrow
smooth: true
source: "./newImages/Arrow.png"
width: arrow.sourceSize.width / background.sourceSize.width *background.width
height: arrow.sourceSize.height / background.sourceSize.height * background.height
x: 60 / background.sourceSize.width * background.width
y: 63 / background.sourceSize.height * background.height
transform: Rotation {
origin.x: arrow.sourceSize.width / 2
origin.y: arrow.sourceSize.height / 2
angle: (dial.value < 10 ? dial.value : 0) * 36.0 + 105; //105 - поправка, так как на фото стрелочка показывает на 7
Behavior on angle {
SpringAnimation {damping: 0.5; spring : 5; modulus: 360 }
}
}
/*transform: Rotation {
origin.x: arrow.sourceSize.width / 2
origin.y: arrow.sourceSize.height / 2
angle: (dial.value < 10 ? dial.value : 0) * 36.0 + 105; //105 - поправка, так как на фото стрелочка показывает на 7
Behavior on angle {
SpringAnimation {damping: 0.5; spring : 5; modulus: 360 }
}
}*/
}
MouseArea {
function calculateValue() {
dial.focus = true
if(mouseX == background.width / 2)
return
var angle = Math.atan((mouseY - background.height / 2)
/ (mouseX - background.width / 2));
//text.text = string(mouseY)
angle *= (180 / 3.1415926);
angle += 90 + (mouseX > background.width / 2) * 180
var sector = (360.0 / 10);
if(angle > 342)
angle = 0
dial.value = Math.floor((angle + 18) / sector)
}
id: mouseArea
hoverEnabled: true
anchors.fill: parent
onPositionChanged:
if(mouseArea.pressedButtons == Qt.LeftButton)
calculateValue();
onPressed: calculateValue()
}
}
}