mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +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):
|
def _paste_value_actions(self, menu):
|
||||||
output = []
|
output = []
|
||||||
|
# Allow paste of value only if were copied from this UI
|
||||||
mime_data = QtWidgets.QApplication.clipboard().mimeData()
|
mime_data = QtWidgets.QApplication.clipboard().mimeData()
|
||||||
mime_value = mime_data.data("application/copy_settings_value")
|
mime_value = mime_data.data("application/copy_settings_value")
|
||||||
|
# Skip if there is nothing to do
|
||||||
if not mime_value:
|
if not mime_value:
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
@ -206,18 +208,9 @@ class BaseWidget(QtWidgets.QWidget):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Paste value to matchin entity
|
def _set_entity_value(_entity, _value):
|
||||||
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():
|
|
||||||
try:
|
try:
|
||||||
self.entity.set(value)
|
_entity.set(_value)
|
||||||
except Exception:
|
except Exception:
|
||||||
dialog = QtWidgets.QMessageBox(self)
|
dialog = QtWidgets.QMessageBox(self)
|
||||||
dialog.setWindowTitle("Value does not match settings schema")
|
dialog.setWindowTitle("Value does not match settings schema")
|
||||||
|
|
@ -228,6 +221,18 @@ class BaseWidget(QtWidgets.QWidget):
|
||||||
))
|
))
|
||||||
dialog.exec_()
|
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")
|
action = QtWidgets.QAction("Paste")
|
||||||
output.append((action, paste_value))
|
output.append((action, paste_value))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue