import QtQuick 2.12 import QtQuick.Controls 2.12 Popup { id: boite_dialogue_entrees_aux // Propriétés fixes : readonly property double pourcentage_largeur_page_popup: 0.95 readonly property double pourcentage_hauteur_page_popup: 0.7 readonly property int padding_popup: 20 readonly property double pourcentage_boite_dialogue_titre: 0.3 readonly property double pourcentage_boite_dialogue_message: 1 - pourcentage_boite_dialogue_titre - pourcentage_boite_dialogue_ligne_boutons readonly property double pourcentage_boite_dialogue_ligne_boutons: 0.3 readonly property int bouton_largeur: 200 // Propriétés : // Propriétés alias : property alias boutonAnnuler: bouton_annuler.visible property alias boutonAnnulerTexte: bouton_annuler_label.text property string nom_equipement: "" // Signaux : signal clicked(int bouton, int no_entree) // Valeur à lire lorsque le "OnClicked' est activé x: (shipheart_largeur_page * (1 - pourcentage_largeur_page_popup)) / 2; y: (shipheart_hauteur_page * (1 - pourcentage_hauteur_page_popup)) / 2; width: shipheart_largeur_page * pourcentage_largeur_page_popup; height: shipheart_hauteur_page * pourcentage_hauteur_page_popup; padding: padding_popup modal: true // focus: true // SDIR # 224 : Il ne faut PAS activer le focus. Sinon, à la fermeture, le focus précédent est réactivé (comme le dernier TextField par exemple) closePolicy: Popup.NoAutoClose //Popup.CloseOnPressOutside background: Rectangle { color: shipheart_couleur_fond_boite_dialogue_niveau_0 radius: 20 } Column { id: affichage_boite_dialogue spacing: 20 //========================================================================= // Titre : //========================================================================= Rectangle { id: titre_boite_dialogue width: boite_dialogue_entrees_aux.width - (2 * padding_popup) height: (boite_dialogue_entrees_aux.height - (2 * padding_popup) - (2 * affichage_boite_dialogue.spacing)) * pourcentage_boite_dialogue_titre color: "transparent" Label { text: qsTr("Entrées Auxiliaires") anchors.fill: parent verticalAlignment: Text.AlignTop horizontalAlignment: Text.AlignHCenter topPadding: 20 wrapMode: Text.Wrap color: couleur_blanc_casse font.pixelSize:40 font.weight: Font.Bold } Label { text: qsTr("Affectation de l'entrée n° %1 du %2").arg(entree_en_cours).arg(nom_equipement) anchors.fill: parent verticalAlignment: Text.AlignBottom horizontalAlignment: Text.AlignHCenter bottomPadding: 20 wrapMode: Text.Wrap color: couleur_blanc_casse font.pixelSize:18 } } //========================================================================= // Choix de l'entrée : //========================================================================= Rectangle { width: boite_dialogue_entrees_aux.width - (2 * padding_popup) height: (boite_dialogue_entrees_aux.height - (2 * padding_popup) - (2 * affichage_boite_dialogue.spacing)) * pourcentage_boite_dialogue_message color: "transparent" Grid { id: grille_entrees_aux width: parent.width height: parent.height columns: 4 spacing: 20 Repeater { // Constitue les blocs d'entrées, telq qu'ils sont physiquement (4 entrées + espace) model: modele_entrees_aux delegate: Row { width: (parent.width - (3 * grille_entrees_aux.spacing)) / 4 height: (parent.height - grille_entrees_aux.spacing) / 2 Repeater { // Constitue les 4 entrées par bloc model: valeurs delegate: Rectangle { // Ce rectangle réserve la place pour chaque bouton mais n'est pas visible width: parent.width / 4 height: parent.height color: "transparent" Rectangle { // Ce rectangle est le bouton visible, légèrement plus petit que son père pour réserver un espace entre chaque entrée au sein du même bloc width: parent.width * 0.98 height: parent.height radius: shipheart_rayon_bouton color: ((model.used === 1) && (model.no_entree !== entree_en_cours)) ? couleur_gris_fonce : couleur_gris_tres_fonce Label { anchors.fill: parent horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignTop topPadding: 20 text: no color: (model.used === 0) ? couleur_blanc_casse : couleur_gris_moyen font.pixelSize: 18 font.bold: true } Label { anchors.fill: parent horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignBottom bottomPadding: 20 visible: model.no_entree !== 0 text: model.no_entree color: couleur_green_yellow font.pixelSize: 18 font.bold: true } } MouseArea { anchors.fill: parent enabled: (model.used === 0) || (model.no_entree === entree_en_cours) onClicked: { shipheart_clic(); boite_dialogue_entrees_aux.clicked(shipheart_boite_dialogue_bouton_1, no); } } } } } } } } //========================================================================= // Boutons : //========================================================================= Row { height: (boite_dialogue_entrees_aux.height - (2 * padding_popup) - (2 * affichage_boite_dialogue.spacing)) * pourcentage_boite_dialogue_ligne_boutons anchors.horizontalCenter: parent.horizontalCenter spacing: 20 //-------------------------------------------------------------------- // Bouton Annuler : Rectangle { id: bouton_annuler width: bouton_largeur height: parent.height * 0.5 anchors.verticalCenter: parent.verticalCenter radius: shipheart_rayon_bouton color: couleur_gris_tres_fonce Label { id: bouton_annuler_label anchors.centerIn: parent text: qsTr("Annuler") color: couleur_blanc_casse font.pixelSize:20 } MouseArea { anchors.fill: parent onClicked: { shipheart_clic(); boite_dialogue_entrees_aux.clicked(shipheart_boite_dialogue_bouton_2, 0); boite_dialogue_entrees_aux.close(); } } } } } //============================================================================================================= // Transitions d'ouverture et de fermeture de la boite de dialogue //============================================================================================================= enter: Transition { ParallelAnimation { NumberAnimation { property: "opacity" from: 0.0 to: 1.0 //easing.type: Easing.InElastic duration: 200 } NumberAnimation { property: "scale" from: 0.0 to: 1.0 // easing.type: Easing.OutBack duration: 200 } } } exit: Transition { ParallelAnimation { NumberAnimation { property: "opacity" from: 1.0 to: 0.0 duration: 200 } NumberAnimation { property: "scale" from: 1.0 to: 0.0 duration: 200 } } } }