diff options
author | Manuel Schneider | 2013-12-02 12:24:53 +0100 |
---|---|---|
committer | Manuel Schneider | 2013-12-02 12:24:53 +0100 |
commit | 70f3d788a43072ee4f10c3a67cc92fbb2bff5eee (patch) | |
tree | d8141c7d27011270e7867f8dae5812d8a4ef978a /src/timeoutdialog.cpp | |
parent | [Experimental] Button works fine now. (diff) | |
download | beamergui-70f3d788a43072ee4f10c3a67cc92fbb2bff5eee.tar.gz beamergui-70f3d788a43072ee4f10c3a67cc92fbb2bff5eee.tar.xz beamergui-70f3d788a43072ee4f10c3a67cc92fbb2bff5eee.zip |
[Experimental] Timeout + revert functionality
Diffstat (limited to 'src/timeoutdialog.cpp')
-rw-r--r-- | src/timeoutdialog.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/timeoutdialog.cpp b/src/timeoutdialog.cpp new file mode 100644 index 0000000..5a76504 --- /dev/null +++ b/src/timeoutdialog.cpp @@ -0,0 +1,40 @@ +#include "timeoutdialog.h" +#include <iostream> +#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("%v seconds"); + qbar->setMaximum(_time); + qbar->setMinimum(0); + qbar->setValue(_time); + qbar->setLayoutDirection(Qt::RightToLeft); + setBar(qbar); + _timer.start(1000); +} + +//___________________________________________________________________________ +void TimeOutDialog::update() +{ + if (_time == 0) { + _timer.stop(); + accept(); + } + else + setValue(_time); + --_time; +} + +//___________________________________________________________________________ +void TimeOutDialog::cancel() +{ + _timer.stop(); +} |