-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewcomputationwindow.cpp
More file actions
92 lines (66 loc) · 2.14 KB
/
newcomputationwindow.cpp
File metadata and controls
92 lines (66 loc) · 2.14 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
#include "newcomputationwindow.h"
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QIntValidator>
#include <QHBoxLayout>
#include <QVBoxLayout>
NewComputationWindow::NewComputationWindow(QMainWindow *parent) :
QMainWindow(parent), k(0), l(0)
{
this->setWindowTitle(tr("New computation"));
labelInfo = new QLabel(this);
labelInfo->setText(tr("Choose parameters for your computation:"));
labelK = new QLabel(this);
labelK->setText(tr("k"));
labelL = new QLabel(this);
labelL->setText(tr("l"));
editK = new QLineEdit(this);
editK->setText("0");
editL = new QLineEdit(this);
editL->setText("0");
QIntValidator* v = new QIntValidator(editK);
v->setBottom(0);
editK->setValidator(v);
editL->setValidator(v);
QObject::connect(editL, SIGNAL(textChanged(QString)), this, SLOT(setL()));
QObject::connect(editK, SIGNAL(textChanged(QString)), this, SLOT(setK()));
ok = new QPushButton(tr("&OK"), this);
QObject::connect(ok, SIGNAL(clicked()), this, SLOT(createComputation()));
cancel = new QPushButton(tr("&Cancel"), this);
QObject::connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *layoutInfo = new QHBoxLayout();
layoutInfo->addWidget(labelInfo);
QHBoxLayout *layoutK = new QHBoxLayout();
layoutK->addWidget(labelK);
layoutK->addWidget(editK);
QHBoxLayout *layoutL = new QHBoxLayout();
layoutL->addWidget(labelL);
layoutL->addWidget(editL);
QHBoxLayout *layoutButtons = new QHBoxLayout();
layoutButtons->addWidget(ok);
layoutButtons->addWidget(cancel);
QVBoxLayout *layout = new QVBoxLayout();
layout->addLayout (layoutInfo);
layout->addLayout (layoutK);
layout->addLayout (layoutL);
layout->addLayout(layoutButtons);
QWidget *q = new QWidget();
setCentralWidget(q);
q->setLayout(layout);
}
void NewComputationWindow::createComputation()
{
if(k > 0 && l > 0) {
emit computationCreated(k, l);
}
close();
}
void NewComputationWindow::setK()
{
k = editK->text().toInt();
}
void NewComputationWindow::setL()
{
l = editL->text().toInt();
}