Street bets UI.

This commit is contained in:
greek 2024-06-01 01:14:46 +01:00
parent 2e9f2133d6
commit 223a340971
8 changed files with 148 additions and 4 deletions

View file

@ -10,12 +10,19 @@ find_package(Qt6 6.2 COMPONENTS Core Widgets QuickControls2 Gui REQUIRED)
qt_standard_project_setup() qt_standard_project_setup()
qt_add_executable(roulette-payout qt_add_resources(QRC res.qrc)
set(SOURCES
main.cpp main.cpp
MainWindow.cpp MainWindow.cpp
MainWindow.h MainWindow.h
PlayerAreaModel.cpp PlayerAreaModel.cpp
PlayerAreaModel.h PlayerAreaModel.h
StreetBetsModel.cpp
StreetBetsModel.h
${QRC})
qt_add_executable(roulette-payout
${SOURCES}
) )
qt_add_qml_module(roulette-payout qt_add_qml_module(roulette-payout
@ -25,6 +32,8 @@ qt_add_qml_module(roulette-payout
QML_FILES QML_FILES
Root.qml Root.qml
PlayerAreaView.qml PlayerAreaView.qml
Roulette.qml
StreetBetsView.qml
) )
target_link_libraries(roulette-payout PRIVATE target_link_libraries(roulette-payout PRIVATE

View file

@ -1,6 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts
import roulette import roulette
@ -11,11 +10,21 @@ Window {
visible: true visible: true
Pane { Pane {
id: rootWindow
anchors.fill: parent anchors.fill: parent
PlayerAreaView { PlayerAreaView {
id: playerAreaView id: playerAreaView
} }
Roulette {
id: roulette
height: parent.height / 1.7
width: parent.width / 1.7
anchors{
top: parent.top
right: parent.right
}
}
} }
} }

25
Roulette.qml Normal file
View file

@ -0,0 +1,25 @@
import QtQuick
import Qt5Compat.GraphicalEffects
import roulette
Item {
Image {
source: "qrc:/roulette.png"
signal streetBet(n: int)
//fillMode: Image.PreserveAspectFit
height: parent.height
width: parent.width
anchors {
top: parent.top
right: parent.right
}
StreetBetsView {
id: streetBets
}
}
}

10
StreetBetsModel.cpp Normal file
View file

@ -0,0 +1,10 @@
#include "StreetBetsModel.h"
StreetBetsModel::StreetBetsModel(QObject *parent)
{
}
void StreetBetsModel::betOnStreet(int n) {
printf("emit signal to mark bet on street %d\n", n);
}

17
StreetBetsModel.h Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include <QQuickView>
#include <qqmlintegration.h>
#include <qtmetamacros.h>
#include <qobject.h>
class StreetBetsModel : public QObject {
Q_OBJECT
QML_ELEMENT
public:
explicit StreetBetsModel(QObject *parent = nullptr);
public slots:
void betOnStreet(int n);
};

69
StreetBetsView.qml Normal file
View file

@ -0,0 +1,69 @@
import QtQuick
import roulette
Item {
StreetBetsModel {
id: streetBetsModel
}
Repeater {
model: 12
Rectangle {
visible: true
color: tapHandler1.pressed ? "#999999" : "#EEEEEE"
opacity: hoverHandler.hovered ? 0.4 : 0
height: 45
width: 35
anchors {
left: parent.left
leftMargin: 90 + (index * (width + 1.8))
top: parent.top
topMargin: 22
}
HoverHandler {
id: hoverHandler
}
TapHandler {
id: tapHandler1
}
}
}
Repeater {
model: 12
delegate: Rectangle {
visible: true
color: "transparent"
height: 44
width: 35
border.color: "blue"
border.width: 0
anchors {
left: parent.left
leftMargin: 90 + (index * (width + 1.8))
top: parent.top
topMargin: 22
}
TapHandler {
onTapped: ()=> {
if (parent.border.width == 0) {
parent.border.width = 2
} else {
parent.border.width = 0
}
streetBetsModel.betOnStreet(index)
}
}
}
}
}

5
res.qrc Normal file
View file

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>roulette.png</file>
</qresource>
</RCC>

BIN
roulette.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB