-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloopdialog.cpp
56 lines (46 loc) · 1.15 KB
/
loopdialog.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
#include "loopdialog.h"
#include "ui_loopdialog.h"
#include <QDebug>
#include <QThread>
LoopDialog::LoopDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::LoopDialog)
{
ui->setupUi(this);
}
LoopDialog::~LoopDialog()
{
delete ui;
}
void LoopDialog::accept()
{
qDebug() << "Accept Clicked";
parseLines();
}
void LoopDialog::parseLines()
{
cmdLines = ui->commands_edit->toPlainText().split("\n");
unsigned int delay = ui->delay_box->value();
unsigned int stepDelay = 0;
for (int i=0;i<ui->iteration_box->value();i++)
{
for (auto &cmd: cmdLines)
{
if (cmd.contains(".sleep"))
{
stepDelay = cmd.split(".sleep ")[1].toInt();
qDebug() << "Sleeping for "<< stepDelay<< "ms";
QThread::msleep(stepDelay);
}
else
{
emit sendCmd(cmd);
qDebug() << cmd;
}
}
ui->progressBar->setValue(int(double(i)/double(ui->iteration_box->value())*100));
QThread::msleep(delay);
}
ui->progressBar->setValue(0);
hide();
}