Skip to content
Snippets Groups Projects
Commit 89f79863 authored by Massies Alexandre's avatar Massies Alexandre
Browse files

Orga relative fenetre réglée et ça ercit dans les cases

parent 48d49951
No related merge requests found
......@@ -47,6 +47,7 @@ qt_add_qml_module(appMotus
QML_FILES
QML_FILES MotusTimer.qml
QML_FILES NumberLetterButton.qml
RESOURCES qtquickcontrols2.conf
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
import QtQuick
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
// Optionnel : utilisez un style non natif pour autoriser la personnalisation
// import QtQuick.Controls.Material 2.12
Window {
id: mainWindow
width: Screen.width
height: Screen.height
visible: true
visibility: Window.Maximized
title: qsTr("Motus")
property var caseArray: [
_case_1_1, _case_1_2, _case_1_3, _case_1_4, _case_1_5,
_case_2_1, _case_2_2, _case_2_3, _case_2_4, _case_2_5,
_case_3_1, _case_3_2, _case_3_3, _case_3_4, _case_3_5,
_case_4_1, _case_4_2, _case_4_3, _case_4_4, _case_4_5,
_case_5_1, _case_5_2, _case_5_3, _case_5_4, _case_5_5,
_case_6_1, _case_6_2, _case_6_3, _case_6_4, _case_6_5
]
// Suppression de la déclaration initiale de caseArray car _case_1_1 etc. ne sont pas définis.
property int indice_case: 0
property var caseArray: [] // sera rempli après création de la grille
property var case_focus: null
property var case_focus: caseArray[0]
// L'élément Rectangle ci-dessous couvre toute la fenêtre et gère les touches
Rectangle {
id: mainRect
anchors.fill: parent
color: "#323232"
focus: true
// Gestion des touches (attachée à un Item, pas à Window)
Keys.onPressed: {
// Vérifier que l'élément qui a le focus possède la propriété _textText
// Vérification que case_focus existe et possède la propriété _textText
if (case_focus && case_focus._textText !== undefined && /^[a-zA-Z]$/.test(event.text)) {
case_focus._textText = event.text;
indice_case += 1;
case_focus = caseArray[indice_case]
console.log("Lettre pressée :", event.text);
event.accepted = true;
indice_case++;
if (indice_case < caseArray.length) {
case_focus = caseArray[indice_case];
}
else if (event.key === Qt.Key_Backspace) {
console.log("Backspace a été pressée");
event.accepted = true;
} else if (event.key === Qt.Key_Backspace) {
if (case_focus && case_focus._textText !== undefined)
case_focus._textText = "";
if (indice_case != 0){
indice_case -= 1;
if (indice_case > 0) {
indice_case--;
case_focus = caseArray[indice_case];
}
// Ajoutez ici le code pour effacer le contenu ou réaliser l'action souhaitée
event.accepted = true;
}
}
Rectangle {
id: rectangle
anchors.fill: parent
color: "#323232"
focus: true
// Bouton "Générer un mot"
Choosebutton {
id: choosebutton
anchors.top: parent.top
anchors.left: parent.left
anchors.topMargin: height * 0.2
anchors.leftMargin: width * 0.2
anchors.topMargin: parent.height * 0.2
anchors.leftMargin: parent.width * 0.2
_textText: "Générer un mot"
Case {
......@@ -72,8 +70,6 @@ Window {
}
}
// Choix du nombre de lettres (en haut à droite)
// Fenêtre pour les langages (en dessous du bouton générer)
Rectangle {
id: big_rectangle_langue
......@@ -81,7 +77,7 @@ Window {
height: parent.height * 0.35
anchors.top: choosebutton.bottom
anchors.left: choosebutton.left
anchors.topMargin: height * 0.3
anchors.topMargin: parent.height * 0.3
color: "#323232"
radius: 10
border.color: "#ffffff"
......@@ -91,48 +87,37 @@ Window {
anchors.fill: parent
anchors.margins: 10
spacing: 10
anchors.horizontalCenter: parent.horizontalCenter
// Ne pas utiliser d'anchors conflictuels sur les enfants du Column
Text {
text: qsTr("Language/Langage")
font.pixelSize: 25
color: "white"
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
}
LangageButton {
_textText: "Français"
anchors.top: parent.top
anchors.right: parent.right
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: parent.height * 0.6
// Utilisez par exemple Layout.alignment si nécessaire
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: motusGame.dictionnaryChoosed = "Motus\\mots_francais.txt"
onClicked: {
motusGame.dictionnaryChoosed = "Motus\\mots_francais.txt";
}
}
}
LangageButton {
_textText: "English"
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: parent.height * 0.2
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: motusGame.dictionnaryChoosed = "Motus\\words_alpha.txt"
onClicked: {
motusGame.dictionnaryChoosed = "Motus\\words_alpha.txt";
}
}
}
}
......@@ -149,14 +134,14 @@ Window {
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: height * 0.2
anchors.topMargin: parent.height * 0.2
}
// Grille de jeu juste en dessous de MOTUS
// Grille de jeu (les cases seront créées dynamiquement)
Grid {
id: grid
anchors.top: _text2.bottom
anchors.topMargin: height * 0.02
anchors.topMargin: parent.height * 0.02
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width * 0.25
height: parent.height * 0.3
......@@ -165,8 +150,26 @@ Window {
columns: 5
Repeater {
id: caseRepeater
model: 30
delegate: Case {}
delegate: Case {
// Afin d'identifier chaque instance, on peut donner un objectName
objectName: "caseDelegate"
}
}
}
// Au chargement, remplir caseArray à partir des enfants de la grille
Component.onCompleted: {
caseArray = [];
for (var i = 0; i < grid.children.length; i++) {
// On ajoute uniquement les instances générées par le Repeater
if (grid.children[i].objectName === "caseDelegate") {
caseArray.push(grid.children[i]);
}
}
if (caseArray.length > 0) {
case_focus = caseArray[0];
}
}
......@@ -177,7 +180,7 @@ Window {
height: parent.height * 0.28
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottomMargin: height * 0.2
anchors.bottomMargin: parent.height * 0.2
color: "#323232"
radius: 10
border.color: "#ffffff"
......@@ -186,16 +189,6 @@ Window {
Column {
anchors.fill: parent
anchors.margins: 10
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.topMargin: 0
anchors.rightMargin: 0
anchors.leftMargin: 0
anchors.bottomMargin: 0
spacing: parent.width * 0.04
Repeater {
......@@ -220,22 +213,17 @@ Window {
}
}
}
// Timer en bas à droite
// Timer à droite du mot MOTUS
}
// Combobox pour le nombre de lettres
Rectangle {
id: rectangle_combobox
x: 1299
y: 4
width: parent.width * 0.2
height: parent.height * 0.2
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: height * 1.3
anchors.rightMargin: width * 0.6
width: parent.width * 0.2
height: parent.height * 0.2
anchors.topMargin: parent.height * 0.13
anchors.rightMargin: parent.width * 0.6
color: "#323232"
radius: 10
border.color: "#ffffff"
......@@ -256,11 +244,10 @@ Window {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 16
anchors.left: parent.left
}
}
// Timer
MotusTimer {
id: motusTimer
anchors.top: parent.top
......@@ -268,7 +255,5 @@ Window {
anchors.topMargin: parent.height * 0.07
anchors.rightMargin: parent.width * 0.25
}
}
}
[Controls]
Style=Material
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment