Changed PlayerAreaModel to a named QML_SINGLETON.
This commit is contained in:
parent
223a340971
commit
f51623deaf
7 changed files with 40 additions and 30 deletions
|
@ -7,8 +7,6 @@
|
||||||
class MainWindow : public QQmlApplicationEngine
|
class MainWindow : public QQmlApplicationEngine
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
|
||||||
QML_SINGLETON /* ??? */
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWindow *parent = nullptr);
|
explicit MainWindow(QWindow *parent = nullptr);
|
||||||
|
|
|
@ -79,3 +79,8 @@ void PlayerAreaModel::setPlayerName(QString s, int n)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerAreaModel::bet(BetType b, int n)
|
||||||
|
{
|
||||||
|
printf("Received %d-%d\n", b, n);
|
||||||
|
}
|
||||||
|
|
|
@ -3,12 +3,15 @@
|
||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
#include <QtGui/qwindow.h>
|
#include <QtGui/qwindow.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
#include <qqmlintegration.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
|
|
||||||
class PlayerAreaModel : public QObject
|
class PlayerAreaModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_NAMED_ELEMENT(PlayerAreaModel)
|
||||||
|
QML_SINGLETON
|
||||||
|
|
||||||
Q_PROPERTY(QString playerName1 READ playerName1 NOTIFY playerName1Changed)
|
Q_PROPERTY(QString playerName1 READ playerName1 NOTIFY playerName1Changed)
|
||||||
Q_PROPERTY(QString playerName2 READ playerName2 NOTIFY playerName2Changed)
|
Q_PROPERTY(QString playerName2 READ playerName2 NOTIFY playerName2Changed)
|
||||||
|
@ -27,6 +30,20 @@ public:
|
||||||
QString playerName5();
|
QString playerName5();
|
||||||
QString playerName6();
|
QString playerName6();
|
||||||
QString playerName7();
|
QString playerName7();
|
||||||
|
enum BetType {
|
||||||
|
RED,
|
||||||
|
BLACK,
|
||||||
|
ODD,
|
||||||
|
EVEN,
|
||||||
|
LOW,
|
||||||
|
HIGH,
|
||||||
|
DOZEN,
|
||||||
|
STREET,
|
||||||
|
SINGLE,
|
||||||
|
SPLIT
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_ENUM(BetType)
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void playerName1Changed();
|
void playerName1Changed();
|
||||||
|
@ -39,6 +56,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPlayerName(QString s, int n);
|
void setPlayerName(QString s, int n);
|
||||||
|
void bet(BetType b, int n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString playerName1Text;
|
QString playerName1Text;
|
||||||
|
@ -49,4 +67,3 @@ private:
|
||||||
QString playerName6Text;
|
QString playerName6Text;
|
||||||
QString playerName7Text;
|
QString playerName7Text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,43 +5,40 @@ import QtQuick.Layouts
|
||||||
import roulette
|
import roulette
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
PlayerAreaModel {
|
|
||||||
id: playerAreaModel
|
|
||||||
}
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Text {
|
Text {
|
||||||
text: "Croupier"
|
text: "Croupier"
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName1
|
text: PlayerAreaModel.playerName1
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 1)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 1)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName2
|
text: PlayerAreaModel.playerName2
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 2)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 2)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName3
|
text: PlayerAreaModel.playerName3
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 3)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 3)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName4
|
text: PlayerAreaModel.playerName4
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 4)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 4)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName5
|
text: PlayerAreaModel.playerName5
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 5)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 5)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName6
|
text: PlayerAreaModel.playerName6
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 6)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 6)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName7
|
text: PlayerAreaModel.playerName7
|
||||||
onEditingFinished: playerAreaModel.setPlayerName(text, 7)
|
onEditingFinished: PlayerAreaModel.setPlayerName(text, 7)
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: playerAreaModel.playerName1
|
text: PlayerAreaModel.playerName1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,3 @@ StreetBetsModel::StreetBetsModel(QObject *parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreetBetsModel::betOnStreet(int n) {
|
|
||||||
printf("emit signal to mark bet on street %d\n", n);
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,4 @@ class StreetBetsModel : public QObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StreetBetsModel(QObject *parent = nullptr);
|
explicit StreetBetsModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void betOnStreet(int n);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,7 +61,7 @@ Item {
|
||||||
} else {
|
} else {
|
||||||
parent.border.width = 0
|
parent.border.width = 0
|
||||||
}
|
}
|
||||||
streetBetsModel.betOnStreet(index)
|
PlayerAreaModel.bet(PlayerAreaModel.STREET, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue