roulette-payout/BetInputDialog.qml
2024-06-08 12:25:20 +01:00

64 lines
1.4 KiB
QML

import QtQuick
import QtQuick.Controls
import roulette
Dialog {
required property int betType /* It wouldn't accept the BetType type defined in PlayerAreaModel so I just used the int since that's what it is*/
required property int n
required property int squareX
required property int squareY
id: dialog
modal: true
height: 35
width: 80
TextField {
id: input
focus: true
/* No negative numners or leading 0s, and cap at 99 million */
validator: RegularExpressionValidator { regularExpression: /[1-9][0-9]{0,7}/ }
anchors {
left: parent.left
right: gil.left
rightMargin: 5
top: parent.top
bottom: parent.bottom
}
onActiveFocusChanged: {
selectAll()
focus = true
}
onAccepted: {
dialog.accept()
}
}
Text {
id: gil
text: "g"
anchors {
/* Can not 'left: indicator.right'; Only anchor the same side once, which was done in 'input' */
right: parent.right
verticalCenter: input.verticalCenter
}
}
onActiveFocusChanged: {
dialog.x = squareX
dialog.y = squareY
}
onAccepted: {
PlayerAreaModel.bet(betType, n, input.text)
rouletteTable.numberOfBets += 1
}
onRejected: {
PlayerAreaModel.cancelBet(betType, n)
}
}