312 lines
13 KiB
QML
312 lines
13 KiB
QML
import QtQuick 2.12
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import qt.koriolan.shipheart 1.0
|
|
import"fonctions.js" as Fonctions
|
|
import"fonctions_date_heure.js" as Fonctions_date_heure
|
|
import"suncalc.js" as Suncalc
|
|
|
|
|
|
Shipheart_page {
|
|
id: page_ephemeride
|
|
|
|
// Mis en forme :
|
|
readonly property double pourcentage_largeur_page_affichage_date_heure: 0.6
|
|
readonly property double espace_colonnes_principales: 30
|
|
|
|
// Affichage :
|
|
property bool bouton_bandeau_bas_zone_zone_retour_actif: false
|
|
|
|
// Données :
|
|
property string jour_semaine_courant
|
|
property string date_courante
|
|
property string heure_courante
|
|
property string langue: "FR"
|
|
|
|
property double test:0
|
|
|
|
// Modèles :
|
|
// Note : les modèles chargés dans 'main.qml' n'ont pas à être rechargés dans les pages suivantes
|
|
|
|
|
|
//===========================================================
|
|
// Timer 1 seconde :
|
|
//===========================================================
|
|
Timer {
|
|
id: timer_secondes
|
|
interval: 1000
|
|
triggeredOnStart: true
|
|
running: true
|
|
repeat: true
|
|
onTriggered: {
|
|
// Calcul de la date et de l'heure + mise en forme
|
|
var date = Fonctions_date_heure.date_courante(null, shipheart_fuseau_horaire, shipheart_heure_ete);
|
|
jour_semaine_courant = Fonctions_date_heure.chaine_jour_semaine(date)
|
|
date_courante = Fonctions_date_heure.chaine_date_longue(date, shipheart_langue)
|
|
heure_courante = Fonctions_date_heure.chaine_heure(date);
|
|
|
|
// Position :
|
|
mise_a_jour();
|
|
}
|
|
}
|
|
|
|
// Titre de la page :
|
|
Shipheart_titre_1 {titre:qsTr("Ephéméride"); hauteur: shipheart_hauteur_bandeau_haut}
|
|
|
|
//-------------------------------------------------------
|
|
// Ecran de gauche :
|
|
//-------------------------------------------------------
|
|
Rectangle {
|
|
x: 0
|
|
y: shipheart_hauteur_bandeau_haut;
|
|
width: (shipheart_largeur_page * pourcentage_largeur_page_affichage_date_heure) - (espace_colonnes_principales / 2);
|
|
height: shipheart_hauteur_page - shipheart_hauteur_bandeau_haut - shipheart_hauteur_bandeau_bas;
|
|
color: "transparent"
|
|
|
|
Text {
|
|
id: texte_jour_semaine
|
|
text: jour_semaine_courant
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
verticalCenterOffset: -200
|
|
horizontalCenter: parent.horizontalCenter
|
|
}
|
|
// font.family: "Montserrat"
|
|
font.pixelSize: 60
|
|
color: couleur_blanc_casse
|
|
}
|
|
Text {
|
|
id: texte_date
|
|
text: date_courante
|
|
textFormat: Text.RichText // Autorise la prise en compte de <sup> par exemple...
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
verticalCenterOffset: -100
|
|
horizontalCenter: parent.horizontalCenter
|
|
}
|
|
font.pixelSize: 60
|
|
color: couleur_blanc_casse
|
|
}
|
|
Text {
|
|
id: texte_heure
|
|
text: heure_courante
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
verticalCenterOffset: 100
|
|
horizontalCenter: parent.horizontalCenter
|
|
}
|
|
font.pixelSize: 100
|
|
// font.weight: Font.Bold
|
|
color: couleur_blanc_casse
|
|
}
|
|
Text {
|
|
id: texte_fuseau
|
|
text: (shipheart_fuseau_horaire > 0) ? "[ UTC +" + shipheart_fuseau_horaire + " ]" : ((shipheart_fuseau_horaire < 0) ? "[ UTC " + shipheart_fuseau_horaire + " ]" : "[ UTC ]" )
|
|
// NB : Il n'y a pas de '-' dans le second cas car il est mis automatiquement par la valeur numérique (qui est négative).
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
verticalCenterOffset: 250
|
|
horizontalCenter: parent.horizontalCenter
|
|
}
|
|
font.pixelSize: 20
|
|
color: couleur_blanc_casse
|
|
}
|
|
|
|
|
|
Text {
|
|
id: texte_heure_ete
|
|
text: (shipheart_heure_ete === 0) ? qsTr("Heure d'hiver") : qsTr("Heure d'été")
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
verticalCenterOffset: 250 + texte_fuseau.height + 10
|
|
horizontalCenter: parent.horizontalCenter
|
|
}
|
|
font.pixelSize: 16
|
|
// font.italic: true
|
|
color: couleur_gris_fonce
|
|
}
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------
|
|
// Ecran de droite :
|
|
//-------------------------------------------------------
|
|
Rectangle {
|
|
x: (shipheart_largeur_page * pourcentage_largeur_page_affichage_date_heure) + espace_colonnes_principales;
|
|
y: shipheart_hauteur_bandeau_haut;
|
|
width: ((shipheart_largeur_page * (1 - pourcentage_largeur_page_affichage_date_heure)) - (espace_colonnes_principales / 2)) * 0.8;
|
|
height: shipheart_hauteur_page - shipheart_hauteur_bandeau_haut - shipheart_hauteur_bandeau_bas;
|
|
color: "transparent"
|
|
|
|
ColumnLayout {
|
|
width: parent.width
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: 0
|
|
|
|
ListModel {
|
|
id: modele_ephemeride
|
|
ListElement { evenement: qsTr("Aube nautique"); heure: "00:00"; ligne_sup: 1; ligne_inf: 1; hauteur:40; image: ""; }
|
|
ListElement { evenement: qsTr("Lever du soleil"); heure: "00:00"; ligne_sup: 0; ligne_inf: 1; hauteur:40; image: ""; }
|
|
ListElement { evenement: qsTr("Zénith"); heure: "00:00"; ligne_sup: 0; ligne_inf: 1; hauteur:40; image: ""; }
|
|
ListElement { evenement: qsTr("Coucher du soleil"); heure: "00:00"; ligne_sup: 0; ligne_inf: 1; hauteur:40; image: ""; }
|
|
ListElement { evenement: qsTr("Crépuscule nautique"); heure: "00:00"; ligne_sup: 0; ligne_inf: 1; hauteur:40; image: ""; }
|
|
ListElement { evenement: ""; heure: ""; ligne_sup: 0; ligne_inf: 1; hauteur:60; image: ""; }
|
|
ListElement { evenement: qsTr("Lune"); heure: ""; ligne_sup: 0; ligne_inf: 1; hauteur:60; image: "/images/lune_1.png"; }
|
|
ListElement { evenement: ""; heure: ""; ligne_sup: 0; ligne_inf: 1; hauteur:60; image: ""; }
|
|
ListElement { evenement: qsTr("Latitude"); heure: "Inconnue"; ligne_sup: 0; ligne_inf: 1; hauteur:40; image: ""; }
|
|
ListElement { evenement: qsTr("Longitude"); heure: "Inconnue"; ligne_sup: 0; ligne_inf: 1; hauteur:40; image: ""; }
|
|
}
|
|
|
|
Repeater {
|
|
model: modele_ephemeride
|
|
|
|
Rectangle {
|
|
Layout.alignment: Qt.AlignCenter
|
|
Layout.preferredWidth: parent.width
|
|
Layout.preferredHeight: model.hauteur
|
|
color: "transparent"
|
|
|
|
Rectangle {
|
|
id: ligne_sup
|
|
height:1
|
|
width:parent.width
|
|
color: couleur_gris_tres_fonce_transparent
|
|
visible: model.ligne_sup ? 1 : 0;
|
|
}
|
|
Text {
|
|
id: titre_ligne
|
|
width: parent.width / 2;
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
horizontalAlignment: Text.AlignLeft
|
|
leftPadding: 10
|
|
text: model.evenement
|
|
font.pixelSize: 18
|
|
color: couleur_blanc_casse
|
|
}
|
|
Text {
|
|
x: titre_ligne.width;
|
|
width: parent.width - titre_ligne.width;
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
horizontalAlignment: Text.AlignRight
|
|
rightPadding: 10
|
|
text: model.heure
|
|
font.pixelSize: 18
|
|
color: couleur_blanc_casse
|
|
visible: (model.image === "") ? true : false;
|
|
}
|
|
Image {
|
|
visible: (model.image === "") ? false : true;
|
|
source: model.image;
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 20
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
sourceSize.height: 40;
|
|
}
|
|
Rectangle {
|
|
id: ligne_inf
|
|
anchors.top: parent.bottom;
|
|
height:1
|
|
width:parent.width
|
|
color: couleur_gris_tres_fonce_transparent
|
|
visible: model.ligne_inf ? 1 : 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------
|
|
// 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 - (2 * parent.padding)
|
|
height: shipheart_hauteur_bandeau_bas - parent.topPadding - parent.bottomPadding;
|
|
radius: 5
|
|
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: {
|
|
shipheart_clic();
|
|
stackView.pop()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//===========================================================
|
|
// 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);
|
|
}
|
|
}
|
|
|
|
|
|
//=============================================================================================================
|
|
// Mise à jour de la position
|
|
//=============================================================================================================
|
|
function mise_a_jour()
|
|
{
|
|
var req, res
|
|
var lat, lon;
|
|
var altitude = 0;
|
|
|
|
// Latitude :
|
|
modele_ephemeride.set(8, {"heure": Fonctions.chaine_latitude(shipheart_latitude) })
|
|
|
|
// Longitude :
|
|
modele_ephemeride.set(9, {"heure": Fonctions.chaine_longitude(shipheart_longitude) })
|
|
|
|
// Informations sur le soleil :
|
|
modele_ephemeride.set(0, {"heure": shipheart_heure_aube_nautique });
|
|
modele_ephemeride.set(1, {"heure": shipheart_heure_lever_soleil });
|
|
modele_ephemeride.set(2, {"heure": shipheart_heure_zenith });
|
|
modele_ephemeride.set(3, {"heure": shipheart_heure_coucher_soleil });
|
|
modele_ephemeride.set(4, {"heure": shipheart_heure_crepuscule_nautique });
|
|
|
|
// Ajout du calcul de la hauteur du soleil au zénith :
|
|
// NON TESTE !! A Tester !!
|
|
//var sun_positions = Suncalc.SunCalc.getPosition(Fonctions_date_heure.date_courante(null, shipheart_fuseau_horaire, shipheart_heure_ete), lat, lon);
|
|
//console.log("Hauteur du soleil au Zénith : " + (sun_positions.altitude * (180/3.141592653)).toFixed(1) + "°"); // La valeur d'altitude est retournée en radians
|
|
//console.log("Azimuth du soleil au Zénith : " + (sun_positions.azimuth * (180/3.141592653)).toFixed(1) + "°"); // La valeur d'azimuth est retournée en radians
|
|
|
|
// Informations sur la lune :
|
|
//console.time('calcul_heures_lune')
|
|
var moon_status = Suncalc.SunCalc.getMoonIllumination(Fonctions_date_heure.date_courante(null, shipheart_fuseau_horaire, shipheart_heure_ete));
|
|
//console.timeEnd('calcul_heures_lune')
|
|
var phase = Number(moon_status.phase);
|
|
|
|
modele_ephemeride.set(6, {"image": "/images/lune_" + Number(Math.trunc(phase * 16) + 1) + ".png" }) // Sélection d'une image entre 'lune_1.png' et 'lune_16.png'
|
|
}
|
|
}
|
|
|