Browse Source

Ajout d'une sonnerie de fin de temps

François Drouhard 6 years ago
parent
commit
ec7b0a68e5
6 changed files with 21 additions and 4 deletions
  1. 4 0
      ChronoCheckMate.pro
  2. 5 3
      Chronometre.cpp
  3. 1 1
      Dialog.cpp
  4. 6 0
      MaFenetre.cpp
  5. 5 0
      ressources.qrc
  6. BIN
      ressources/sonnette.wav

+ 4 - 0
ChronoCheckMate.pro

@@ -6,6 +6,7 @@ TEMPLATE = app
 TARGET = ChronoCheckMate
 INCLUDEPATH += .
 QT += widgets
+QT += multimedia
 
 # The following define makes your compiler warn you if you use any
 # feature of Qt which has been marked as deprecated (the exact warnings
@@ -25,3 +26,6 @@ HEADERS += Chronometre.h MaFenetre.h \
 SOURCES += Chronometre.cpp MaFenetre.cpp main.cpp \
     Dialog.cpp \
     options.cpp
+
+RESOURCES += \
+    ressources.qrc

+ 5 - 3
Chronometre.cpp

@@ -29,11 +29,12 @@
 #include <QDebug>
 #include <QFont>
 #include <QTime>
+#include <QSound>
 
 Chronometre::Chronometre (const QString & nom , int tempsDepart, QWidget * parent = nullptr) :
     QGroupBox (nom , parent),
-    ms(1000*60*tempsDepart),
-    msTempsDepart(1000*60*tempsDepart)
+    ms(0),
+    msTempsDepart(0)
 {
     setFlat(false);
 
@@ -62,12 +63,13 @@ void Chronometre::modifierNomJoueur(QString joueur) {
 }
 
 void Chronometre::definirTemps(int tempsDepart) {
-    msTempsDepart = tempsDepart*60*1000;
+    msTempsDepart = tempsDepart*1000;
 }
 
 void Chronometre::refresh () {
     ms -= 10;
     if (ms <= 0) {
+        QSound::play(":/ressources/sonnette.wav");
         emit fin();
     }
 	affichage ();

+ 1 - 1
Dialog.cpp

@@ -16,7 +16,7 @@ Dialog::Dialog(Options *option, QWidget *parent) :
     QDialogButtonBox *boutonJouer = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
     QLabel *labelTempsDepart= new QLabel("Temps départ (minutes)");
     spinTempsDepart     = new QSpinBox;
-    spinTempsDepart->setMinimum(0);
+    spinTempsDepart->setMinimum(1);
     spinTempsDepart->setMaximum(300);
     spinTempsDepart->setValue(option->tempsDepart());
     joueur1LineEdit = new QLineEdit(option->nomJoueur1() , this);

+ 6 - 0
MaFenetre.cpp

@@ -145,6 +145,12 @@ void MaFenetre::arreter () {
 	chrono2->stop();
 	marche = false;
     etatBoutons (true , false);
+    /*
+    QMessageBox message;
+    message.setText("Le joueur bidule a gagné");
+    message.setStandardButtons(QMessageBox::Ok);
+    message.exec();
+    */
 }
 
 void MaFenetre::init () {

+ 5 - 0
ressources.qrc

@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>ressources/sonnette.wav</file>
+    </qresource>
+</RCC>

BIN
ressources/sonnette.wav