Skip to content
Snippets Groups Projects
Commit 4357e504 authored by Breitwiller Josephine's avatar Breitwiller Josephine
Browse files

popupDialogue finie

parent 2a0d8eca
Branches
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ qt_add_qml_module(appapplicationQT2048
SOURCES gamemanager.h gamemanager.cpp
SOURCES gamemanager.h gamemanager.cpp
QML_FILES Main.qml
QML_FILES popupDialogue.qml
QML_FILES PopupDialogue.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
......@@ -5,6 +5,8 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
id: gamePage
focus: true // Active le focus pour capter les événements clavier
Rectangle {
width: 400
height: 600
......@@ -34,7 +36,11 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
}
PopupDialogue{
id : popup
x : 100
y : 200
}
Text {
......@@ -142,7 +148,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
id: buttonMouseArea
anchors.fill: parent
onClicked: gameManager.restartGame()
onClicked: popup.open()
}
}
......
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick
import QtQuick.Controls
ApplicationWindow {
visible: true
......
import QtQuick
import QtQuick.Controls
Popup {
id: partieNameDialogue
width: 250
height: 150
modal: true
closePolicy: Popup.CloseOnEscape
onOpened: textInput.text = ""
Column {
spacing: 10
width: parent.width
padding: 10
Label {
text: "Pour enregistrer la partie précédente, entrez un nom pour la partie.\nSi vous ne souhaitez pas enregistrer, appuyez sur Annuler."
wrapMode: Text.Wrap
width: parent.width
}
TextField {
id: textInput
width: parent.width
placeholderText: "Ex: Partie 1"
}
Row {
spacing: 10
width: parent.width
Button {
text: "OK"
onClicked: {
gameManager.restartGame(textInput.text);
partieNameDialogue.close();
}
}
Button {
text: "Annuler"
onClicked: {
gameManager.restartGame("false");
partieNameDialogue.close();
}
}
}
}
}
#include "gamemanager.h"
#include "random"
#include <QFileInfo>
#include <QDebug>
GameManager::GameManager(QObject *parent) : QObject(parent), grid(4, std::vector<int>(4, 0)) {
......@@ -184,11 +183,14 @@ void GameManager::moveDown() {
}
void GameManager::restartGame() {
void GameManager::restartGame(QString partieName) {
//demander pour sauvergarder la partie précédente
enregistrerPartie("partie1");
if(partieName=="false"){
}else{
enregistrerPartie(partieName);
};
// Réinitialisation des variables
......@@ -383,3 +385,5 @@ void GameManager::chargerPartie(QString partieName){
}
......@@ -23,7 +23,7 @@ public:
Q_INVOKABLE void moveRight();
Q_INVOKABLE void moveUp();
Q_INVOKABLE void moveDown();
Q_INVOKABLE void restartGame();
Q_INVOKABLE void restartGame(QString partieName);
Q_INVOKABLE void undo();
Q_INVOKABLE void chargerPartie(QString partieName);
......
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
Dialog {
id: partieNameDialogue
title: "Pour enregistrer la partie précédente entrez un nom pour la partie. Si vous ne souhaitez pas enregistrer cette partie appuyer sur Cancel."
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
Column {
spacing: 10
width: parent.width
TextField {
id: textInput
width: parent.width
placeholderText: "Ex: Partie 1"
}
}
onAccepted: {
gameManager.recupererNomPartie(textInput.text);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment