mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
make both paste secure with dialog poopup
This commit is contained in:
parent
daf12bb973
commit
9c02ecb35a
1 changed files with 16 additions and 11 deletions
|
|
@ -180,8 +180,10 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
|
||||
def _paste_value_actions(self, menu):
|
||||
output = []
|
||||
# Allow paste of value only if were copied from this UI
|
||||
mime_data = QtWidgets.QApplication.clipboard().mimeData()
|
||||
mime_value = mime_data.data("application/copy_settings_value")
|
||||
# Skip if there is nothing to do
|
||||
if not mime_value:
|
||||
return output
|
||||
|
||||
|
|
@ -206,18 +208,9 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
# Paste value to matchin entity
|
||||
def paste_value_to_path():
|
||||
matching_entity.set(value)
|
||||
|
||||
if matching_entity is not None:
|
||||
action = QtWidgets.QAction("Paste to same entity", menu)
|
||||
output.append((action, paste_value_to_path))
|
||||
|
||||
# Simple paste value method
|
||||
def paste_value():
|
||||
def _set_entity_value(_entity, _value):
|
||||
try:
|
||||
self.entity.set(value)
|
||||
_entity.set(_value)
|
||||
except Exception:
|
||||
dialog = QtWidgets.QMessageBox(self)
|
||||
dialog.setWindowTitle("Value does not match settings schema")
|
||||
|
|
@ -228,6 +221,18 @@ class BaseWidget(QtWidgets.QWidget):
|
|||
))
|
||||
dialog.exec_()
|
||||
|
||||
# Paste value to matchin entity
|
||||
def paste_value_to_path():
|
||||
_set_entity_value(matching_entity, value)
|
||||
|
||||
if matching_entity is not None:
|
||||
action = QtWidgets.QAction("Paste to same entity", menu)
|
||||
output.append((action, paste_value_to_path))
|
||||
|
||||
# Simple paste value method
|
||||
def paste_value():
|
||||
_set_entity_value(self.entity, value)
|
||||
|
||||
action = QtWidgets.QAction("Paste")
|
||||
output.append((action, paste_value))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue