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