From 466ae17a4a4972aa0bd8e4618c8f92104e84cdf2 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Sat, 6 Jun 2020 12:29:50 -0500 Subject: [PATCH] Draft: hide properties not used in the Label object When `LabelType` is `'Custom'`, the `Target` property is hidden and `CustomText` is shown. For other values of `LabelType`, `Target` is shown, and in turn `CustomText` is hidden. This avoids showing unused information in the property editor. --- src/Mod/Draft/draftobjects/label.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Mod/Draft/draftobjects/label.py b/src/Mod/Draft/draftobjects/label.py index e5877420c5..036af75187 100644 --- a/src/Mod/Draft/draftobjects/label.py +++ b/src/Mod/Draft/draftobjects/label.py @@ -229,6 +229,22 @@ class Label(DraftAnnotation): """ super(Label, self).onDocumentRestored(obj) + def onChanged(self, obj, prop): + """Execute when a property is changed.""" + super(Label, self).onChanged(obj, prop) + self.show_and_hide(obj, prop) + + def show_and_hide(self, obj, prop): + """Show and hide the properties depending on the touched property.""" + # The minus sign removes the Hidden property (show) + if prop == "LabelType": + if obj.LabelType != "Custom": + obj.setPropertyStatus("CustomText", "Hidden") + obj.setPropertyStatus("Target", "-Hidden") + else: + obj.setPropertyStatus("CustomText", "-Hidden") + obj.setPropertyStatus("Target", "Hidden") + def execute(self, obj): """Execute when the object is created or recomputed.""" if obj.StraightDirection != "Custom":