]>
git.mar77i.info Git - bigintmandel/blob - settingswidget.h
5 * This file is covered by the LICENSE file in the root of this project.
8 #ifndef SETTINGSWIDGET_H
9 #define SETTINGSWIDGET_H
16 #include "uint64validator.h"
18 template <typename T
> class TypedLineEdit
;
20 template <> class TypedLineEdit
<quint64
> : public QLineEdit
{
22 explicit TypedLineEdit(QWidget
*parent
= nullptr) : QLineEdit(parent
) {
23 setValidator(new UInt64Validator(this));
25 inline void set_value(const quint64
&value
) {
26 setText(QString::number(value
));
28 inline quint64
get_value() const { return text().toULongLong(); }
31 template <> class TypedLineEdit
<int> : public QLineEdit
{
33 explicit TypedLineEdit(QWidget
*parent
= nullptr) : QLineEdit(parent
) {
34 setValidator(new QIntValidator(this));
36 inline void set_value(const int &value
) {
37 setText(QString::number(value
));
39 inline int get_value() const { return text().toInt(); }
42 template <> class TypedLineEdit
<mpz_class
> : public QLineEdit
{
44 explicit TypedLineEdit(QWidget
*parent
= nullptr) : QLineEdit(parent
) {
45 QRegularExpression
number_re("^-?\\d+$");
46 setValidator(new QRegularExpressionValidator(number_re
, this));
48 inline void set_value(const mpz_class
&value
) {
49 setText(QString::fromStdString(value
.get_str()));
51 inline mpz_class
get_value() const {
52 return mpz_class(text().toStdString());
56 class SettingsWidget
: public QDialog
{
60 TypedLineEdit
<quint64
> *max_iter
;
61 TypedLineEdit
<int> *width
, *height
;
62 TypedLineEdit
<mpz_class
> *center_f_x
, *center_f_y
, *one
;
63 QCheckBox
*clear_image
;
67 explicit SettingsWidget(QWidget
*parent
= nullptr);
68 void update_params(const MandelParams
¶ms
);
69 void reset_params_fields();
70 bool are_params_fields_changed();
71 inline const quint64
get_max_iter() const {
72 return max_iter
->get_value();
74 MandelParams
get_params() const;
75 inline bool is_clear_image_checked() const {
76 return clear_image
->isChecked();
84 #endif // SETTINGSWIDGET_H