roulette-payout/BetInputDialog.qml

73 lines
1.7 KiB
QML
Raw Normal View History

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
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: {
/*
* Qt has no good way of making bottom to top grid layouts, so I had to use
* a workaround where the indexes do not work as expected.
*
* A solution for the indexes is to rotate the layout 180º, but that will mess up
* the x and y coordinates which is even more annoying to fix.
*/
//if (betType == 9 && n < 35) {
// n = 35 - n
//}
PlayerAreaModel.bet(betType, n, input.text)
rouletteTable.numberOfBets += 1
}
onRejected: {
PlayerAreaModel.cancelBet(betType, n)
}
}