-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangetimerdialog.cpp
More file actions
68 lines (48 loc) · 1.8 KB
/
changetimerdialog.cpp
File metadata and controls
68 lines (48 loc) · 1.8 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
#include "changetimerdialog.h"
#include "ui_changetimerdialog.h"
#include <QTime>
#include <QFile>
#include <QLineEdit>
ChangeTimerDialog::ChangeTimerDialog(TimerWidget *parent) :
QDialog(parent),
ui(new Ui::ChangeTimerDialog)
{
ui->setupUi(this);
WidgetSettings timerSettings = parent->getSettings();
addSounds(ui->SoundBox);
QFile file(":/stylesheet.qss");
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
this->setStyleSheet(file.readAll());
file.close();
}
par = parent;
ui->timerName->setText(timerSettings.name);
ui->interval->setTime(QTime::fromMSecsSinceStartOfDay(parent->getTimerDuration()));
ui->SoundBox->setCurrentIndex(ui->SoundBox->findData(QVariant(timerSettings.signalPath)));
connect(ui->changeButton, SIGNAL(clicked()), this, SLOT(changeTimerAndQuit()));
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
// Validation for text field.
QRegExp rx("[A-Z,a-z,0-9, ]{1,19}");
QValidator *validator = new QRegExpValidator(rx, this);
ui->timerName->setValidator(validator);
}
ChangeTimerDialog::~ChangeTimerDialog()
{
delete ui;
}
void ChangeTimerDialog::updateWidget(GlobalSettings _globalSettings)
{
globalSettings = std::move(_globalSettings);
ui->interval->setDisplayFormat(globalSettings.timerTimeFormat);
}
void ChangeTimerDialog::changeTimerAndQuit()
{
int elpasedTime = ui->interval->time().hour()*3600*1000+
ui->interval->time().minute()*60*1000+
ui->interval->time().second()*1000;
//par->setTimerDuration(elpasedTime);
//par->setTimerName(ui->timerName->text());
emit changeTimerSignal(WidgetSettings(elpasedTime,ui->timerName->text(),true,ui->SoundBox->itemData(ui->SoundBox->currentIndex()).toString()));
this->close();
}