Import initial du projet shipheart_cm5
This commit is contained in:
@@ -0,0 +1,366 @@
|
||||
import QtQuick 2.12
|
||||
import QtQml.Models
|
||||
|
||||
import qt.koriolan.shipheart 1.0
|
||||
|
||||
|
||||
Shipheart_page {
|
||||
id: page_config_circuit
|
||||
|
||||
|
||||
// Mis en forme :
|
||||
readonly property double pourcentage_largeur_colonne_gauche: 0.75
|
||||
readonly property double espace_colonnes_principales: 20
|
||||
readonly property double pourcentage_hauteur_ligne_haut: 1
|
||||
readonly property double espace_lignes_principales: 20
|
||||
readonly property double affichage_hauteur_utile: shipheart_hauteur_page - shipheart_hauteur_bandeau_haut - shipheart_hauteur_bandeau_bas
|
||||
|
||||
readonly property int hauteur_ligne_formulaire: 60
|
||||
readonly property double pourcentage_largeur_labels_formulaire: 0.6
|
||||
|
||||
readonly property int hauteur_bouton_droit: 80
|
||||
|
||||
readonly property double pourcentage_bandeau_bas_largeur_zone_retour: 1
|
||||
|
||||
|
||||
readonly property int periode_init_raffraichissement_parametres: 1 // En ms
|
||||
readonly property int periode_raffraichissement_parametres: 1000 // En ms
|
||||
|
||||
|
||||
|
||||
// Affichage :
|
||||
property int protection_mode: 0
|
||||
|
||||
|
||||
// Données :
|
||||
|
||||
|
||||
|
||||
// Modèles :
|
||||
property Bdd bdd : Bdd{}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//===========================================================
|
||||
// Timer periode raffraichissement parametres :
|
||||
//===========================================================
|
||||
Timer {
|
||||
id: timer_raffraichissement_parametres
|
||||
interval: periode_init_raffraichissement_parametres
|
||||
triggeredOnStart: false
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (interval == periode_init_raffraichissement_parametres) { // Premier passage, 1ms après le premier chargement
|
||||
interval = periode_raffraichissement_parametres;
|
||||
|
||||
init_page();
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Titre de la page :
|
||||
Shipheart_titre_1 {titre:"Configuration des tests"; hauteur: shipheart_hauteur_bandeau_haut}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Ecran Haut - Gauche :
|
||||
//-------------------------------------------------------
|
||||
Rectangle {
|
||||
id: zone_affichage_haut_gauche
|
||||
x: 0
|
||||
y: shipheart_hauteur_bandeau_haut;
|
||||
width: (shipheart_largeur_page * pourcentage_largeur_colonne_gauche) - (espace_colonnes_principales / 2)
|
||||
height: (affichage_hauteur_utile * pourcentage_hauteur_ligne_haut) - (espace_lignes_principales / 2);
|
||||
color: "transparent"
|
||||
|
||||
ListView {
|
||||
id: grille_principale
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
snapMode: GridView.SnapToRow // L'arret de l'affichage se fera sur une rangée entière
|
||||
clip: true // Nécessaire pour que les Delegates s'arretent à l'intérieur de la GridView
|
||||
model: modele_grille_principale
|
||||
footer: Rectangle { // Permet de dégager la place suffisante en fin de GridView pour accéder même au dernier élément lorsque que clavier est déplié
|
||||
height: shipheart_hauteur_clavier
|
||||
color: "transparent"
|
||||
}
|
||||
|
||||
ObjectModel {
|
||||
id: modele_grille_principale
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Ligne de formulaire : Vitesse de test écran
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: visible ? hauteur_ligne_formulaire : 0
|
||||
color: "transparent"
|
||||
|
||||
Shipheart_formulaire_label {
|
||||
text: qsTr("Vitesse de test de l'écran")
|
||||
width: parent.width * pourcentage_largeur_labels_formulaire
|
||||
}
|
||||
|
||||
Shipheart_formulaire_combobox {
|
||||
id: champ_formulaire_Vitesse_test_ecran
|
||||
model: ListModel { }
|
||||
width: parent.width * (1 - pourcentage_largeur_labels_formulaire)
|
||||
onActivated: {
|
||||
shipheart_clic();
|
||||
}
|
||||
}
|
||||
|
||||
Shipheart_formulaire_ligne_separation {
|
||||
haut_bas_hautbas: shipheart_formulaire_ligne_separation_basse
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Ligne de formulaire : Nombre colonnes de la matrice de test
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: visible ? hauteur_ligne_formulaire : 0
|
||||
color: "transparent"
|
||||
|
||||
Shipheart_formulaire_label {
|
||||
text: qsTr("Nombre de colonnes de test du touchpad")
|
||||
width: parent.width * pourcentage_largeur_labels_formulaire
|
||||
}
|
||||
|
||||
Shipheart_formulaire_combobox {
|
||||
id: champ_formulaire_Nombre_colonnes_matrice_test
|
||||
model: ListModel { }
|
||||
width: parent.width * (1 - pourcentage_largeur_labels_formulaire)
|
||||
onActivated: {
|
||||
shipheart_clic();
|
||||
}
|
||||
}
|
||||
|
||||
Shipheart_formulaire_ligne_separation {
|
||||
haut_bas_hautbas: shipheart_formulaire_ligne_separation_basse
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Ligne de formulaire : Nombre lignes de la matrice de test
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: visible ? hauteur_ligne_formulaire : 0
|
||||
color: "transparent"
|
||||
|
||||
Shipheart_formulaire_label {
|
||||
text: qsTr("Nombre de lignes de test du touchpad")
|
||||
width: parent.width * pourcentage_largeur_labels_formulaire
|
||||
}
|
||||
|
||||
Shipheart_formulaire_combobox {
|
||||
id: champ_formulaire_Nombre_lignes_matrice_test
|
||||
model: ListModel { }
|
||||
width: parent.width * (1 - pourcentage_largeur_labels_formulaire)
|
||||
onActivated: {
|
||||
shipheart_clic();
|
||||
}
|
||||
}
|
||||
|
||||
Shipheart_formulaire_ligne_separation {
|
||||
haut_bas_hautbas: shipheart_formulaire_ligne_separation_basse
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Ecran Droite :
|
||||
//-------------------------------------------------------
|
||||
Rectangle {
|
||||
id: zone_affichage_droite
|
||||
x: zone_affichage_haut_gauche.width + espace_colonnes_principales
|
||||
y: shipheart_hauteur_bandeau_haut;
|
||||
width: (shipheart_largeur_page * (1 - pourcentage_largeur_colonne_gauche)) - (espace_colonnes_principales / 2)
|
||||
height: (affichage_hauteur_utile * pourcentage_hauteur_ligne_haut) - (espace_lignes_principales / 2);
|
||||
color: "transparent"
|
||||
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
// Bouton Enregistrer :
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: hauteur_bouton_droit
|
||||
color: shipheart_couleur_fond_bouton
|
||||
radius: shipheart_rayon_bouton
|
||||
Text {
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
font.pixelSize: 20
|
||||
text: "Enregistrer"
|
||||
color: couleur_blanc_casse
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
pressAndHoldInterval: shipheart_mouse_press_and_hold_interval_tres_court
|
||||
onPressAndHold: {
|
||||
shipheart_test_vitesse_test_ecran = champ_formulaire_Vitesse_test_ecran.model.get(champ_formulaire_Vitesse_test_ecran.currentIndex).valeur
|
||||
nombre_colonnes_matrice_test = champ_formulaire_Nombre_colonnes_matrice_test.model.get(champ_formulaire_Nombre_colonnes_matrice_test.currentIndex).valeur
|
||||
nombre_lignes_matrice_test = champ_formulaire_Nombre_lignes_matrice_test.model.get(champ_formulaire_Nombre_lignes_matrice_test.currentIndex).valeur
|
||||
stackView.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Bandeau bas :
|
||||
//-------------------------------------------------------
|
||||
Row {
|
||||
x: 0
|
||||
y: shipheart_hauteur_page - shipheart_hauteur_bandeau_bas;
|
||||
width: shipheart_largeur_page;
|
||||
height: shipheart_hauteur_bandeau_bas;
|
||||
spacing: 5
|
||||
padding: 5
|
||||
|
||||
//.................................................
|
||||
// Bouton retour
|
||||
//.................................................
|
||||
Rectangle {
|
||||
id: bandeau_bas_zone_retour
|
||||
width: (parent.width * pourcentage_bandeau_bas_largeur_zone_retour) - (2 * parent.padding)
|
||||
height: shipheart_hauteur_bandeau_bas - parent.topPadding - parent.bottomPadding;
|
||||
radius: shipheart_rayon_bouton
|
||||
color: shipheart_couleur_fond_bouton
|
||||
|
||||
Image {
|
||||
source: "/images/icone_retour.png"
|
||||
sourceSize.height: 30
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea { // Zone d'interaction. On est obligé de la mettre dans la grille pour que Rectangle et MouseArea soient frères ou parent/enfant ET qu'on n'occupe qu'un espace dans la grille.
|
||||
id: mouse_area_bandeau_bas_zone_retour
|
||||
anchors.fill: parent
|
||||
onClicked: { // Si la pression n'a pas duré assez longtemps, on ne fait rien
|
||||
stackView.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================================================================================
|
||||
// Init de la page
|
||||
//=============================================================================================================
|
||||
function init_page()
|
||||
{
|
||||
var i, j;
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Vitesse de test d'écran :
|
||||
champ_formulaire_Vitesse_test_ecran.model.clear();
|
||||
champ_formulaire_Vitesse_test_ecran.model.append({"valeur": 500, "texte": "Très rapide (500ms par page)" });
|
||||
champ_formulaire_Vitesse_test_ecran.model.append({"valeur": 1000, "texte": "Rapide (1s par page)" });
|
||||
champ_formulaire_Vitesse_test_ecran.model.append({"valeur": shipheart_test_vitesse_test_ecran, "texte": "Moyenne (1.5s par page)" });
|
||||
champ_formulaire_Vitesse_test_ecran.model.append({"valeur": 2000, "texte": "Lente (2s par page)" });
|
||||
champ_formulaire_Vitesse_test_ecran.model.append({"valeur": 3000, "texte": "Très lente (3s par page)" });
|
||||
|
||||
// Positionnement de l'index sur la valeur en cours :
|
||||
i = recherche_index_valeur_modele(shipheart_test_vitesse_test_ecran, champ_formulaire_Vitesse_test_ecran.model, "Vitesse_test_ecran");
|
||||
if (i === -1) champ_formulaire_Vitesse_test_ecran.currentIndex = 2;
|
||||
else champ_formulaire_Vitesse_test_ecran.currentIndex = i;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Nombre de colonnes de la matrice de test :
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.clear();
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 4, "texte": "4" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 5, "texte": "5" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 6, "texte": "6" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 7, "texte": "7" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 8, "texte": "8" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 9, "texte": "9" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 10, "texte": "10" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 11, "texte": "11" });
|
||||
champ_formulaire_Nombre_colonnes_matrice_test.model.append({"valeur": 12, "texte": "12" });
|
||||
|
||||
// Positionnement de l'index sur la valeur en cours :
|
||||
i = recherche_index_valeur_modele(nombre_colonnes_matrice_test, champ_formulaire_Nombre_colonnes_matrice_test.model, "Nombre_colonnes_matrice_test");
|
||||
if (i === -1) champ_formulaire_Nombre_colonnes_matrice_test.currentIndex = 2;
|
||||
else champ_formulaire_Nombre_colonnes_matrice_test.currentIndex = i;
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Nombre de lignes de la matrice de test :
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.clear();
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 2, "texte": "2" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 3, "texte": "3" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 4, "texte": "4" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 5, "texte": "5" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 6, "texte": "6" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 7, "texte": "7" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 8, "texte": "8" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 9, "texte": "9" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 10, "texte": "10" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 11, "texte": "11" });
|
||||
champ_formulaire_Nombre_lignes_matrice_test.model.append({"valeur": 12, "texte": "12" });
|
||||
|
||||
// Positionnement de l'index sur la valeur en cours :
|
||||
i = recherche_index_valeur_modele(nombre_lignes_matrice_test, champ_formulaire_Nombre_lignes_matrice_test.model, "Nombre_lignes_matrice_test");
|
||||
if (i === -1) champ_formulaire_Nombre_lignes_matrice_test.currentIndex = 2;
|
||||
else champ_formulaire_Nombre_lignes_matrice_test.currentIndex = i;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================================================================================
|
||||
// Recherche de l'index d'une certaine valeur dans un modele
|
||||
//=============================================================================================================
|
||||
function recherche_index_valeur_modele(cible, modele, nom_modele)
|
||||
{
|
||||
var i;
|
||||
|
||||
for (i=0; i<modele.count; i ++)
|
||||
{
|
||||
if (modele.get(i).valeur === cible) break; // Cas où la valeur cible a été trouvée parmi les valeurs du modèle
|
||||
}
|
||||
if (i === modele.count)
|
||||
{
|
||||
console.log("Aucune valeur trouvée pour cible = [" + cible + "] du modèle = " + nom_modele);
|
||||
i = -1; // Cas où la valeur n'a pas été trouvée parmi les valeurs du modèle
|
||||
}
|
||||
//else console.log("Valeur trouvée : [" + i + "] pour cible = [" + cible + "] soit texte = [" + modele.get(i).texte + "]");
|
||||
return(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user