Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1932 from pypeclub/feature/breadcrumbs_in_settings
Browse files Browse the repository at this point in the history
Settings UI: Breadcrumbs in settings
  • Loading branch information
iLLiCiTiT authored Aug 13, 2021
2 parents d81575b + f2d59de commit 2535b08
Show file tree
Hide file tree
Showing 19 changed files with 959 additions and 68 deletions.
8 changes: 8 additions & 0 deletions openpype/settings/entities/base_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ def __init__(self, schema_data):
roles = [roles]
self.roles = roles

@abstractmethod
def collect_static_entities_by_path(self):
"""Collect all paths of all static path entities.
Static path is entity which is not dynamic or under dynamic entity.
"""
pass

@property
def require_restart_on_change(self):
return self._require_restart_on_change
Expand Down
5 changes: 5 additions & 0 deletions openpype/settings/entities/dict_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ def _add_children(self):

self.non_gui_children[item_key][child_obj.key] = child_obj

def collect_static_entities_by_path(self):
if self.is_dynamic_item or self.is_in_dynamic_item:
return {}
return {self.path: self}

def get_child_path(self, child_obj):
"""Get hierarchical path of child entity.
Expand Down
12 changes: 12 additions & 0 deletions openpype/settings/entities/dict_immutable_keys_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ def _item_initalization(self):
)
self.show_borders = self.schema_data.get("show_borders", True)

def collect_static_entities_by_path(self):
output = {}
if self.is_dynamic_item or self.is_in_dynamic_item:
return output

output[self.path] = self
for children in self.non_gui_children.values():
result = children.collect_static_entities_by_path()
if result:
output.update(result)
return output

def get_child_path(self, child_obj):
"""Get hierarchical path of child entity.
Expand Down
5 changes: 5 additions & 0 deletions openpype/settings/entities/input_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def schema_validations(self):
def _settings_value(self):
pass

def collect_static_entities_by_path(self):
if self.is_dynamic_item or self.is_in_dynamic_item:
return {}
return {self.path: self}

def settings_value(self):
if self._override_state is OverrideState.NOT_DEFINED:
return NOT_SET
Expand Down
33 changes: 33 additions & 0 deletions openpype/settings/entities/item_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def _item_initalization(self):
self.valid_value_types = valid_value_types
self.child_obj = self.create_schema_object(item_schema, self)

def collect_static_entities_by_path(self):
return self.child_obj.collect_static_entities_by_path()

def get_child_path(self, _child_obj):
return self.path

Expand Down Expand Up @@ -192,6 +195,24 @@ def reset_callbacks(self):
class ListStrictEntity(ItemEntity):
schema_types = ["list-strict"]

def __getitem__(self, idx):
if not isinstance(idx, int):
idx = int(idx)
return self.children[idx]

def __setitem__(self, idx, value):
if not isinstance(idx, int):
idx = int(idx)
self.children[idx].set(value)

def get(self, idx, default=None):
if not isinstance(idx, int):
idx = int(idx)

if idx < len(self.children):
return self.children[idx]
return default

def _item_initalization(self):
self.valid_value_types = (list, )
self.require_key = True
Expand Down Expand Up @@ -222,6 +243,18 @@ def schema_validations(self):

super(ListStrictEntity, self).schema_validations()

def collect_static_entities_by_path(self):
output = {}
if self.is_dynamic_item or self.is_in_dynamic_item:
return output

output[self.path] = self
for child_obj in self.children:
result = child_obj.collect_static_entities_by_path()
if result:
output.update(result)
return output

def get_child_path(self, child_obj):
result_idx = None
for idx, _child_obj in enumerate(self.children):
Expand Down
18 changes: 18 additions & 0 deletions openpype/settings/entities/list_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ def __contains__(self, item):
return True
return False

def __getitem__(self, idx):
if not isinstance(idx, int):
idx = int(idx)
return self.children[idx]

def __setitem__(self, idx, value):
if not isinstance(idx, int):
idx = int(idx)
self.children[idx].set(value)

def get(self, idx, default=None):
if not isinstance(idx, int):
idx = int(idx)

if idx < len(self.children):
return self.children[idx]
return default

def index(self, item):
if isinstance(item, BaseEntity):
for idx, child_entity in enumerate(self.children):
Expand Down
8 changes: 8 additions & 0 deletions openpype/settings/entities/root_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ def on_child_change(self, _child_entity):
"""Whan any children has changed."""
self.on_change()

def collect_static_entities_by_path(self):
output = {}
for child_obj in self.non_gui_children.values():
result = child_obj.collect_static_entities_by_path()
if result:
output.update(result)
return output

def get_child_path(self, child_entity):
"""Return path of children entity"""
for key, _child_entity in self.non_gui_children.items():
Expand Down
65 changes: 63 additions & 2 deletions openpype/tools/settings/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,38 @@ def __init__(self, category_widget, entity, entity_widget):
self.label_widget = None
self.create_ui()

def scroll_to(self, widget):
self.category_widget.scroll_to(widget)

def set_path(self, path):
self.category_widget.set_path(path)

def set_focus(self, scroll_to=False):
"""Set focus of a widget.
Args:
scroll_to(bool): Also scroll to widget in category widget.
"""
if scroll_to:
self.scroll_to(self)
self.setFocus()

def make_sure_is_visible(self, path, scroll_to):
"""Make a widget of entity visible by it's path.
Args:
path(str): Path to entity.
scroll_to(bool): Should be scrolled to entity.
Returns:
bool: Entity with path was found.
"""
raise NotImplementedError(
"{} not implemented `make_sure_is_visible`".format(
self.__class__.__name__
)
)

def trigger_hierarchical_style_update(self):
self.category_widget.hierarchical_style_update()

Expand Down Expand Up @@ -277,11 +309,23 @@ def show_actions_menu(self, event=None):
if to_run:
to_run()

def focused_in(self):
if self.entity is not None:
self.set_path(self.entity.path)

def mouseReleaseEvent(self, event):
if self.allow_actions and event.button() == QtCore.Qt.RightButton:
return self.show_actions_menu()

return super(BaseWidget, self).mouseReleaseEvent(event)
focused_in = False
if event.button() == QtCore.Qt.LeftButton:
focused_in = True
self.focused_in()

result = super(BaseWidget, self).mouseReleaseEvent(event)
if focused_in and not event.isAccepted():
event.accept()
return result


class InputWidget(BaseWidget):
Expand Down Expand Up @@ -337,6 +381,14 @@ def _add_inputs_to_layout(self):
)
)

def make_sure_is_visible(self, path, scroll_to):
if path:
entity_path = self.entity.path
if entity_path == path:
self.set_focus(scroll_to)
return True
return False

def update_style(self):
has_unsaved_changes = self.entity.has_unsaved_changes
if not has_unsaved_changes and self.entity.group_item:
Expand Down Expand Up @@ -422,11 +474,20 @@ def _create_separator_ui(self):
layout.addWidget(splitter_item)

def set_entity_value(self):
return
pass

def hierarchical_style_update(self):
pass

def make_sure_is_visible(self, *args, **kwargs):
return False

def focused_in(self):
pass

def set_path(self, *args, **kwargs):
pass

def get_invalid(self):
return []

Expand Down
Loading

0 comments on commit 2535b08

Please sign in to comment.