]>
git.mar77i.info Git - bigintmandel/blob - settingswidget.cpp
7 #include <QIntValidator>
9 #include "settingswidget.h"
11 SettingsWidget::SettingsWidget(QWidget
*parent
)
13 max_iter(new QLineEdit("", this)),
14 width(new QLineEdit("", this)),
15 height(new QLineEdit("", this)),
16 center_f_x(new QLineEdit("", this)),
17 center_f_y(new QLineEdit("", this)),
18 one(new QLineEdit("", this))
20 static QStringList labels
= {
21 "max_iter", "width", "height", "x", "y", "one"
23 static QList
<QLineEdit
*> line_edits
= {
24 max_iter
, width
, height
, center_f_x
, center_f_y
, one
26 QPushButton
*apply_button
= new QPushButton("Apply");
27 QGridLayout
*grid_layout
= new QGridLayout(this);
29 setLayout(grid_layout
);
30 for (i
= 0; i
< line_edits
.size(); i
++) {
31 grid_layout
->addWidget(new QLabel(labels
[i
], this), i
, 0);
33 line_edits
[i
]->setValidator(
34 new QIntValidator(0, INT_MAX
, line_edits
[i
])
37 line_edits
[i
]->setReadOnly(true);
38 line_edits
[i
]->setMinimumWidth(256);
39 grid_layout
->addWidget(line_edits
[i
], i
, 1);
43 &QPushButton::clicked
,
45 &SettingsWidget::apply
47 grid_layout
->addWidget(apply_button
, i
, 1);
50 void SettingsWidget::update_fields(
51 const MandelParams
¶ms
, const bool is_finished
53 QSize size
= params
.get_size();
54 MpzPoint center_f
= params
.get_center_f();
55 max_iter
->setText(QString::number(params
.get_max_iter()));
56 width
->setText(QString::number(size
.width()));
57 height
->setText(QString::number(size
.height()));
58 center_f_x
->setText(QString::fromStdString(center_f
.get_x().get_str()));
59 center_f_y
->setText(QString::fromStdString(center_f
.get_y().get_str()));
60 one
->setText(QString::fromStdString(params
.get_one().get_str()));
61 set_finished(is_finished
);
64 void SettingsWidget::apply() {