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
This commit is contained in:
Michaël Lemaire 2012-06-27 14:03:19 +00:00 committed by ThunderK
parent 73e6c40f75
commit b067dbebba
5 changed files with 35 additions and 5 deletions

1
TODO
View file

@ -5,7 +5,6 @@ Technology Preview 2 :
=> Find a proper model for night sky (maybe Shirley) => Find a proper model for night sky (maybe Shirley)
- InputInt doesn't honor small_step. - InputInt doesn't honor small_step.
- Keep skydome lights in cache for a render. - 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. - Add buttons to restore "auto" default values in tabs and dialogs.
- Replace zone ranges with curves (with curve input and curve dialog). - Replace zone ranges with curves (with curve input and curve dialog).
- Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges). - Interface for textures thickness, slope_range and thickness_transparency (and correct slider ranges).

View file

@ -143,7 +143,14 @@ void BaseForm::configChangeEvent()
QList<BaseInput*> inputs = form->findChildren<BaseInput*>("_form_input_"); QList<BaseInput*> inputs = form->findChildren<BaseInput*>("_form_input_");
for (int i = 0; i < inputs.size(); i++) 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) if (auto_update_previews)
@ -372,6 +379,7 @@ void BaseForm::layerSelectedEvent(int layer)
for (int i = 0; i < inputs.size(); i++) for (int i = 0; i < inputs.size(); i++)
{ {
inputs[i]->revert(); inputs[i]->revert();
inputs[i]->checkVisibility(layer >= 0);
} }
QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_"); QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_");

View file

@ -10,6 +10,7 @@ BaseInput::BaseInput(QWidget* form, QString label):
_visibility_value = NULL; _visibility_value = NULL;
_visible = true; _visible = true;
_enabled = true;
} }
void BaseInput::setVisibilityCondition(int* value, int condition) void BaseInput::setVisibilityCondition(int* value, int condition)
@ -33,7 +34,7 @@ void BaseInput::revert()
updatePreview(); updatePreview();
} }
void BaseInput::checkVisibility() void BaseInput::checkVisibility(bool enabled)
{ {
if (!_visibility_value || *_visibility_value == _visibility_condition) if (!_visibility_value || *_visibility_value == _visibility_condition)
{ {
@ -57,4 +58,25 @@ void BaseInput::checkVisibility()
_control->hide(); _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);
}
}
} }

View file

@ -19,7 +19,7 @@ public slots:
virtual void updatePreview(); virtual void updatePreview();
virtual void revert(); virtual void revert();
virtual void applyValue(); virtual void applyValue();
void checkVisibility(); void checkVisibility(bool enabled);
signals: signals:
void valueChanged(); void valueChanged();
@ -31,6 +31,7 @@ protected:
int* _visibility_value; int* _visibility_value;
int _visibility_condition; int _visibility_condition;
bool _visible; bool _visible;
bool _enabled;
}; };
#endif #endif

View file

@ -29,7 +29,7 @@
<translation>Annuler les modifications</translation> <translation>Annuler les modifications</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="342"/> <location filename="../gui_qt/baseform.cpp" line="349"/>
<source>Layer %1</source> <source>Layer %1</source>
<translation>Niveau %1</translation> <translation>Niveau %1</translation>
</message> </message>