summaryrefslogblamecommitdiffstats
path: root/src/timeoutdialog.cpp
blob: 418d791a41f580467acbca47d3554635d2df2ff7 (plain) (tree)
1
2
3
4
5
6


                                          
                          

                       








                                                                     
                                        


                          



                     
 











                                                                             
 




                                                                             
// Copyright 2013, University of Freiburg,
// Author: Manuel Schneider <ms1144>

#include "timeoutdialog.h"
#include <QProgressBar>

TimeOutDialog::TimeOutDialog(int time, QWidget *parent)
  : QProgressDialog(parent), _time(time)
{
  QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
  QObject::connect(this, SIGNAL(canceled()), this, SLOT(cancel()));


  // QProgressDialog takes ownership of QProgressBar
  QProgressBar *qbar = new QProgressBar(this);
  qbar->setFormat(trUtf8("%v seconds"));
  qbar->setMaximum(_time);
  qbar->setMinimum(0);
  qbar->setValue(_time);
  setBar(qbar);
  _timer.start(1000);
}


//___________________________________________________________________________
void TimeOutDialog::update()
{
  if (_time == 0) {
    _timer.stop();
    accept();
  }
  else
    setValue(_time);
  --_time;
}


//___________________________________________________________________________
void TimeOutDialog::cancel()
{
  _timer.stop();
}