diff --git a/TODO b/TODO index 924e0ab..d907b6a 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ Technology Preview 2 : - Finalize Preetham's model usage - => Update all fields when "auto from daytime" is selected => Apply model to atmosphere (aerial perspective) => Find a proper model for night sky (maybe Shirley) - InputInt doesn't honor small_step. diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index e3f9764..702ec37 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -176,7 +176,7 @@ void BaseForm::revertConfig() } updatePreviews(); - configChangeEvent(); + //configChangeEvent(); button_apply->setEnabled(false); button_revert->setEnabled(false); diff --git a/gui_qt/formsky.cpp b/gui_qt/formsky.cpp index a82d5e0..fa6d913 100644 --- a/gui_qt/formsky.cpp +++ b/gui_qt/formsky.cpp @@ -144,5 +144,11 @@ void FormSky::applyConfig() void FormSky::configChangeEvent() { skyValidateDefinition(&_definition); + + if (_definition.model == SKY_MODEL_CUSTOM && _definition.model_custom.auto_from_daytime) + { + BaseForm::revertConfig(); + } + BaseForm::configChangeEvent(); } diff --git a/gui_qt/inputdouble.cpp b/gui_qt/inputdouble.cpp index 60234ac..39b2226 100644 --- a/gui_qt/inputdouble.cpp +++ b/gui_qt/inputdouble.cpp @@ -4,50 +4,55 @@ #include "math.h" InputDouble::InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step): - BaseInput(form, label), - value(value), min(min), max(max), small_step(small_step), large_step(large_step) + BaseInput(form, label) { - slider = new QSlider(form); + _value = value; + _min = min; + _max = max; + _small_step = small_step; + _large_step = large_step; + + _slider = new QSlider(form); - slider->setOrientation(Qt::Horizontal); - slider->setMinimumWidth(200); - slider->setMaximumWidth(400); + _slider->setOrientation(Qt::Horizontal); + _slider->setMinimumWidth(200); + _slider->setMaximumWidth(400); - slider->setMinimum(0); - slider->setMaximum(round((max - min) / small_step)); - slider->setValue(round((*value - min) / small_step)); + _slider->setMinimum(0); + _slider->setMaximum(round((max - min) / small_step)); + _slider->setValue(round((*value - min) / small_step)); - slider->setTickInterval(round(large_step / small_step)); - slider->setTickPosition(QSlider::TicksBelow); + _slider->setTickInterval(round(large_step / small_step)); + _slider->setTickPosition(QSlider::TicksBelow); - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); + connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); _preview = new QLabel(form); ((QLabel*)_preview)->setAlignment(Qt::AlignCenter); - _control = slider; + _control = _slider; } void InputDouble::updatePreview() { - ((QLabel*)_preview)->setText(QString::number(*value, 'g', 3)); + ((QLabel*)_preview)->setText(QString::number(*_value, 'g', 3)); BaseInput::updatePreview(); } void InputDouble::applyValue() { - int ivalue = slider->value(); - if (ivalue == slider->maximum()) + int ivalue = _slider->value(); + if (ivalue == _slider->maximum()) { - *value = max; + *_value = _max; } else { - *value = min + ((double)ivalue) * small_step; + *_value = _min + ((double)ivalue) * _small_step; } - if (fabs(*value) < 0.0000001) + if (fabs(*_value) < 0.0000001) { - *value = 0.0; + *_value = 0.0; } BaseInput::applyValue(); @@ -55,7 +60,11 @@ void InputDouble::applyValue() void InputDouble::revert() { - slider->setValue(round((*value - min) / small_step)); + double value = round((*_value - _min) / _small_step); + if (value != _slider->value()) + { + _slider->setValue(value); + } BaseInput::revert(); } diff --git a/gui_qt/inputdouble.h b/gui_qt/inputdouble.h index da73fdf..6df19e0 100644 --- a/gui_qt/inputdouble.h +++ b/gui_qt/inputdouble.h @@ -18,12 +18,12 @@ public slots: virtual void revert(); private: - QSlider* slider; - double* value; - double min; - double max; - double small_step; - double large_step; + QSlider* _slider; + double* _value; + double _min; + double _max; + double _small_step; + double _large_step; }; -#endif // _PAYSAGES_QT_INPUTDOUBLE_H_ +#endif diff --git a/gui_qt/inputenum.cpp b/gui_qt/inputenum.cpp index 7745881..804ea33 100644 --- a/gui_qt/inputenum.cpp +++ b/gui_qt/inputenum.cpp @@ -23,7 +23,10 @@ void InputEnum::applyValue() void InputEnum::revert() { - ((QComboBox*)_control)->setCurrentIndex(*_value); + if (*_value != ((QComboBox*)_control)->currentIndex()) + { + ((QComboBox*)_control)->setCurrentIndex(*_value); + } BaseInput::revert(); } diff --git a/gui_qt/inputint.cpp b/gui_qt/inputint.cpp index 1e4d883..091d83f 100644 --- a/gui_qt/inputint.cpp +++ b/gui_qt/inputint.cpp @@ -3,46 +3,54 @@ #include InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step): - BaseInput(form, label), - value(value), min(min), max(max), small_step(small_step), large_step(large_step) + BaseInput(form, label) { - slider = new QSlider(form); + _value = value; + _min = min; + _max = max; + _small_step = small_step; + _large_step = large_step; + + _slider = new QSlider(form); - slider->setOrientation(Qt::Horizontal); - slider->setMinimumWidth(150); - slider->setMaximumWidth(400); + _slider->setOrientation(Qt::Horizontal); + _slider->setMinimumWidth(150); + _slider->setMaximumWidth(400); - slider->setMinimum(min); - slider->setMaximum(max); - slider->setValue(*value); + _slider->setMinimum(min); + _slider->setMaximum(max); + _slider->setValue(*value); - slider->setTickInterval(large_step); - slider->setTickPosition(QSlider::TicksBelow); + _slider->setTickInterval(large_step); + _slider->setTickPosition(QSlider::TicksBelow); - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); + connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); _preview = new QLabel(form); ((QLabel*)_preview)->setAlignment(Qt::AlignCenter); - _control = slider; + _control = _slider; } void InputInt::updatePreview() { - ((QLabel*)_preview)->setText(QString("%1").arg(*value)); + ((QLabel*)_preview)->setText(QString("%1").arg(*_value)); BaseInput::updatePreview(); } void InputInt::applyValue() { - *value = (int)slider->value(); + *_value = (int)_slider->value(); BaseInput::applyValue(); } void InputInt::revert() { - slider->setValue(*value); + if (*_value != _slider->value()) + { + _slider->setValue(*_value); + } BaseInput::revert(); } diff --git a/gui_qt/inputint.h b/gui_qt/inputint.h index 7a32a03..9c6e942 100644 --- a/gui_qt/inputint.h +++ b/gui_qt/inputint.h @@ -18,12 +18,12 @@ public slots: virtual void revert(); private: - QSlider* slider; - int* value; - int min; - int max; - int small_step; - int large_step; + QSlider* _slider; + int* _value; + int _min; + int _max; + int _small_step; + int _large_step; }; #endif