mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
Merge pull request #149 from aardschok/PLN-105
Refactored standalone plugins
This commit is contained in:
commit
a7102fd709
2 changed files with 12 additions and 17 deletions
|
|
@ -24,12 +24,10 @@ class CopyFile(api.Loader):
|
|||
assert app, "Must have running QApplication instance"
|
||||
|
||||
# Build mime data for clipboard
|
||||
file_path = QtCore.QUrl.fromLocalFile(path)
|
||||
byte_array = QtCore.QByteArray("copy\n").append(file_path)
|
||||
|
||||
mime = QtCore.QMimeData()
|
||||
mime.setData("text/uri-list", byte_array)
|
||||
data = QtCore.QMimeData()
|
||||
url = QtCore.QUrl.fromLocalFile(path)
|
||||
data.setUrls([url])
|
||||
|
||||
# Set to Clipboard
|
||||
clipboard = app.clipboard()
|
||||
clipboard.setMimeData(mime)
|
||||
clipboard.setMimeData(data)
|
||||
|
|
|
|||
|
|
@ -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