mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 08:54:53 +01:00
implemented get_invalid to be able change focus to the invalid widget
This commit is contained in:
parent
eacf8cd401
commit
fc9d199437
5 changed files with 60 additions and 1 deletions
|
|
@ -41,6 +41,13 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
)
|
||||
)
|
||||
|
||||
def get_invalid(self):
|
||||
raise NotImplementedError(
|
||||
"{} not implemented `get_invalid`".format(
|
||||
self.__class__.__name__
|
||||
)
|
||||
)
|
||||
|
||||
def show_actions_menu(self, event):
|
||||
print("Show actions for {}".format(self.entity.path))
|
||||
|
||||
|
|
@ -71,6 +78,12 @@ class InputWidget(BaseWidget):
|
|||
def hierarchical_style_update(self):
|
||||
self.update_style()
|
||||
|
||||
def get_invalid(self):
|
||||
invalid = []
|
||||
if self.is_invalid:
|
||||
invalid.append(self)
|
||||
return invalid
|
||||
|
||||
|
||||
class GUIWidget(BaseWidget):
|
||||
separator_height = 2
|
||||
|
|
@ -115,3 +128,6 @@ class GUIWidget(BaseWidget):
|
|||
|
||||
def hierarchical_style_update(self):
|
||||
pass
|
||||
|
||||
def get_invalid(self):
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -460,7 +460,16 @@ class SystemWidget(SettingsCategoryWidget):
|
|||
print("*** validate_defaults_to_save")
|
||||
|
||||
def save(self):
|
||||
self.entity.save()
|
||||
invalid = self.get_invalid()
|
||||
if not invalid:
|
||||
self.entity.save()
|
||||
return
|
||||
|
||||
def get_invalid(self):
|
||||
invalid = []
|
||||
for input_field in self.input_fields:
|
||||
invalid.extend(input_field.get_invalid())
|
||||
return invalid
|
||||
|
||||
def update_values(self):
|
||||
self.entity.reset()
|
||||
|
|
|
|||
|
|
@ -434,6 +434,13 @@ class ModifiableDictItem(QtWidgets.QWidget):
|
|||
def is_invalid(self):
|
||||
return self.is_key_duplicated or self.input_field.is_invalid
|
||||
|
||||
def get_invalid(self):
|
||||
invalid = []
|
||||
if self.is_key_duplicated:
|
||||
invalid.append(self.key_input)
|
||||
invalid.extend(self.input_field.get_invalid())
|
||||
return invalid
|
||||
|
||||
def update_style(self):
|
||||
key_input_state = ""
|
||||
if self.is_key_duplicated or self.key_value() == "":
|
||||
|
|
@ -550,6 +557,12 @@ class DictMutableKeysWidget(BaseWidget):
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_invalid(self):
|
||||
invalid = []
|
||||
for input_field in self.input_fields:
|
||||
invalid.extend(input_field.get_invalid())
|
||||
return invalid
|
||||
|
||||
def add_required_keys(self):
|
||||
# TODO implement
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -181,6 +181,12 @@ class DictImmutableKeysWidget(BaseWidget):
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_invalid(self):
|
||||
invalid = []
|
||||
for input_field in self.input_fields:
|
||||
invalid.extend(input_field.get_invalid())
|
||||
return invalid
|
||||
|
||||
def _on_entity_change(self):
|
||||
print("_on_entity_change", self.__class__.__name__, self.entity.path)
|
||||
|
||||
|
|
@ -465,6 +471,9 @@ class PathWidget(BaseWidget):
|
|||
def _on_entity_change(self):
|
||||
print("_on_entity_change", self.__class__.__name__, self.entity.path)
|
||||
|
||||
def get_invalid(self):
|
||||
return self.input_field.get_invalid()
|
||||
|
||||
|
||||
class PathInputWidget(InputWidget):
|
||||
def create_ui(self, label_widget=None):
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ class ListItem(QtWidgets.QWidget):
|
|||
|
||||
self.spacer_widget = spacer_widget
|
||||
|
||||
def get_invalid(self):
|
||||
return self.input_field.get_invalid()
|
||||
|
||||
def add_widget_to_layout(self, widget, label=None):
|
||||
self.content_layout.addWidget(widget, 1)
|
||||
|
||||
|
|
@ -230,6 +233,15 @@ class ListWidget(InputWidget):
|
|||
|
||||
self.empty_row.setVisible(self.count() == 0)
|
||||
|
||||
def get_invalid(self):
|
||||
invalid = []
|
||||
if self.is_invalid:
|
||||
invalid.append(self)
|
||||
|
||||
for input_field in self.input_fields:
|
||||
invalid.extend(input_field.get_invalid())
|
||||
return invalid
|
||||
|
||||
def _on_value_change(self):
|
||||
print("_on_value_change", self.__class__.__name__, self.entity.path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue