//======================================================================================================================================================================== // HOME_ACCUEIL.QML // Ce fichier est la page d'accueil par défaut. Il propose l'affichage du logo ShipHeart et le nom du bateau. // La page est appelée depuis la page main.qml lorsque le paramètre 'shipheart_specifique_client[0]' est égal à 0 //======================================================================================================================================================================== import QtQuick 2.12 import QtQuick.Controls 2.12 import qt.koriolan.shipheart 1.0 Shipheart_page { id: page_home_o_yachts // Mis en forme : readonly property double pourcentage_hauteur_ligne_haut: 0.7 readonly property double espace_lignes_principales: 0 // L'espace ne sert à rien et est même contre-productif pour avoir le logo centré entre haut de l'écran et le texte "Bienvenue à bord...." readonly property double affichage_hauteur_utile: shipheart_hauteur_page - shipheart_hauteur_bandeau_bas readonly property int periode_raffraichissement_parametres: 1000 // En ms readonly property int duree_affichage: 15 // En s // Affichage : // Données : property string nom_du_bateau: "" property int compteur_affichage: 0 // Modèles : // Note : les modèles chargés dans 'main.qml' n'ont pas à être rechargés dans les pages suivantes //------------------------------------------------- // Ouverture : //------------------------------------------------- StackView.onActivating: { // Le 'onActivating' permet de ne pas voir la mise à jour puisqu'elle est lancée dès que la page va être chargée init_page(); timer_raffraichissement_parametres.start(); } //------------------------------------------------- // Fermeture : //------------------------------------------------- StackView.onDeactivating: { timer_raffraichissement_parametres.stop(); } //=========================================================== // Timer periode raffraichissement parametres : //=========================================================== Timer { id: timer_raffraichissement_parametres interval: periode_raffraichissement_parametres triggeredOnStart: false running: true repeat: true onTriggered: { if (++ compteur_affichage > duree_affichage) sortie_page(); } } //------------------------------------------------------- // Ecran Haut : //------------------------------------------------------- Rectangle { id: zone_affichage_haut_gauche x: 0 y: 0 width: shipheart_largeur_page height: (affichage_hauteur_utile * pourcentage_hauteur_ligne_haut) - (espace_lignes_principales); color: "transparent" Image { source: (shipheart_fichier_image_accueil !== "") ? "file://" + shipheart_repertoire_config + shipheart_sous_repertoire_images_accueil + "/" + shipheart_fichier_image_accueil : "/images/" + shipheart_nom_fichier_image_accueil_par_defaut sourceSize.height: parent.height * 0.7 anchors { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter } } } //------------------------------------------------------- // Ecran Bas : //------------------------------------------------------- Rectangle { id: zone_affichage_bas_gauche x: 0 y: zone_affichage_haut_gauche.height + espace_lignes_principales; width: shipheart_largeur_page height: (affichage_hauteur_utile * (1 - pourcentage_hauteur_ligne_haut)) - (espace_lignes_principales); color: "transparent" Text { anchors { top: parent.top // Permet que ce texte soit juste en-dessous de la zone haute (sur laquelle le logo est centré => donc le logo est centré entre haut de l'écran et ce texte) horizontalCenter: parent.horizontalCenter } font.pixelSize: 24 text: qsTr("Bienvenue à bord de"); color: couleur_blanc_casse } Text { anchors { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter verticalCenterOffset: -20 // Remonté légèrement le nom du bateau... } font.pixelSize: 50 text: '" ' + nom_du_bateau + ' "'; color: couleur_blanc_casse font.weight: Font.Black } } //------------------------------------------------------- // 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 Rectangle { width: parent.width height: parent.height color: shipheart_couleur_fond_bouton //"transparent" Rectangle { // Barre augmentant selon l'évolution du compteur_affichage width: (compteur_affichage / duree_affichage) * parent.width height: parent.height color: shipheart_couleur_fond_bouton_actif opacity: 0.5 radius: shipheart_rayon_bouton Behavior on width { NumberAnimation { duration: periode_raffraichissement_parametres } } } Image { source: "/images/right_sombre.png" sourceSize.height: parent.height * 0.5 anchors { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter horizontalCenterOffset: -10 } } Image { source: "/images/right_sombre.png" sourceSize.height: parent.height * 0.5 anchors { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter horizontalCenterOffset: +10 } } MouseArea { anchors.fill: parent onClicked: { shipheart_clic(); sortie_page(); //stackView.push("parametres_avances.qml"); } } } } //=========================================================== // Economiseur : Doit être placé en fin de page pour fonctionner //=========================================================== MouseArea { anchors.fill: parent preventStealing: true // Permet que cela fonctionne même si un élément flickable (notamment) soit derrière et "vole" le click enabled: flag_economiseur_actif onClicked: { mise_en_veille(0); } } //============================================================================================================= // Init de la page //============================================================================================================= function init_page() { var req, res mise_en_veille(0); console.log("Init de Home_accueil..."); // Mise à jour du nom du bateau : req = 'SELECT Valeur FROM TB_Configuration WHERE Nom="Nom_du_bateau" '; res = bdd.requete_unique(req); nom_du_bateau = res[0]; compteur_affichage = 0; } //============================================================================================================= // Sortie de la page //============================================================================================================= function sortie_page() { compteur_affichage = 0; // Pour le cas où on réouvrirait la page (via le bouton paramètres / appui long) ; dans ce cas, la remise à 0 du compteur prend quelques secondes (ce sera donc fait avant si on le remet de suite à 0) stackView.push("home.qml"); } }