From ace014c777cf08223a11eeee3cc94435289a424d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 30 Jul 2021 16:16:47 +0200 Subject: [PATCH 1/6] fix exceptions --- openpype/settings/entities/dict_conditional.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/settings/entities/dict_conditional.py b/openpype/settings/entities/dict_conditional.py index 96065b670e..b61f667f6d 100644 --- a/openpype/settings/entities/dict_conditional.py +++ b/openpype/settings/entities/dict_conditional.py @@ -185,13 +185,13 @@ class DictConditionalEntity(ItemEntity): children_def_keys = [] for children_def in self.enum_children: if not isinstance(children_def, dict): - raise EntitySchemaError(( + raise EntitySchemaError(self, ( "Children definition under key 'enum_children' must" " be a dictionary." )) if "key" not in children_def: - raise EntitySchemaError(( + raise EntitySchemaError(self, ( "Children definition under key 'enum_children' miss" " 'key' definition." )) From 73a13a13cd6a9e2a1711e439e67c4cd9d4538eef Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 30 Jul 2021 16:18:35 +0200 Subject: [PATCH 2/6] added new enum attributes --- openpype/settings/entities/dict_conditional.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openpype/settings/entities/dict_conditional.py b/openpype/settings/entities/dict_conditional.py index b61f667f6d..b48c5a1cb0 100644 --- a/openpype/settings/entities/dict_conditional.py +++ b/openpype/settings/entities/dict_conditional.py @@ -144,6 +144,13 @@ class DictConditionalEntity(ItemEntity): self.enum_entity = None + # GUI attributes + self.enum_is_horizontal = self.schema_data.get( + "enum_is_horizontal", False + ) + # `enum_on_right` can be used only if + self.enum_on_right = self.schema_data.get("enum_on_right", False) + self.highlight_content = self.schema_data.get( "highlight_content", False ) From e4c050611d102771c4976db8347032b4cd33b897 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 30 Jul 2021 16:20:55 +0200 Subject: [PATCH 3/6] modified widget to be able show combobox horizontally --- .../settings/settings/dict_conditional.py | 63 +++++++++++++++---- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/openpype/tools/settings/settings/dict_conditional.py b/openpype/tools/settings/settings/dict_conditional.py index da2f53497e..31a4fa9fab 100644 --- a/openpype/tools/settings/settings/dict_conditional.py +++ b/openpype/tools/settings/settings/dict_conditional.py @@ -24,6 +24,7 @@ class DictConditionalWidget(BaseWidget): self.body_widget = None self.content_widget = None self.content_layout = None + self.enum_layout = None label = None if self.entity.is_dynamic_item: @@ -40,8 +41,36 @@ class DictConditionalWidget(BaseWidget): self._enum_key_by_wrapper_id = {} self._added_wrapper_ids = set() - self.content_layout.setColumnStretch(0, 0) - self.content_layout.setColumnStretch(1, 1) + enum_layout = QtWidgets.QGridLayout() + enum_layout.setContentsMargins(0, 0, 0, 0) + enum_layout.setColumnStretch(0, 0) + enum_layout.setColumnStretch(1, 1) + + all_children_layout = QtWidgets.QVBoxLayout() + all_children_layout.setContentsMargins(0, 0, 0, 0) + + if self.entity.enum_is_horizontal: + if self.entity.enum_on_right: + self.content_layout.addLayout(all_children_layout, 0, 0) + self.content_layout.addLayout(enum_layout, 0, 1) + # Stretch combobox to minimum and expand value + self.content_layout.setColumnStretch(0, 1) + self.content_layout.setColumnStretch(1, 0) + else: + self.content_layout.addLayout(enum_layout, 0, 0) + self.content_layout.addLayout(all_children_layout, 0, 1) + # Stretch combobox to minimum and expand value + self.content_layout.setColumnStretch(0, 0) + self.content_layout.setColumnStretch(1, 1) + + else: + # Expand content + self.content_layout.setColumnStretch(0, 1) + self.content_layout.addLayout(enum_layout, 0, 0) + self.content_layout.addLayout(all_children_layout, 1, 0) + + self.enum_layout = enum_layout + self.all_children_layout = all_children_layout # Add enum entity to layout mapping enum_entity = self.entity.enum_entity @@ -58,6 +87,8 @@ class DictConditionalWidget(BaseWidget): content_layout.setContentsMargins(0, 0, 0, 0) content_layout.setSpacing(5) + all_children_layout.addWidget(content_widget) + self._content_by_enum_value[enum_key] = { "widget": content_widget, "layout": content_layout @@ -80,9 +111,6 @@ class DictConditionalWidget(BaseWidget): for item_key, children in self.entity.children.items(): content_widget = self._content_by_enum_value[item_key]["widget"] - row = self.content_layout.rowCount() - self.content_layout.addWidget(content_widget, row, 0, 1, 2) - for child_obj in children: self.input_fields.append( self.create_ui_for_entity( @@ -191,12 +219,25 @@ class DictConditionalWidget(BaseWidget): else: map_id = widget.entity.id - content_widget = self.content_widget - content_layout = self.content_layout - if map_id != self.entity.enum_entity.id: - enum_value = self._enum_key_by_wrapper_id[map_id] - content_widget = self._content_by_enum_value[enum_value]["widget"] - content_layout = self._content_by_enum_value[enum_value]["layout"] + is_enum_item = map_id == self.entity.enum_entity.id + if is_enum_item: + content_widget = self.content_widget + content_layout = self.enum_layout + + if not label: + content_layout.addWidget(widget, 0, 0, 1, 2) + return + + label_widget = GridLabelWidget(label, widget) + label_widget.input_field = widget + widget.label_widget = label_widget + content_layout.addWidget(label_widget, 0, 0, 1, 1) + content_layout.addWidget(widget, 0, 1, 1, 1) + return + + enum_value = self._enum_key_by_wrapper_id[map_id] + content_widget = self._content_by_enum_value[enum_value]["widget"] + content_layout = self._content_by_enum_value[enum_value]["layout"] wrapper = self._parent_widget_by_entity_id[map_id] if wrapper is not content_widget: From 8ad04c84f62840c86634f8cd82cfd97f7b8927bd Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 30 Jul 2021 16:21:10 +0200 Subject: [PATCH 4/6] allow to not set label --- openpype/settings/entities/dict_conditional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/settings/entities/dict_conditional.py b/openpype/settings/entities/dict_conditional.py index b48c5a1cb0..d275d8ac3d 100644 --- a/openpype/settings/entities/dict_conditional.py +++ b/openpype/settings/entities/dict_conditional.py @@ -293,7 +293,7 @@ class DictConditionalEntity(ItemEntity): "multiselection": False, "enum_items": enum_items, "key": enum_key, - "label": self.enum_label or enum_key + "label": self.enum_label } enum_entity = self.create_schema_object(enum_schema, self) From 860bb00ed5b466d3ec75b9de00433de138049d80 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 30 Jul 2021 16:22:19 +0200 Subject: [PATCH 5/6] added example of `enum_is_horizontal` usage --- .../schemas/system_schema/example_schema.json | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openpype/settings/entities/schemas/system_schema/example_schema.json b/openpype/settings/entities/schemas/system_schema/example_schema.json index c3287d7452..8ec97064a1 100644 --- a/openpype/settings/entities/schemas/system_schema/example_schema.json +++ b/openpype/settings/entities/schemas/system_schema/example_schema.json @@ -9,6 +9,31 @@ "label": "Color input", "type": "color" }, + { + "type": "dict-conditional", + "key": "overriden_value", + "label": "Overriden value", + "enum_key": "overriden", + "enum_is_horizontal": true, + "enum_children": [ + { + "key": "overriden", + "label": "Override value", + "children": [ + { + "type": "number", + "key": "value", + "label": "value" + } + ] + }, + { + "key": "inherit", + "label": "Inherit value", + "children": [] + } + ] + }, { "type": "dict-conditional", "use_label_wrap": true, From f34f45c3fbf8fb2568ed69483dd0719c9e9f9520 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 30 Jul 2021 16:25:18 +0200 Subject: [PATCH 6/6] added enum_is_horizontal to readme --- openpype/settings/entities/schemas/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpype/settings/entities/schemas/README.md b/openpype/settings/entities/schemas/README.md index 079d16c506..399c4ac1d9 100644 --- a/openpype/settings/entities/schemas/README.md +++ b/openpype/settings/entities/schemas/README.md @@ -204,6 +204,8 @@ - it is possible to add darker background with `"highlight_content"` (Default: `False`) - darker background has limits of maximum applies after 3-4 nested highlighted items there is not difference in the color - output is dictionary `{the "key": children values}` +- for UI porposes was added `enum_is_horizontal` which will make combobox appear next to children inputs instead of on top of them (Default: `False`) + - this has extended ability of `enum_on_right` which will move combobox to right side next to children widgets (Default: `False`) ``` # Example {