started revamping qml files and added player.nim which holds the player QtObject
This commit is contained in:
parent
355cc551b9
commit
b79a99ff73
3 changed files with 217 additions and 111 deletions
116
main.qml
116
main.qml
|
@ -2,6 +2,8 @@ import QtQuick 6
|
||||||
import QtQuick.Controls 6
|
import QtQuick.Controls 6
|
||||||
import QtQuick.Layouts 6
|
import QtQuick.Layouts 6
|
||||||
|
|
||||||
|
import "players"
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
width: 600
|
width: 600
|
||||||
height: 501
|
height: 501
|
||||||
|
@ -26,114 +28,8 @@ ApplicationWindow {
|
||||||
SplitView.preferredHeight: parent.height - 190 // setting the bar to be 60 ambiguous units lower than middle
|
SplitView.preferredHeight: parent.height - 190 // setting the bar to be 60 ambiguous units lower than middle
|
||||||
Layout.maximumHeight: 500
|
Layout.maximumHeight: 500
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
//textfeild time
|
Player0{}
|
||||||
GridLayout{
|
|
||||||
id: grid1
|
|
||||||
anchors.fill: parent
|
|
||||||
columns: 6
|
|
||||||
rows: 5
|
|
||||||
flow: GridLayout.TopToBottom
|
|
||||||
Layout.fillWidth: false
|
|
||||||
Layout.preferredWidth: 200
|
|
||||||
|
|
||||||
//start of name boxes
|
|
||||||
Repeater{
|
|
||||||
id: names
|
|
||||||
model: ["name", "name", "name", "name", "name"]
|
|
||||||
|
|
||||||
TextField { // look at my field of TextFields
|
|
||||||
required property string modelData
|
|
||||||
id: na1
|
|
||||||
placeholderText: modelData
|
|
||||||
background: Rectangle {
|
|
||||||
implicitWidth: 175
|
|
||||||
implicitHeight: 35
|
|
||||||
color: na1.enabled ? "transparent" : "#353637"
|
|
||||||
border.color: na1.enabled ? "#87CEEB" : "transparent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//start of bet boxes
|
|
||||||
Repeater{
|
|
||||||
id: bets
|
|
||||||
model: 5
|
|
||||||
TextField{
|
|
||||||
id: bt1
|
|
||||||
placeholderText: qsTr("Enter bet")
|
|
||||||
background: Rectangle {
|
|
||||||
implicitWidth: 175
|
|
||||||
implicitHeight: 35
|
|
||||||
color: bt1.enabled ? "transparent" : "#353637"
|
|
||||||
border.color: bt1.enabled ? "#87CEEB" : "transparent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//start of Push buttons
|
|
||||||
Repeater{
|
|
||||||
model: 5
|
|
||||||
RoundButton{
|
|
||||||
id: p1
|
|
||||||
text: "P"
|
|
||||||
background: Rectangle{
|
|
||||||
implicitHeight: 35
|
|
||||||
implicitWidth: 35
|
|
||||||
color: p1.down ? "#eddc1c" : "transparent"
|
|
||||||
border.color: "#eddc1c"
|
|
||||||
border.width: 1
|
|
||||||
radius: 180
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//start od Double buttons
|
|
||||||
Repeater{
|
|
||||||
model: 5
|
|
||||||
RoundButton{
|
|
||||||
id: d1
|
|
||||||
text: "D"
|
|
||||||
background: Rectangle{
|
|
||||||
implicitHeight: 35
|
|
||||||
implicitWidth: 35
|
|
||||||
color: d1.down ? "#7207ed" : "transparent"
|
|
||||||
border.color: "#7207ed"
|
|
||||||
border.width: 1
|
|
||||||
radius: 180
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//start of Win buttons
|
|
||||||
Repeater{
|
|
||||||
model: 5
|
|
||||||
RoundButton{
|
|
||||||
id: w1
|
|
||||||
text: "W"
|
|
||||||
background: Rectangle{
|
|
||||||
implicitHeight: 35
|
|
||||||
implicitWidth: 35
|
|
||||||
color: w1.down ? "#1dbf32" : "transparent"
|
|
||||||
border.color: "#1dbf32"
|
|
||||||
border.width: 1
|
|
||||||
radius: 180
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//start of Lose buttons
|
|
||||||
Repeater{
|
|
||||||
model: 5
|
|
||||||
RoundButton{
|
|
||||||
id: l1
|
|
||||||
text: "L"
|
|
||||||
background: Rectangle{
|
|
||||||
implicitHeight: 35
|
|
||||||
implicitWidth: 35
|
|
||||||
color: l1.down ? "#e6050c" : "transparent"
|
|
||||||
border.color: "#e6050c"
|
|
||||||
border.width: 1
|
|
||||||
radius: 180
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
@ -141,9 +37,7 @@ ApplicationWindow {
|
||||||
//SplitView.preferredHeight: parent.height - 300 // not needed as it conflicts with rect1 line placement
|
//SplitView.preferredHeight: parent.height - 300 // not needed as it conflicts with rect1 line placement
|
||||||
Layout.maximumHeight: 500
|
Layout.maximumHeight: 500
|
||||||
color: "#2b2b29" //making payout window grey for better visibility
|
color: "#2b2b29" //making payout window grey for better visibility
|
||||||
ListView{
|
|
||||||
model: names
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
109
player.nim
Normal file
109
player.nim
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
import NimQml
|
||||||
|
|
||||||
|
QtObject:
|
||||||
|
type player* = ref object of QObject
|
||||||
|
p_name: string
|
||||||
|
p_bet: int
|
||||||
|
p_push: bool
|
||||||
|
p_double: bool
|
||||||
|
p_payout: int
|
||||||
|
|
||||||
|
proc delete*(self: player)
|
||||||
|
proc setup(self: player)
|
||||||
|
proc newplayer*(): player =
|
||||||
|
new(result, delete)
|
||||||
|
result.p_name = "no player name"
|
||||||
|
result.p_bet = 250000
|
||||||
|
result.p_push = false
|
||||||
|
result.p_double = false
|
||||||
|
result.p_payout = 250000
|
||||||
|
result.setup
|
||||||
|
|
||||||
|
proc delete*(self: player) =
|
||||||
|
self.QObject.delete
|
||||||
|
|
||||||
|
proc setup(self: player) =
|
||||||
|
self.QObject.setup
|
||||||
|
|
||||||
|
proc getName*(self: player): string {.slot.} =
|
||||||
|
result = self.p_name
|
||||||
|
|
||||||
|
proc getBet*(self: player): int {.slot.} =
|
||||||
|
result = self.p_bet
|
||||||
|
|
||||||
|
proc getPush*(self: player): bool {.slot.} =
|
||||||
|
result = self.p_push
|
||||||
|
|
||||||
|
proc getDouble*(self: player): bool {.slot.} =
|
||||||
|
result = self.p_double
|
||||||
|
|
||||||
|
proc getPayout*(self: player): int {.slot.} =
|
||||||
|
result = self.p_payout
|
||||||
|
|
||||||
|
proc nameChanged*(self: player, name: string) {.signal.}
|
||||||
|
proc betChanged*(self: player, bet: int) {.signal.}
|
||||||
|
proc pushChanged*(self: player, push: bool) {.signal.}
|
||||||
|
proc doubleChanged*(self: player, double: bool) {.signal.}
|
||||||
|
proc payoutChanged*(self: player, payout: int) {.signal.}
|
||||||
|
|
||||||
|
proc setName*(self: player, name: string) {.slot.} =
|
||||||
|
if self.p_name == name:
|
||||||
|
return
|
||||||
|
self.p_name = name
|
||||||
|
self.nameChanged(name)
|
||||||
|
|
||||||
|
proc setBet*(self: player, bet: int) {.slot.} =
|
||||||
|
if self.p_bet == bet:
|
||||||
|
return
|
||||||
|
self.p_bet = bet
|
||||||
|
self.betChanged(bet)
|
||||||
|
|
||||||
|
proc setPush*(self: player, push: bool) {.slot.} =
|
||||||
|
if self.p_push == push:
|
||||||
|
return
|
||||||
|
self.p_push = push
|
||||||
|
self.pushChanged(push)
|
||||||
|
|
||||||
|
proc setDouble*(self: player, double: bool) {.slot.} =
|
||||||
|
if self.p_double == double:
|
||||||
|
return
|
||||||
|
self.p_double = double
|
||||||
|
self.doubleChanged(double)
|
||||||
|
|
||||||
|
proc setPayout*(self: player, payout: int) {.slot.} =
|
||||||
|
if self.p_payout == payout:
|
||||||
|
return
|
||||||
|
self.p_payout = payout
|
||||||
|
self.payoutChanged(payout)
|
||||||
|
|
||||||
|
proc calcPayout*(self: player, bet: int, push: bool, double: bool): int {.slot.} =
|
||||||
|
var payout = bet * 2
|
||||||
|
self.p_bet = payout
|
||||||
|
self.betChanged(payout)
|
||||||
|
|
||||||
|
QtProperty[string] name:
|
||||||
|
read = getName
|
||||||
|
write = setName
|
||||||
|
notify = nameChanged
|
||||||
|
|
||||||
|
QtProperty[int] bet:
|
||||||
|
read = getBet
|
||||||
|
write = setBet
|
||||||
|
notify = betChanged
|
||||||
|
|
||||||
|
QtProperty[bool] push:
|
||||||
|
read = getPush
|
||||||
|
write = setPush
|
||||||
|
notify = pushChanged
|
||||||
|
|
||||||
|
QtProperty[bool] double:
|
||||||
|
read = getDouble
|
||||||
|
write = setDouble
|
||||||
|
notify = doubleChanged
|
||||||
|
|
||||||
|
QtProperty[int] payout:
|
||||||
|
read = getPayout
|
||||||
|
write = setPayout
|
||||||
|
notify = payoutChanged
|
||||||
|
|
||||||
|
|
103
players/Player0.qml
Normal file
103
players/Player0.qml
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
import QtQuick 6
|
||||||
|
import QtQuick.Controls 6
|
||||||
|
import QtQuick.Layouts 6
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
anchors.fill: parent
|
||||||
|
spacing: 2
|
||||||
|
TextField { // look at my field of TextFields
|
||||||
|
id: na1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: parent.width / 2.5
|
||||||
|
placeholderText: "enter playername"
|
||||||
|
background: Rectangle {
|
||||||
|
implicitWidth: 175
|
||||||
|
implicitHeight: 35
|
||||||
|
color: na1.enabled ? "transparent" : "#353637"
|
||||||
|
border.color: na1.enabled ? "#87CEEB" : "transparent"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: bt1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.maximumWidth: parent.width / 2.5
|
||||||
|
placeholderText: qsTr("Enter bet")
|
||||||
|
background: Rectangle {
|
||||||
|
implicitWidth: 175
|
||||||
|
implicitHeight: 35
|
||||||
|
color: bt1.enabled ? "transparent" : "#353637"
|
||||||
|
border.color: bt1.enabled ? "#87CEEB" : "transparent"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RoundButton {
|
||||||
|
id: p1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.maximumWidth: parent.width / 8
|
||||||
|
Layout.maximumHeight: parent.height / 8
|
||||||
|
text: "P"
|
||||||
|
background: Rectangle {
|
||||||
|
implicitHeight: 35
|
||||||
|
implicitWidth: 35
|
||||||
|
color: p1.down ? "#eddc1c" : "transparent"
|
||||||
|
border.color: "#eddc1c"
|
||||||
|
border.width: 1
|
||||||
|
radius: 180
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RoundButton {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.maximumWidth: parent.width / 8
|
||||||
|
Layout.maximumHeight: parent.height / 8
|
||||||
|
id: d1
|
||||||
|
text: "D"
|
||||||
|
background: Rectangle {
|
||||||
|
implicitHeight: 35
|
||||||
|
implicitWidth: 35
|
||||||
|
color: d1.down ? "#7207ed" : "transparent"
|
||||||
|
border.color: "#7207ed"
|
||||||
|
border.width: 1
|
||||||
|
radius: 180
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RoundButton {
|
||||||
|
id: w1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.maximumWidth: parent.width / 8
|
||||||
|
Layout.maximumHeight: parent.height / 8
|
||||||
|
text: "W"
|
||||||
|
background: Rectangle{
|
||||||
|
implicitHeight: 35
|
||||||
|
implicitWidth: 35
|
||||||
|
color: w1.down ? "#1dbf32" : "transparent"
|
||||||
|
border.color: "#1dbf32"
|
||||||
|
border.width: 1
|
||||||
|
radius: 180
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RoundButton {
|
||||||
|
id: l1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.maximumWidth: parent.width / 8
|
||||||
|
Layout.maximumHeight: parent.height / 8
|
||||||
|
text: "L"
|
||||||
|
background: Rectangle{
|
||||||
|
implicitHeight: 35
|
||||||
|
implicitWidth: 35
|
||||||
|
color: l1.down ? "#e6050c" : "transparent"
|
||||||
|
border.color: "#e6050c"
|
||||||
|
border.width: 1
|
||||||
|
radius: 180
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue