mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
Add CopyToClipboard global action
This commit is contained in:
parent
e06d2fe8f5
commit
cdfe8401dc
1 changed files with 32 additions and 0 deletions
32
colorbleed/plugins/global/load/copy_to_clipboard.py
Normal file
32
colorbleed/plugins/global/load/copy_to_clipboard.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from avalon import api
|
||||
|
||||
|
||||
class CopyToClipboardLoader(api.Loader):
|
||||
"""Copy published file to clipboard to allow to paste the content"""
|
||||
representations = ["*"]
|
||||
families = ["*"]
|
||||
|
||||
label = "Copy to Clipboard"
|
||||
order = 20
|
||||
icon = "clipboard"
|
||||
color = "#999999"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
self.log.info("Added to clipboard: {0}".format(self.fname))
|
||||
self.copy_file_to_clipboard(self.fname)
|
||||
|
||||
@staticmethod
|
||||
def copy_file_to_clipboard(path):
|
||||
from avalon.vendor.Qt import QtCore, QtWidgets
|
||||
|
||||
app = QtWidgets.QApplication.instance()
|
||||
assert app, "Must have running QApplication instance"
|
||||
|
||||
# Build mime data for clipboard
|
||||
mime = QtCore.QMimeData()
|
||||
mime.setText(path)
|
||||
mime.setUrls([QtCore.QUrl.fromLocalFile(path)])
|
||||
|
||||
# Set to Clipboard
|
||||
clipboard = app.clipboard()
|
||||
clipboard.setMimeData(mime)
|
||||
Loading…
Add table
Add a link
Reference in a new issue