Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "window.h"
- #include <Qsound>
- int tempsMinutes=0;
- int tempsSecondes=0;
- bool enCours=false;
- double i=0;
- MaFenetre::MaFenetre() : QWidget()
- {
- setFixedSize(250, 300);
- m_bouton = new QPushButton("Commencer", this);
- m_bouton->setCursor(Qt::PointingHandCursor);
- m_bouton->setGeometry(35, 250, 180, 50);
- connect(m_bouton, SIGNAL(clicked()), this, SLOT(start()));
- m_progressbar= new QProgressBar(this);
- m_progressbar->setGeometry(50, 180, 180, 30);
- m_spinbox = new QSpinBox(this);
- m_spinbox -> setGeometry(35, 30, 180, 30);
- m_spinbox-> setMaximum(3600);
- m_spinbox-> setAccelerated(true);
- m_spinbox-> setMaximum(120);
- m_spinbox-> setMinimum(1);
- m_spinbox-> setSuffix (" minute(s)");
- QLabel *label = new QLabel("Avancement vers le prochain TR: ", this);
- label->move(50,155);
- QLabel *label2 = new QLabel("Temps entre les TRs:", this);
- label2->move(35,15);
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
- timer->start(100);
- }
- void MaFenetre::start()
- {
- static bool dejaClique =false;
- if(dejaClique==false)
- {
- enCours=true;
- tempsMinutes = m_spinbox->value();
- tempsSecondes = tempsMinutes*60;
- dejaClique=true;
- m_bouton->setText("Reset");
- }
- else
- {
- enCours=false;
- dejaClique=false;
- m_progressbar->setValue(0);
- i=0;
- m_bouton->setText("Recommencer");
- }
- }
- void MaFenetre::update()
- {
- static int prct;
- if(enCours)
- {
- prct = (i*100)/tempsSecondes;
- m_progressbar->setValue(prct);
- i+=0.1;
- }
- if(prct>100)
- {
- m_progressbar->setValue(0);
- i=0;
- QSound::play("sounds/firealarm.wav");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement