mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
implemented set_value for each attribute def widget
This commit is contained in:
parent
42870fa159
commit
ecf85225bb
1 changed files with 31 additions and 0 deletions
|
|
@ -61,6 +61,13 @@ class _BaseAttrDefWidget(QtWidgets.QWidget):
|
|||
)
|
||||
)
|
||||
|
||||
def set_value(self, value):
|
||||
raise NotImplementedError(
|
||||
"Method 'current_value' is not implemented. {}".format(
|
||||
self.__class__.__name__
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class NumberAttrWidget(_BaseAttrDefWidget):
|
||||
def _ui_init(self):
|
||||
|
|
@ -91,6 +98,10 @@ class NumberAttrWidget(_BaseAttrDefWidget):
|
|||
def current_value(self):
|
||||
return self._input_widget.value()
|
||||
|
||||
def set_value(self, value):
|
||||
if self.current_value != value:
|
||||
self._input_widget.setValue(value)
|
||||
|
||||
|
||||
class TextAttrWidget(_BaseAttrDefWidget):
|
||||
def _ui_init(self):
|
||||
|
|
@ -130,6 +141,14 @@ class TextAttrWidget(_BaseAttrDefWidget):
|
|||
return self._input_widget.toPlainText()
|
||||
return self._input_widget.text()
|
||||
|
||||
def set_value(self, value):
|
||||
if value == self.current_value():
|
||||
return
|
||||
if self.multiline:
|
||||
self._input_widget.setPlainText(value)
|
||||
else:
|
||||
self._input_widget.setText(value)
|
||||
|
||||
|
||||
class BoolAttrWidget(_BaseAttrDefWidget):
|
||||
def _ui_init(self):
|
||||
|
|
@ -149,6 +168,10 @@ class BoolAttrWidget(_BaseAttrDefWidget):
|
|||
def current_value(self):
|
||||
return self._input_widget.isChecked()
|
||||
|
||||
def set_value(self, value):
|
||||
if value != self.current_value():
|
||||
self._input_widget.setChecked(value)
|
||||
|
||||
|
||||
class EnumAttrWidget(_BaseAttrDefWidget):
|
||||
def _ui_init(self):
|
||||
|
|
@ -178,3 +201,11 @@ class EnumAttrWidget(_BaseAttrDefWidget):
|
|||
def current_value(self):
|
||||
idx = self._input_widget.currentIndex()
|
||||
return self._input_widget.itemData(idx)
|
||||
|
||||
def set_value(self, value):
|
||||
idx = self._input_widget.findData(value)
|
||||
cur_idx = self._input_widget.currentIndex()
|
||||
if idx == cur_idx:
|
||||
return
|
||||
if idx >= 0:
|
||||
self._input_widget.setCurrentIndex(idx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue