From b067dbebbab300478457548de019cbb0fdc782a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Wed, 27 Jun 2012 14:03:19 +0000 Subject: [PATCH] paysages : Disable form fields when no layer is selected. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@368 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 - gui_qt/baseform.cpp | 10 +++++++++- gui_qt/baseinput.cpp | 24 +++++++++++++++++++++++- gui_qt/baseinput.h | 3 ++- i18n/paysages_fr.ts | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 9d5ce5c..56fb8e7 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ Technology Preview 2 : => Find a proper model for night sky (maybe Shirley) - InputInt doesn't honor small_step. - Keep skydome lights in cache for a render. -- Disable form fields when no layer is selected. - Add buttons to restore "auto" default values in tabs and dialogs. - Replace zone ranges with curves (with curve input and curve dialog). - Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges). diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index 28030cb..e3f9764 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -143,7 +143,14 @@ void BaseForm::configChangeEvent() QList inputs = form->findChildren("_form_input_"); for (int i = 0; i < inputs.size(); i++) { - inputs[i]->checkVisibility(); + if (with_layers && layer_list->count() == 0) + { + inputs[i]->checkVisibility(false); + } + else + { + inputs[i]->checkVisibility(true); + } } if (auto_update_previews) @@ -372,6 +379,7 @@ void BaseForm::layerSelectedEvent(int layer) for (int i = 0; i < inputs.size(); i++) { inputs[i]->revert(); + inputs[i]->checkVisibility(layer >= 0); } QList list_previews = previews->findChildren("_form_preview_"); diff --git a/gui_qt/baseinput.cpp b/gui_qt/baseinput.cpp index b58d238..8537160 100644 --- a/gui_qt/baseinput.cpp +++ b/gui_qt/baseinput.cpp @@ -10,6 +10,7 @@ BaseInput::BaseInput(QWidget* form, QString label): _visibility_value = NULL; _visible = true; + _enabled = true; } void BaseInput::setVisibilityCondition(int* value, int condition) @@ -33,7 +34,7 @@ void BaseInput::revert() updatePreview(); } -void BaseInput::checkVisibility() +void BaseInput::checkVisibility(bool enabled) { if (!_visibility_value || *_visibility_value == _visibility_condition) { @@ -57,4 +58,25 @@ void BaseInput::checkVisibility() _control->hide(); } } + + if (enabled) + { + if (not _enabled) + { + _enabled = true; + + _preview->setEnabled(true); + _control->setEnabled(true); + } + } + else + { + if (_enabled) + { + _enabled = false; + + _preview->setEnabled(false); + _control->setEnabled(false); + } + } } diff --git a/gui_qt/baseinput.h b/gui_qt/baseinput.h index 3e38e98..2cdf8b0 100644 --- a/gui_qt/baseinput.h +++ b/gui_qt/baseinput.h @@ -19,7 +19,7 @@ public slots: virtual void updatePreview(); virtual void revert(); virtual void applyValue(); - void checkVisibility(); + void checkVisibility(bool enabled); signals: void valueChanged(); @@ -31,6 +31,7 @@ protected: int* _visibility_value; int _visibility_condition; bool _visible; + bool _enabled; }; #endif diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index 0a2297f..705f7c0 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -29,7 +29,7 @@ Annuler les modifications - + Layer %1 Niveau %1