Chronometre.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Chronometre.h
  3. * This file is part of ChronoCheckMate
  4. *
  5. * Copyright (C) 2010 - François Drouhard
  6. *
  7. * ChronoCheckMate is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * ChronoCheckMate is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with ChronoCheckMate; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301 USA
  21. */
  22. #ifndef DEF_CHRONOMETRE
  23. #define DEF_CHRONOMETRE
  24. #include <QWidget>
  25. #include <QTime>
  26. class QGroupBox;
  27. class QLabel;
  28. class QHBoxLayout;
  29. class QTimer;
  30. class QString;
  31. class QPixmap;
  32. #define INTERVAL 1 // vitesse de défilement (1000ème de secondes)
  33. enum Couleur {
  34. Blanc,
  35. Noir,
  36. };
  37. enum Placement {
  38. Gauche,
  39. Droite
  40. };
  41. class Chronometre : public QWidget {
  42. Q_OBJECT
  43. public:
  44. Chronometre (const QString & nom , Couleur unecouleur, QTime const& tempsDepart, Placement placement = Placement::Gauche, QWidget * parent = nullptr);
  45. void start ();
  46. void stop ();
  47. void affichage ();
  48. void reinit ();
  49. void basculer ();
  50. void basculer (Chronometre & Chrono);
  51. void echangerCouleur (Chronometre & chrono);
  52. void setCouleur (Couleur const& color);
  53. Couleur getCouleur () const;
  54. void modifierNomJoueur (QString const& joueur);
  55. void definirTemps (QTime const& tempsDepart);
  56. void addSecs (unsigned int secondes);
  57. QString nomJoueur () const;
  58. signals:
  59. void fin(Chronometre *chrono);
  60. void won(Chronometre * chrono);
  61. void is_paused(Chronometre *chrono);
  62. public slots:
  63. void declareGagnant();
  64. protected slots:
  65. void refresh ();
  66. private:
  67. QLabel *labelPion;
  68. Couleur couleur;
  69. QGroupBox *groupBox;
  70. QPixmap *pion;
  71. QTime temps;
  72. QTime msTempsDepart;
  73. QTimer *timer;
  74. QHBoxLayout *ecranLayout;
  75. QLabel *ecranTemps;
  76. };
  77. #endif