2 #include "ui_IHMGroom.h"
21 qDebug() << Q_FUNC_INFO;
33 #ifdef TEST_NOTIFICATION
34 connect(
uiIHMGroom->boutonPoussoirSonnette, SIGNAL(clicked(
bool)),
this, SLOT(testerNotification()));
49 qDebug() << Q_FUNC_INFO;
64 QMessageBox::information(
this,
"IHMGroom",
"Le programme continue à s'éxécuter. Utiliser le menu Quitter pour mettre fin à l'application.");
83 actionQuitter =
new QAction(QString::fromUtf8(
"&Quitter"),
this);
86 uiIHMGroom->widgetCalendrier->setMinimumDate(QDate(1900, 1, 1));
87 uiIHMGroom->widgetCalendrier->setMaximumDate(QDate(3000, 1, 1));
88 uiIHMGroom->widgetCalendrier->setGridVisible(
true);
89 QMenu *fileMenu =
new QMenu(tr(
"&Fichier"),
this);
90 menuBar()->addMenu(fileMenu);
91 fileMenu->addAction(tr(
"&Ouvrir un fichier de calendrier"),
this, SLOT(
ouvrirFichier()), QKeySequence::New);
92 fileMenu->addAction(tr(
"&Ouvrir un calendrier avec une URL"),
this, SLOT(
ouvrirURL()), QKeySequence::Open);
93 fileMenu->addAction(tr(
"&Effacer"),
this, SLOT(
effacer()), QKeySequence(tr(
"Suppr",
"Suppression")));
94 fileMenu->addAction(tr(
"&Quitter"), qApp, SLOT(quit()), QKeySequence::Quit);
95 menuBar()->setStyleSheet(
"background-color: rgb(176, 193, 173);");
99 connect(
actionMaximiser, SIGNAL(triggered(
bool)),
this, SLOT(showMaximized()));
100 connect(
actionRestaurer, SIGNAL(triggered(
bool)),
this, SLOT(showNormal()));
101 connect(
actionQuitter, SIGNAL(triggered(
bool)), qApp, SLOT(quit()));
115 QIcon icone(
":/groom.png");
117 setWindowIcon(icone);
137 iconeSysteme->showMessage(titre, message, icone, duree);
153 qDebug() << Q_FUNC_INFO;
156 #ifdef TEST_NOTIFICATION
162 void IHMGroom::testerNotification()
176 uiIHMGroom->boutonRechercherBluetooth->setEnabled(
true);
177 uiIHMGroom->labelEtatConnexion->setText(
"État : déconnecté");
178 uiIHMGroom->boutonConnecterBluetooth->setEnabled(
false);
179 uiIHMGroom->boutonDeconnecterBluetooth->setEnabled(
false);
186 uiIHMGroom->lineEditNom->setPlaceholderText(
"Nom");
187 uiIHMGroom->lineEditPrenom->setPlaceholderText(
"Prénom");
188 uiIHMGroom->lineEditFonction->setPlaceholderText(
"Fonction");
189 uiIHMGroom->zoneTexteMessage->setPlaceholderText(
"Message à afficher");
190 uiIHMGroom->boutonEnvoyerOccupant->setEnabled(
false);
192 uiIHMGroom->lineEditPrenom->setEnabled(
false);
193 uiIHMGroom->lineEditFonction->setEnabled(
false);
195 uiIHMGroom->boutonViderFormulaire->setEnabled(
false);
196 uiIHMGroom->zoneTexteMessage->setEnabled(
false);
197 uiIHMGroom->boutonEnvoyerMessage->setEnabled(
false);
198 uiIHMGroom->boutonRadioLibre->setEnabled(
false);
199 uiIHMGroom->boutonRadioOccupe->setEnabled(
false);
200 uiIHMGroom->boutonRadioAbsent->setEnabled(
false);
201 uiIHMGroom->boutonRadioEntrer->setEnabled(
false);
202 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
false);
203 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
false);
205 uiIHMGroom->boutonAjouterOccupant->setEnabled(
false);
206 uiIHMGroom->boutonEditerOccupant->setEnabled(
false);
207 uiIHMGroom->boutonSupprimerOccupant->setEnabled(
false);
215 uiIHMGroom->boutonRadioEntrer->setEnabled(
false);
217 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
false);
219 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
false);
229 connect(
communicationGroom, SIGNAL(actualiserEtats(
int,
int,
int,
int,
int)),
this, SLOT(
actualiserIndicateurs(
int,
int,
int,
int,
int)));
241 hostURL(
"https://calendar.google.com/calendar/ical/robertutilisateur84%40gmail.com/private-ab9f00fcf91e8c05d89d6e5c8a1234f7/basic.ics");
243 requete.setRawHeader(
"User-Agent",
"CalendarClient_ICS");
244 requete.setRawHeader(
"Depth",
"0");
245 requete.setRawHeader(
"Prefer",
"return-minimal");
246 requete.setRawHeader(
"Content-Type",
"text/xml; charset=utf-8");
247 requete.setRawHeader(
"Content-Length",
"0");
249 QSslConfiguration configuration =
requete.sslConfiguration();
250 configuration.setPeerVerifyMode(QSslSocket::VerifyNone);
251 requete.setSslConfiguration(configuration);
257 connect(
networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(handleHTTPError()));
266 QBuffer buffer(
this);
269 buffer.open(QIODevice::ReadOnly);
273 QString ligne = buffer.readLine();
276 if (ligne.startsWith(
"X-WR-CALNAME"))
278 QString nomCalendrier = ligne.trimmed();
279 nomCalendrier.remove(
";LANGUAGE=fr", Qt::CaseInsensitive);
280 nomCalendrier.remove(
"X-WR-CALNAME:", Qt::CaseInsensitive);
285 while (!buffer.atEnd() && !trouve);
306 qDebug() << Q_FUNC_INFO <<
"Occupant courant" <<
indexOccupant;
310 uiIHMGroom->boutonAjouterOccupant->setEnabled(
true);
311 uiIHMGroom->boutonEditerOccupant->setEnabled(
true);
312 uiIHMGroom->boutonSupprimerOccupant->setEnabled(
true);
326 qDebug() << Q_FUNC_INFO;
327 QString contenuNom =
uiIHMGroom->lineEditNom->text();
328 QString contenuPrenom =
uiIHMGroom->lineEditPrenom->text();
329 QString contenuFonction =
uiIHMGroom->lineEditFonction->text();
331 Occupant nouveau(contenuNom, contenuPrenom, contenuFonction);
347 QSystemTrayIcon::MessageIcon icone = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
365 QString contenuNom =
uiIHMGroom->lineEditNom->text();
366 QString contenuPrenom =
uiIHMGroom->lineEditPrenom->text();
367 QString contenuFonction =
uiIHMGroom->lineEditFonction->text();
379 QSystemTrayIcon::MessageIcon icone = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
412 QString module = nomPeripherique +
" [" + adressePeripherique +
"]";
413 qDebug() << Q_FUNC_INFO << module;
416 if(
uiIHMGroom->listeBluetooth->findText(module) == -1)
419 uiIHMGroom->boutonConnecterBluetooth->setEnabled(
true);
430 qDebug() << Q_FUNC_INFO;
441 qDebug() << Q_FUNC_INFO;
460 qDebug() << Q_FUNC_INFO << nomPeripherique << adressePeripherique;
461 uiIHMGroom->listeBluetooth->setEnabled(
false);
462 uiIHMGroom->boutonRechercherBluetooth->setEnabled(
false);
463 uiIHMGroom->boutonConnecterBluetooth->setEnabled(
false);
464 uiIHMGroom->boutonDeconnecterBluetooth->setEnabled(
true);
465 uiIHMGroom->labelEtatConnexion->setText(
"État : connecté");
467 uiIHMGroom->boutonEnvoyerOccupant->setEnabled(
true);
470 uiIHMGroom->lineEditFonction->setEnabled(
true);
472 uiIHMGroom->boutonViderFormulaire->setEnabled(
true);
473 uiIHMGroom->zoneTexteMessage->setEnabled(
true);
474 uiIHMGroom->boutonEnvoyerMessage->setEnabled(
true);
475 uiIHMGroom->boutonRadioLibre->setEnabled(
true);
476 uiIHMGroom->boutonRadioOccupe->setEnabled(
true);
477 uiIHMGroom->boutonRadioAbsent->setEnabled(
true);
478 uiIHMGroom->boutonRadioEntrer->setEnabled(
true);
479 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
true);
480 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
true);
481 uiIHMGroom->boutonAjouterOccupant->setEnabled(
true);
482 uiIHMGroom->boutonSupprimerOccupant->setEnabled(
true);
483 uiIHMGroom->boutonEditerOccupant->setEnabled(
true);
484 uiIHMGroom->boutonRadioLibre->setChecked(
true);
494 int index =
uiIHMGroom->listeOccupant->currentIndex();
506 qDebug() << Q_FUNC_INFO << nomPeripherique << adressePeripherique;
508 uiIHMGroom->boutonRechercherBluetooth->setEnabled(
true);
509 uiIHMGroom->boutonConnecterBluetooth->setEnabled(
true);
510 uiIHMGroom->boutonDeconnecterBluetooth->setEnabled(
false);
511 uiIHMGroom->labelEtatConnexion->setText(
"État : déconnecté");
513 uiIHMGroom->boutonEnvoyerOccupant->setEnabled(
false);
515 uiIHMGroom->lineEditPrenom->setEnabled(
false);
516 uiIHMGroom->lineEditFonction->setEnabled(
false);
518 uiIHMGroom->boutonViderFormulaire->setEnabled(
false);
519 uiIHMGroom->zoneTexteMessage->setEnabled(
false);
520 uiIHMGroom->boutonEnvoyerMessage->setEnabled(
false);
521 uiIHMGroom->boutonRadioLibre->setEnabled(
false);
522 uiIHMGroom->boutonRadioOccupe->setEnabled(
false);
523 uiIHMGroom->boutonRadioAbsent->setEnabled(
false);
524 uiIHMGroom->boutonRadioEntrer->setEnabled(
false);
525 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
false);
526 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
false);
527 uiIHMGroom->boutonAjouterOccupant->setEnabled(
false);
528 uiIHMGroom->boutonSupprimerOccupant->setEnabled(
false);
529 uiIHMGroom->boutonEditerOccupant->setEnabled(
false);
530 uiIHMGroom->labelEtatSonnette->setText(
"État : ...");
531 uiIHMGroom->labelEtatPresence->setText(
"État : ...");
532 uiIHMGroom->labelSonnette->setAutoFillBackground(
true);
534 uiIHMGroom->boutonRadioAbsent->setChecked(
true);
570 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
true);
571 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
true);
572 uiIHMGroom->boutonRadioEntrer->setEnabled(
true);
595 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
false);
596 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
false);
597 uiIHMGroom->boutonRadioEntrer->setEnabled(
false);
637 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
false);
638 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
false);
639 uiIHMGroom->boutonRadioEntrer->setEnabled(
false);
679 uiIHMGroom->boutonPoussoirSonnette->setEnabled(
false);
680 uiIHMGroom->boutonActiverDesactiverPresence->setEnabled(
false);
763 QStringList listeChamps = trame.split(
";");
764 QString chaineChampMessage = listeChamps[1];
765 QString nouvelleChaineChampMessage = chaineChampMessage.remove(
'\n');
767 if(listeChamps[1] !=
"\r\n")
769 uiIHMGroom->labelAffichageMessageOccupant->setText(
"Message affiché : \"" + nouvelleChaineChampMessage +
"\"");
771 else if(listeChamps[1] ==
"\r\n")
773 uiIHMGroom->labelAffichageMessageOccupant->setText(
"Aucun message affiché");
786 QString nomFichier = QApplication::applicationDirPath() +
"/parametres.ini";
787 qDebug() << Q_FUNC_INFO << nomFichier;
788 QSettings settings(nomFichier, QSettings::IniFormat);
790 int nbOccupants = settings.value(
"NbOccupants", 0).toInt();
791 qDebug() << Q_FUNC_INFO <<
"NbOccupants" << nbOccupants;
793 qDebug() << Q_FUNC_INFO <<
"Occupant courant" <<
indexOccupant;
796 for(
int i = 0; i < nbOccupants; i++)
798 QString nomOccupant =
"Occupant" + QString::number(i+1);
799 settings.beginGroup(nomOccupant);
800 qDebug() << Q_FUNC_INFO << nomOccupant << settings.value(
"Nom").toString() << settings.value(
"Prenom").toString() << settings.value(
"Fonction").toString();
802 occupant.
nom = settings.value(
"Nom").toString();
803 occupant.
prenom = settings.value(
"Prenom").toString();
804 occupant.
fonction = settings.value(
"Fonction").toString();
820 QString nomFichier = QApplication::applicationDirPath() +
"/parametres.ini";
821 qDebug() << Q_FUNC_INFO << nomFichier;
822 QSettings settings(nomFichier, QSettings::IniFormat);
824 qDebug() << Q_FUNC_INFO <<
occupants.size();
825 for(
int i = 0; i <
occupants.size(); i++)
827 QString nomOccupant =
"Occupant" + QString::number(i+1);
828 settings.beginGroup(nomOccupant);
829 settings.setValue(
"Nom",
occupants[i].nom);
830 settings.setValue(
"Prenom",
occupants[i].prenom);
831 settings.setValue(
"Fonction",
occupants[i].fonction);
834 settings.setValue(
"NbOccupants",
occupants.size());
846 uiIHMGroom->listeBluetooth->setEnabled(
false);
847 uiIHMGroom->boutonRechercherBluetooth->setEnabled(
false);
848 uiIHMGroom->boutonConnecterBluetooth->setEnabled(
false);
849 uiIHMGroom->boutonDeconnecterBluetooth->setEnabled(
false);
850 uiIHMGroom->labelEtatConnexion->setText(
"État : déconnecté");
863 uiIHMGroom->boutonRechercherBluetooth->setEnabled(
true);
865 uiIHMGroom->boutonConnecterBluetooth->setEnabled(
true);
866 uiIHMGroom->boutonDeconnecterBluetooth->setEnabled(
false);
867 uiIHMGroom->labelEtatConnexion->setText(
"État : déconnecté");
879 for(
int i = 0; i <
occupants.size(); i++)
884 uiIHMGroom->listeOccupant->setCurrentIndex(i);
906 uiIHMGroom->labelEtatOccupant->setText(
"État : libre");
909 uiIHMGroom->labelEtatOccupant->setText(
"État : absent");
912 uiIHMGroom->labelEtatOccupant->setText(
"État : occupé");
925 QSystemTrayIcon::MessageIcon icone = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
939 QSystemTrayIcon::MessageIcon icone = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
951 uiIHMGroom->labelEtatSonnette->setText(
"État : désactivé");
955 uiIHMGroom->labelEtatSonnette->setText(
"État : activé");
967 uiIHMGroom->labelEtatPresence->setText(
"État : désactivé");
970 uiIHMGroom->labelEtatPresence->setText(
"État : activé");
996 if (fileName.isNull())
997 fileName = QFileDialog::getOpenFileName(
this, tr(
"Ouvrir le fichier"),
"", tr(
"Fichiers iCal (*.ics)"));
999 if (!fileName.isEmpty())
1002 fileName.prepend(
"file://");
1016 QString url = QInputDialog::getText(
this, tr(
"Ouvrir un calendrier avec une URL"), tr(
"URL :"), QLineEdit::Normal,
"", &ok);
1018 if (ok && !url.isEmpty())
1024 uiIHMGroom->labelAffichageEvenements->clear();
1085 qDebug() << __FUNCTION__ << date;
1090 qDebug() << __FUNCTION__ << evt;
1092 QString dtEnd = evt.getAttribut(
"dtend");
1096 QDateTime dts = QDateTime(debutEvenement.date(), debutEvenement.time(), Qt::UTC);
1097 qDebug() << dts.toTimeZone(QTimeZone(
"Europe/Paris"));
1098 QDateTime dte = QDateTime(finEvenement.date(), finEvenement.time(), Qt::UTC);
1099 qDebug() << dte.toTimeZone(QTimeZone(
"Europe/Paris"));
1103 qDebug() << Q_FUNC_INFO <<
"summary" << evt.getAttribut(
"summary");
1105 qDebug() << Q_FUNC_INFO <<
"dtstart" << dtStart << dts.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"HH:mm");
1106 if(dts.toTimeZone(QTimeZone(
"Europe/Paris")).time().minute() == 0)
1108 qDebug() << Q_FUNC_INFO <<
"dtstart" << dtStart << dts.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'");
1109 uiIHMGroom->evenement->append(
"L'événement \"" + evt.getAttribut(
"summary") +
"\" est noté du " + date.toString(
"dd/MM/yyyy") +
" de " + dts.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'"));
1113 qDebug() << Q_FUNC_INFO <<
"dtstart" << dtStart << dts.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'mm");
1114 uiIHMGroom->evenement->append(
"L'événement \"" + evt.getAttribut(
"summary") +
"\" est noté du " + date.toString(
"dd/MM/yyyy") +
" de " + dts.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'mm"));
1117 qDebug() << Q_FUNC_INFO <<
"dtend" << dtStart << dte.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"HH:mm");
1118 if(dte.toTimeZone(QTimeZone(
"Europe/Paris")).time().minute() == 0)
1120 qDebug() << Q_FUNC_INFO <<
"dtend" << dtStart << dte.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'");
1121 uiIHMGroom->evenement->append(
" à " + dte.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'") +
".");
1125 qDebug() << Q_FUNC_INFO <<
"dtend" << dtStart << dte.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'mm");
1126 uiIHMGroom->evenement->append(
" à " + dte.toTimeZone(QTimeZone(
"Europe/Paris")).toString(
"h'h'mm") +
".");
1131 qDebug() << Q_FUNC_INFO <<
"dtstart" << dtStart <<
"Erreur conversion !";