import QtQuick 2.5
import fbx.application 1.0
import QtGraphicalEffects 1.0

Application {
property int rand: Math.random()* 10
property bool win: false

LinearGradient {
anchors.fill: parent
start: Qt.point(0, 0)
end: Qt.point(350, parent.height)
gradient: Gradient {
GradientStop { position: 0.0; color: "lightblue" }
GradientStop { position: 0.5; color: "steelblue" }
GradientStop { position: 1.0; color: "#202020" }
}
}

Text {
focus: true
id: txtRand
anchors.centerIn: parent
text: "Trouver quelle est la valeur du nombre aléatoire."
horizontalAlignment: Text.AlignHCenter
color: "#88ffffff"
font.pixelSize: 40

Keys.onPressed: {
if((!win) && (event.modifiers & Qt.KeypadModifier) && (event.key != 16777238) && (event.key != 16777239))
{
if(rand == event.text)
{
txtRand.text = "Bien Joué !\nVous pouvez maintenant réessayer en appuyant sur la touche OK."
win = true
}
else if(rand < event.text)
txtRand.text = "C'est moins"
else if(rand > event.text)
txtRand.text = "C'est plus"
}
}

Keys.onReturnPressed: {
if(win)
{
win = false
rand = Math.random()* 10
txtRand.text = "Trouver quelle est la valeur du nombre aléatoire."
}
}
}
}