Changed how player names are changed.
This commit is contained in:
parent
8307e4eec4
commit
8bb03932d2
5 changed files with 48 additions and 69 deletions
|
@ -11,5 +11,4 @@ class MainWindow : public QQuickView
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWindow *parent = nullptr);
|
explicit MainWindow(QWindow *parent = nullptr);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,44 +46,36 @@ QString PlayerAreaModel::playerName7()
|
||||||
return playerName7Text;
|
return playerName7Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerAreaModel::setPlayerName1(QString s)
|
void PlayerAreaModel::setPlayerName(QString s, int n)
|
||||||
{
|
{
|
||||||
playerName1Text = s;
|
switch(n) {
|
||||||
emit playerName1Changed();
|
case 1:
|
||||||
}
|
playerName1Text = s;
|
||||||
|
playerName1Changed();
|
||||||
void PlayerAreaModel::setPlayerName2(QString s)
|
break;
|
||||||
{
|
case 2:
|
||||||
playerName2Text = s;
|
playerName2Text = s;
|
||||||
emit playerName2Changed();
|
playerName2Changed();
|
||||||
}
|
break;
|
||||||
|
case 3:
|
||||||
void PlayerAreaModel::setPlayerName3(QString s)
|
playerName3Text = s;
|
||||||
{
|
playerName3Changed();
|
||||||
playerName3Text = s;
|
break;
|
||||||
emit playerName3Changed();
|
case 4:
|
||||||
}
|
playerName4Text = s;
|
||||||
|
playerName4Changed();
|
||||||
void PlayerAreaModel::setPlayerName4(QString s)
|
break;
|
||||||
{
|
case 5:
|
||||||
playerName4Text = s;
|
playerName5Text = s;
|
||||||
emit playerName4Changed();
|
playerName5Changed();
|
||||||
}
|
break;
|
||||||
|
case 6:
|
||||||
void PlayerAreaModel::setPlayerName5(QString s)
|
playerName6Text = s;
|
||||||
{
|
playerName6Changed();
|
||||||
playerName5Text = s;
|
break;
|
||||||
emit playerName5Changed();
|
case 7:
|
||||||
}
|
playerName7Text = s;
|
||||||
|
playerName7Changed();
|
||||||
void PlayerAreaModel::setPlayerName6(QString s)
|
break;
|
||||||
{
|
}
|
||||||
playerName6Text = s;
|
|
||||||
emit playerName6Changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerAreaModel::setPlayerName7(QString s)
|
|
||||||
{
|
|
||||||
playerName7Text = s;
|
|
||||||
emit playerName7Changed();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@ class PlayerAreaModel : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
Q_PROPERTY(QString playerName1 READ playerName1 WRITE setPlayerName1 NOTIFY playerName1Changed)
|
Q_PROPERTY(QString playerName1 READ playerName1 NOTIFY playerName1Changed)
|
||||||
Q_PROPERTY(QString playerName2 READ playerName2 WRITE setPlayerName2 NOTIFY playerName2Changed)
|
Q_PROPERTY(QString playerName2 READ playerName2 NOTIFY playerName2Changed)
|
||||||
Q_PROPERTY(QString playerName3 READ playerName3 WRITE setPlayerName3 NOTIFY playerName3Changed)
|
Q_PROPERTY(QString playerName3 READ playerName3 NOTIFY playerName3Changed)
|
||||||
Q_PROPERTY(QString playerName4 READ playerName4 WRITE setPlayerName4 NOTIFY playerName4Changed)
|
Q_PROPERTY(QString playerName4 READ playerName4 NOTIFY playerName4Changed)
|
||||||
Q_PROPERTY(QString playerName5 READ playerName5 WRITE setPlayerName5 NOTIFY playerName5Changed)
|
Q_PROPERTY(QString playerName5 READ playerName5 NOTIFY playerName5Changed)
|
||||||
Q_PROPERTY(QString playerName6 READ playerName6 WRITE setPlayerName6 NOTIFY playerName6Changed)
|
Q_PROPERTY(QString playerName6 READ playerName6 NOTIFY playerName6Changed)
|
||||||
Q_PROPERTY(QString playerName7 READ playerName7 WRITE setPlayerName7 NOTIFY playerName7Changed)
|
Q_PROPERTY(QString playerName7 READ playerName7 NOTIFY playerName7Changed)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PlayerAreaModel(QObject *parent = nullptr);
|
explicit PlayerAreaModel(QObject *parent = nullptr);
|
||||||
|
@ -27,13 +27,6 @@ public:
|
||||||
QString playerName5();
|
QString playerName5();
|
||||||
QString playerName6();
|
QString playerName6();
|
||||||
QString playerName7();
|
QString playerName7();
|
||||||
void setPlayerName1(QString s);
|
|
||||||
void setPlayerName2(QString s);
|
|
||||||
void setPlayerName3(QString s);
|
|
||||||
void setPlayerName4(QString s);
|
|
||||||
void setPlayerName5(QString s);
|
|
||||||
void setPlayerName6(QString s);
|
|
||||||
void setPlayerName7(QString s);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void playerName1Changed();
|
void playerName1Changed();
|
||||||
|
@ -44,6 +37,9 @@ signals:
|
||||||
void playerName6Changed();
|
void playerName6Changed();
|
||||||
void playerName7Changed();
|
void playerName7Changed();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setPlayerName(QString s, int n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString playerName1Text;
|
QString playerName1Text;
|
||||||
QString playerName2Text;
|
QString playerName2Text;
|
||||||
|
|
|
@ -14,32 +14,31 @@ Item {
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName1
|
text: playerAreaModel.playerName1
|
||||||
onEditingFinished: playerAreaModel.playerName1 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 1)
|
||||||
selectByMouse: true
|
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName2
|
text: playerAreaModel.playerName2
|
||||||
onEditingFinished: playerAreaModel.playerName2 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 2)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName3
|
text: playerAreaModel.playerName3
|
||||||
onEditingFinished: playerAreaModel.playerName3 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 3)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName4
|
text: playerAreaModel.playerName4
|
||||||
onEditingFinished: playerAreaModel.playerName4 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 4)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName5
|
text: playerAreaModel.playerName5
|
||||||
onEditingFinished: playerAreaModel.playerName5 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 5)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName6
|
text: playerAreaModel.playerName6
|
||||||
onEditingFinished: playerAreaModel.playerName6 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 6)
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: playerAreaModel.playerName7
|
text: playerAreaModel.playerName7
|
||||||
onEditingFinished: playerAreaModel.playerName7 = text
|
onEditingFinished: playerAreaModel.setPlayerName(text, 7)
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
text: playerAreaModel.playerName1
|
text: playerAreaModel.playerName1
|
||||||
|
|
7
Root.qml
7
Root.qml
|
@ -11,11 +11,4 @@ Pane {
|
||||||
width: 1000
|
width: 1000
|
||||||
PlayerAreaView {
|
PlayerAreaView {
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Dentro do Text não podes mudar directamente
|
|
||||||
* o text do playerAreaModel;
|
|
||||||
* Para fazer isso tens que mandar um sinal
|
|
||||||
* que está ligado a um slot do playerAreaModel
|
|
||||||
* que vá mudar esse atributo
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue