-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
105 lines (85 loc) · 2.45 KB
/
mainwindow.cpp
File metadata and controls
105 lines (85 loc) · 2.45 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "alarmdialog.h"
#include <QMessageBox>
#include <QInputDialog>
#include <QTime>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->customInterval = 0;
this->customArmed = false;
ui->btn10m->setProperty("m_interval", 600);
ui->btn20m->setProperty("m_interval", 1200);
timer = new QTimer();
connect(timer, SIGNAL(timeout()),
ui->btn10m, SLOT(tick()));
connect(timer, SIGNAL(timeout()),
ui->btn20m, SLOT(tick()));
connect(timer, SIGNAL(timeout()),
this, SLOT(tick()));
connect(ui->btn10m, SIGNAL(alarm()),
this, SLOT(onAlarm()));
connect(ui->btn20m, SIGNAL(alarm()),
this, SLOT(onAlarm()));
timer->start(1000);
this->setWindowFlags(Qt::WindowStaysOnTopHint);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::tick()
{
if (customArmed && (customInterval > 0))
{
customInterval--;
QTime curTime(0,0,0,0);
curTime = curTime.addSecs(customInterval);
curTime.addMSecs(customInterval);
ui->btnCustom->setText(curTime.toString("hh:mm:ss"));
}
else
{
customInterval = 0;
ui->btnCustom->setText(tr("Свое"));
// QTime curTime(0,0,0,0);
// curTime = curTime.addSecs(customInterval);
// ui->btnCustom->setText(curTime.toString("hh:mm:ss"));
if (customArmed)
{
customArmed = false;
onAlarm();
}
}
}
void MainWindow::on_btnExit_clicked()
{
this->close();
}
void MainWindow::onAlarm()
{
//QMessageBox::StandardButton alrmDialog;
//alrmDialog = QMessageBox::information(this, tr("Alarm"), tr("Alarm"));
AlarmDialog* alrmDlg = new AlarmDialog(this);
alrmDlg->showFullScreen();
}
void MainWindow::on_btnCustom_clicked()
{
if (customArmed)
{
customArmed = false;
}
else
{
this->customInterval = 60 * QInputDialog::getInt(this, tr("Введите количество минут"),
tr("Количество минут"),
0, 0, 120);
if (customInterval > 0 )
{
this->customArmed = true;
}
}
}