Merge pull request #1129 from pypeclub/bugfix/settings_cleanup

Settings schemas cleanup
This commit is contained in:
Milan Kolar 2021-03-17 09:48:46 +01:00 committed by GitHub
commit 0ebe79e199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 110 additions and 62 deletions

View file

@ -1,6 +1,4 @@
{
"ftrack_actions_path": [],
"ftrack_events_path": [],
"events": {
"sync_to_avalon": {
"enabled": true,

View file

@ -10,6 +10,7 @@ from pype.settings.constants import (
M_OVERRIDEN_KEY
)
from . import (
BaseItemEntity,
ItemEntity,
BoolEntity,
GUIEntity
@ -75,6 +76,15 @@ class DictImmutableKeysEntity(ItemEntity):
def schema_validations(self):
"""Validation of schema data."""
children_keys = set()
for child_entity in self.children:
if not isinstance(child_entity, BaseItemEntity):
continue
elif child_entity.key not in children_keys:
children_keys.add(child_entity.key)
else:
raise SchemaDuplicatedKeys(self.path, child_entity.key)
if self.checkbox_key:
checkbox_child = self.non_gui_children.get(self.checkbox_key)
if not checkbox_child:
@ -134,8 +144,6 @@ class DictImmutableKeysEntity(ItemEntity):
if isinstance(child_obj, GUIEntity):
continue
if child_obj.key in self.non_gui_children:
raise SchemaDuplicatedKeys("", child_obj.key)
self.non_gui_children[child_obj.key] = child_obj
if not first:

View file

@ -10,7 +10,7 @@ from .base_entity import ItemEntity
class PathEntity(ItemEntity):
schema_types = ["path-widget", "path-item"]
schema_types = ["path"]
platforms = ("windows", "darwin", "linux")
platform_labels_mapping = {
"windows": "Windows",

View file

@ -47,7 +47,7 @@
"key": "{host_name}_environments",
"env_group_key": "{host_name}"
}, {
"type": "path-widget",
"type": "path",
"key": "{host_name}_executables",
"label": "{host_label} - Full paths to executables",
"multiplatform": "{multipath_executables}",
@ -361,7 +361,7 @@
```
{
"type": "path-widget",
"type": "path",
"key": "ffmpeg_path",
"label": "FFmpeg path",
"multiplatform": true,

View file

@ -15,7 +15,7 @@
"is_group": true,
"expandable": false,
"object_type": {
"type": "path-widget",
"type": "path",
"multiplatform": true
}
},

View file

@ -5,28 +5,6 @@
"collapsible": true,
"is_file": true,
"children": [
{
"type": "splitter"
},
{
"type": "label",
"label": "Additional Ftrack paths"
},
{
"type": "list",
"key": "ftrack_actions_path",
"label": "Action paths",
"object_type": "text"
},
{
"type": "list",
"key": "ftrack_events_path",
"label": "Event paths",
"object_type": "text"
},
{
"type": "splitter"
},
{
"type": "dict",
"key": "events",

View file

@ -39,7 +39,7 @@
]
},
{
"type": "path-widget",
"type": "path",
"key": "ocioconfigpath",
"label": "Custom OCIO path",
"multiplatform": true,
@ -175,7 +175,7 @@
]
},
{
"type": "path-widget",
"type": "path",
"key": "customOCIOConfigPath",
"label": "Custom OCIO config path",
"multiplatform": true,

View file

@ -93,7 +93,7 @@
"label": "Path to material file defining list of material names to check. This is material name per line simple text file.<br/>It will be checked against named group <b>shader</b> in your <em>Validation regex</em>.<p>For example: <br/> <code>^.*(?P=&lt;shader&gt;.+)_GEO</code></p>"
},
{
"type": "path-widget",
"type": "path",
"key": "material_file",
"label": "Material File",
"multiplatform": true,

View file

@ -298,28 +298,28 @@
}
},
{
"type": "path-widget",
"type": "path",
"key": "single_path_input",
"label": "Single path input",
"multiplatform": false,
"multipath": false
},
{
"type": "path-widget",
"type": "path",
"key": "multi_path_input",
"label": "Multi path input",
"multiplatform": false,
"multipath": true
},
{
"type": "path-widget",
"type": "path",
"key": "single_os_specific_path_input",
"label": "Single OS specific path input",
"multiplatform": true,
"multipath": false
},
{
"type": "path-widget",
"type": "path",
"key": "multi_os_specific_path_input",
"label": "Multi OS specific path input",
"multiplatform": true,

View file

@ -11,7 +11,7 @@
"env_group_key": "{host_name}"
},
{
"type": "path-widget",
"type": "path",
"key": "{host_name}_executables",
"label": "{host_label} - Full paths to executables",
"multiplatform": "{multipath_executables}",

View file

@ -39,7 +39,7 @@
"roles": ["developer"]
},
{
"type": "path-widget",
"type": "path",
"key": "executables",
"label": "Executables",
"multiplatform": "{multiplatform}",

View file

@ -20,14 +20,14 @@
},
{
"key": "project_plugins",
"type": "path-widget",
"type": "path",
"label": "Additional Project Plugins Path",
"multiplatform": true,
"multipath": false
},
{
"key": "studio_soft",
"type": "path-widget",
"type": "path",
"label": "Studio Software Location",
"multiplatform": true,
"multipath": false

View file

@ -18,7 +18,7 @@
"label": "Avalon Mongo Timeout (ms)"
},
{
"type": "path-widget",
"type": "path",
"label": "Thumbnail Storage Location",
"key": "AVALON_THUMBNAIL_ROOT",
"multiplatform": true,

View file

@ -489,16 +489,54 @@ class EnumeratorWidget(InputWidget):
class PathWidget(BaseWidget):
def create_ui(self):
self.content_widget = self
self.content_layout = QtWidgets.QGridLayout(self)
self.content_layout.setContentsMargins(0, 0, 0, 0)
self.content_layout.setSpacing(5)
self._child_style_state = ""
if self.entity.use_label_wrap:
entity_label = None
self._create_label_wrapper()
else:
entity_label = self.entity.label
self.content_widget = self
self.content_layout = QtWidgets.QGridLayout(self)
self.content_layout.setContentsMargins(0, 0, 0, 0)
self.content_layout.setSpacing(5)
self.body_widget = None
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.input_field = self.create_ui_for_entity(
self.category_widget, self.entity.child_obj, self
)
self.entity_widget.add_widget_to_layout(self, entity_label)
self.entity_widget.add_widget_to_layout(self, self.entity.label)
def _create_label_wrapper(self):
main_layout = QtWidgets.QHBoxLayout(self)
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.setSpacing(0)
body_widget = ExpandingWidget(self.entity.label, self)
main_layout.addWidget(body_widget)
self.label_widget = body_widget.label_widget
self.body_widget = body_widget
content_widget = QtWidgets.QWidget(body_widget)
content_widget.setObjectName("ContentWidget")
content_widget.setProperty("content_state", "")
content_layout = QtWidgets.QGridLayout(content_widget)
content_layout.setContentsMargins(CHILD_OFFSET, 5, 0, 5)
body_widget.set_content_widget(content_widget)
self.body_widget = body_widget
self.content_widget = content_widget
self.content_layout = content_layout
if not self.entity.collapsible:
body_widget.hide_toolbox(hide_content=False)
elif self.entity.collapsed:
body_widget.toggle_content()
def add_widget_to_layout(self, widget, label=None):
row = self.content_layout.rowCount()
@ -523,26 +561,52 @@ class PathWidget(BaseWidget):
pass
def update_style(self):
if not self.label_widget:
if not self.body_widget and not self.label_widget:
return
has_unsaved_changes = self.entity.has_unsaved_changes
if not has_unsaved_changes and self.entity.group_item:
has_unsaved_changes = self.entity.group_item.has_unsaved_changes
if self.entity.group_item:
group_item = self.entity.group_item
has_unsaved_changes = group_item.has_unsaved_changes
has_project_override = group_item.has_project_override
has_studio_override = group_item.has_studio_override
else:
has_unsaved_changes = self.entity.has_unsaved_changes
has_project_override = self.entity.has_project_override
has_studio_override = self.entity.has_studio_override
state = self.get_style_state(
self.is_invalid,
has_unsaved_changes,
self.entity.has_project_override,
self.entity.has_studio_override
)
if self._style_state == state:
return
child_invalid = self.is_invalid
self._style_state = state
if self.body_widget:
child_style_state = self.get_style_state(
child_invalid,
has_unsaved_changes,
has_project_override,
has_studio_override
)
if child_style_state:
child_style_state = "child-{}".format(child_style_state)
self.label_widget.setProperty("state", state)
self.label_widget.style().polish(self.label_widget)
if child_style_state != self._child_style_state:
self.body_widget.side_line_widget.setProperty(
"state", child_style_state
)
self.body_widget.side_line_widget.style().polish(
self.body_widget.side_line_widget
)
self._child_style_state = child_style_state
if self.label_widget:
style_state = self.get_style_state(
child_invalid,
has_unsaved_changes,
has_project_override,
has_studio_override
)
if self._style_state != style_state:
self.label_widget.setProperty("state", style_state)
self.label_widget.style().polish(self.label_widget)
self._style_state = style_state
@property
def is_invalid(self):