Add-on: use the 'eval' description in the 'eval now' button as well

In the tooltip of the 'evaluate now' button (the one with the Python
icon), include the description provided by the job type in its
`evalInfo.description` field. This makes it explicit what the button
will do when pressed.
This commit is contained in:
Sybren A. Stüvel 2023-07-13 15:14:39 +02:00
parent 6994413ed6
commit b24d748840
3 changed files with 20 additions and 0 deletions

View File

@ -126,6 +126,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel):
props = layout.operator("flamenco.eval_setting", text="", icon="SCRIPTPLUGINS") props = layout.operator("flamenco.eval_setting", text="", icon="SCRIPTPLUGINS")
props.setting_key = setting.key props.setting_key = setting.key
props.setting_eval = setting_eval props.setting_eval = setting_eval
props.eval_description = job_types.eval_description(setting)
def draw_setting_readonly( def draw_setting_readonly(
self, self,

View File

@ -91,6 +91,17 @@ def show_eval_on_submit_button(setting: _AvailableJobSetting) -> bool:
return show_button return show_button
def eval_description(setting: _AvailableJobSetting) -> str:
"""Return the 'eval description' of this setting, or an empty string if not found."""
eval_info = setting.get("eval_info", None)
if not eval_info:
return ""
description: str = eval_info.get("description", "")
return description
def setting_autoeval_propname(setting: _AvailableJobSetting) -> str: def setting_autoeval_propname(setting: _AvailableJobSetting) -> str:
"""Return the property name of the 'auto-eval' state for this setting.""" """Return the property name of the 'auto-eval' state for this setting."""
return f"autoeval_{setting.key}" return f"autoeval_{setting.key}"

View File

@ -143,6 +143,14 @@ class FLAMENCO_OT_eval_setting(FlamencoOpMixin, bpy.types.Operator):
setting_key: bpy.props.StringProperty(name="Setting Key") # type: ignore setting_key: bpy.props.StringProperty(name="Setting Key") # type: ignore
setting_eval: bpy.props.StringProperty(name="Python Expression") # type: ignore setting_eval: bpy.props.StringProperty(name="Python Expression") # type: ignore
eval_description: bpy.props.StringProperty(name="Description", options={"HIDDEN"})
@classmethod
def description(cls, context, properties):
if not properties.eval_description:
return "" # Causes bl_description to be shown.
return f"Set value to: {properties.eval_description}"
def execute(self, context: bpy.types.Context) -> set[str]: def execute(self, context: bpy.types.Context) -> set[str]:
job = job_submission.job_for_scene(context.scene) job = job_submission.job_for_scene(context.scene)
if job is None: if job is None: