-
Notifications
You must be signed in to change notification settings - Fork 0
/
fusinvform.cpp
72 lines (59 loc) · 1.5 KB
/
fusinvform.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "fusinvform.h"
#include "ui_fusinvform.h"
#include <iostream>
#include <QTimer>
FusInvForm::FusInvForm(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::FusInvForm)
{
this->timeout = 0;
ui->setupUi(this);
/* QMenu *qmenu = new QMenu();
qmenu->addAction("Dans 2 heures");
qmenu->addAction("Dans 4 heures");
qmenu->addAction("Dans 8 heures");
ui->pushCancel->setMenu(qmenu); */
}
FusInvForm::~FusInvForm()
{
delete ui;
}
void FusInvForm::setType(QString type) {
if (type == QString("info")) {
ui->pushCancel->hide();
}
}
void FusInvForm::setTimeout(QString timeout) {
if (timeout.toInt()>0) {
this->timeout = timeout.toInt();
ui->textEdit->setText(timeout);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeoutStatus()));
timer->start(1000);
}
}
void FusInvForm::setMsg(QString msg) {
ui->textEdit->setText(msg);
}
void FusInvForm::setTitle(QString title) {
this->setWindowTitle(title);
}
void FusInvForm::on_pushCancel_pressed()
{
std::cout<<"cancel"<<std::endl;
QApplication::exit(0);
}
void FusInvForm::on_pushOk_pressed()
{
std::cout<<"ok"<<std::endl;
QApplication::exit(0);
}
void FusInvForm::updateTimeoutStatus()
{
QString pattern = "Ok (%1)";
ui->pushOk->setText(pattern.arg(this->timeout--));
if (this->timeout == 0) {
std::cout<<"timeout"<<std::endl;
QApplication::exit(0);
}
}