summaryrefslogtreecommitdiffstats
path: root/src/timeoutdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/timeoutdialog.cpp')
-rw-r--r--src/timeoutdialog.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/timeoutdialog.cpp b/src/timeoutdialog.cpp
index f9787fb..6f12ca2 100644
--- a/src/timeoutdialog.cpp
+++ b/src/timeoutdialog.cpp
@@ -2,47 +2,47 @@
// Author: Manuel Schneider <ms1144>
#include "timeoutdialog.h"
+#include "ui_timeoutdialog.h"
#include <QProgressBar>
#include <QDebug>
+#include <QPushButton>
TimeOutDialog::TimeOutDialog(int time, QWidget *parent)
- : QProgressDialog(parent), _time(time)
+ : QDialog(parent), _ui(new Ui::TimeOutDialog), _time(time)
{
- QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
- QObject::connect(this, SIGNAL(canceled()), this, SLOT(cancel()));
-
+ _ui->setupUi(this);
+ QObject::connect(&_timer, &QTimer::timeout, this, &TimeOutDialog::update);
+ QObject::connect(_ui->buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton *button) {
+ _timer.stop();
+ if (button == _ui->buttonBox->button(QDialogButtonBox::Discard)) {
+ _time = 0;
+ }
+ });
+ QObject::connect(_ui->buttonBox, &QDialogButtonBox::rejected, [this]() {
+ _timer.stop();
+ _time = 0; // So wasCanceled() returns true
+ });
// 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);
+ _ui->progressBar->setMaximum(_time);
+ _ui->progressBar->setValue(_time);
+ setWindowTitle(" ");
+ setWindowFlag(Qt::WindowStaysOnTopHint, true);
_timer.start(1000);
}
void TimeOutDialog::hideEvent(QHideEvent *e)
{
- QProgressDialog::hideEvent(e);
+ QDialog::hideEvent(e);
_timer.stop();
}
-//___________________________________________________________________________
void TimeOutDialog::update()
{
--_time;
if (_time == 0) {
_timer.stop();
- accept();
} else {
- setValue(_time);
+ _ui->progressBar->setValue(_time);
}
}
-
-
-//___________________________________________________________________________
-void TimeOutDialog::cancel()
-{
- _timer.stop();
-}