From b24d748840d55a0a7f420490a9d90c7477219614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 13 Jul 2023 15:14:39 +0200 Subject: [PATCH] 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. --- addon/flamenco/gui.py | 1 + addon/flamenco/job_types.py | 11 +++++++++++ addon/flamenco/operators.py | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/addon/flamenco/gui.py b/addon/flamenco/gui.py index abad6c86..b0c2a7ff 100644 --- a/addon/flamenco/gui.py +++ b/addon/flamenco/gui.py @@ -126,6 +126,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel): props = layout.operator("flamenco.eval_setting", text="", icon="SCRIPTPLUGINS") props.setting_key = setting.key props.setting_eval = setting_eval + props.eval_description = job_types.eval_description(setting) def draw_setting_readonly( self, diff --git a/addon/flamenco/job_types.py b/addon/flamenco/job_types.py index b693d9ca..8150a953 100644 --- a/addon/flamenco/job_types.py +++ b/addon/flamenco/job_types.py @@ -91,6 +91,17 @@ def show_eval_on_submit_button(setting: _AvailableJobSetting) -> bool: 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: """Return the property name of the 'auto-eval' state for this setting.""" return f"autoeval_{setting.key}" diff --git a/addon/flamenco/operators.py b/addon/flamenco/operators.py index 0b6c883b..cefc33ed 100644 --- a/addon/flamenco/operators.py +++ b/addon/flamenco/operators.py @@ -143,6 +143,14 @@ class FLAMENCO_OT_eval_setting(FlamencoOpMixin, bpy.types.Operator): setting_key: bpy.props.StringProperty(name="Setting Key") # 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]: job = job_submission.job_for_scene(context.scene) if job is None: