mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
refactored duplicate to copy file path
This commit is contained in:
parent
d4ae8b7c50
commit
d2dc4332f3
1 changed files with 8 additions and 11 deletions
|
|
@ -1,32 +1,29 @@
|
|||
import os
|
||||
|
||||
from avalon import api
|
||||
|
||||
|
||||
class CopyToClipboardLoader(api.Loader):
|
||||
"""Copy published file to clipboard to allow to paste the content"""
|
||||
class CopyFilePath(api.Loader):
|
||||
"""Copy published file path to clipboard"""
|
||||
representations = ["*"]
|
||||
families = ["*"]
|
||||
|
||||
label = "Copy file path to Clipboard"
|
||||
label = "Copy File Path"
|
||||
order = 20
|
||||
icon = "clipboard"
|
||||
color = "#999999"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
self.log.info("Added file path to clipboard: {0}".format(self.fname))
|
||||
self.copy_file_to_clipboard(self.fname)
|
||||
self.copy_path_to_clipboard(self.fname)
|
||||
|
||||
@staticmethod
|
||||
def copy_file_to_clipboard(path):
|
||||
def copy_path_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)
|
||||
clipboard.setText(os.path.normpath(path))
|
||||
Loading…
Add table
Add a link
Reference in a new issue