/* * settingswidget.h * * This file is covered by the LICENSE file in the root of this project. */ #ifndef SETTINGSWIDGET_H #define SETTINGSWIDGET_H #include #include #include #include "mandel.h" #include "uint64validator.h" template class TypedLineEdit; template <> class TypedLineEdit : public QLineEdit { public: explicit TypedLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) { setValidator(new UInt64Validator(this)); } inline void set_value(const quint64 &value) { setText(QString::number(value)); } inline quint64 get_value() const { return text().toULongLong(); } }; template <> class TypedLineEdit : public QLineEdit { public: explicit TypedLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) { setValidator(new QIntValidator(this)); } inline void set_value(const int &value) { setText(QString::number(value)); } inline int get_value() const { return text().toInt(); } }; template <> class TypedLineEdit : public QLineEdit { public: explicit TypedLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) { QRegularExpression number_re("^-?\\d+$"); setValidator(new QRegularExpressionValidator(number_re, this)); } inline void set_value(const mpz_class &value) { setText(QString::fromStdString(value.get_str())); } inline mpz_class get_value() const { return mpz_class(text().toStdString()); } }; class SettingsWidget : public QDialog { Q_OBJECT MandelParams orig; TypedLineEdit *max_iter; TypedLineEdit *width, *height; TypedLineEdit *center_f_x, *center_f_y, *one; QCheckBox *clear_image; bool updating; public: explicit SettingsWidget(QWidget *parent = nullptr); void update_params(const MandelParams ¶ms); void reset_params_fields(); bool are_params_fields_changed(); inline const quint64 get_max_iter() const { return max_iter->get_value(); } MandelParams get_params() const; inline bool is_clear_image_checked() const { return clear_image->isChecked(); } public Q_SLOTS: void update_form(); void reset_form(); }; #endif // SETTINGSWIDGET_H