fix drag and drop issues on macOS
This commit is contained in:
parent
7e8fc143fd
commit
0766bf7064
@ -28,7 +28,7 @@ import pickle
|
||||
|
||||
from PyQt4 import QtCore, QtGui, uic
|
||||
from PyQt4 import QtNetwork
|
||||
#from PyQt4.QtCore import QUrl, pyqtSignal
|
||||
from PyQt4.QtCore import QString, QUrl
|
||||
|
||||
#from comicarchive import ComicArchive
|
||||
#from pageloader import PageLoader
|
||||
@ -585,11 +585,41 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
if url.isValid() and url.scheme() == "file":
|
||||
if self.droppedFiles is None:
|
||||
self.droppedFiles = []
|
||||
self.droppedFiles.append(url.toLocalFile())
|
||||
self.droppedFiles.append(self.getUrlFromLocalFileID(url))
|
||||
|
||||
if self.droppedFiles is not None:
|
||||
event.accept()
|
||||
|
||||
# http://stackoverflow.com/questions/34689562/pyqt-mimedata-filename
|
||||
def getUrlFromLocalFileID(self, localFileID):
|
||||
import sys
|
||||
if not sys.platform == 'darwin':
|
||||
return localFileID.toLocalFile()
|
||||
|
||||
import objc
|
||||
import CoreFoundation as CF
|
||||
localFileQString = QString(localFileID.toLocalFile())
|
||||
relCFStringRef = CF.CFStringCreateWithCString(
|
||||
CF.kCFAllocatorDefault,
|
||||
localFileQString.toUtf8(),
|
||||
CF.kCFStringEncodingUTF8
|
||||
)
|
||||
relCFURL = CF.CFURLCreateWithFileSystemPath(
|
||||
CF.kCFAllocatorDefault,
|
||||
relCFStringRef,
|
||||
CF.kCFURLPOSIXPathStyle,
|
||||
False # is directory
|
||||
)
|
||||
absCFURL = CF.CFURLCreateFilePathURL(
|
||||
CF.kCFAllocatorDefault,
|
||||
relCFURL,
|
||||
objc.NULL
|
||||
)
|
||||
|
||||
local = QUrl(str(absCFURL[0])).toLocalFile()
|
||||
|
||||
return local
|
||||
|
||||
def dropEvent(self, event):
|
||||
# if self.dirtyFlagVerification("Open Archive",
|
||||
# "If you open a new archive now, data in the form will be lost. Are you sure?"):
|
||||
|
Loading…
x
Reference in New Issue
Block a user