diff --git a/picard/ui/coverartbox.py b/picard/ui/coverartbox.py index ba145e059..5efbddbb4 100644 --- a/picard/ui/coverartbox.py +++ b/picard/ui/coverartbox.py @@ -30,14 +30,6 @@ from picard.util import imageinfo from picard.util.lrucache import LRUCache from picard.const import MAX_COVERS_TO_STACK -if sys.platform == 'darwin': - try: - from Foundation import NSURL - NSURL_IMPORTED = True - except ImportError: - NSURL_IMPORTED = False - log.warning("Unable to import NSURL, file drag'n'drop might not work correctly") - class ActiveLabel(QtWidgets.QLabel): """Clickable QLabel.""" @@ -344,18 +336,7 @@ class CoverArtBox(QtWidgets.QGroupBox): xml=False, priority=True, important=True) elif url.scheme() == 'file': - log.debug("Dropped the URL: %r", url.toString(QtCore.QUrl.RemoveUserInfo)) - if sys.platform == 'darwin' and url.path().startswith('/.file/id='): - # Workaround for https://bugreports.qt.io/browse/QTBUG-40449 - # OSX Urls follow the NSURL scheme and need to be converted - if NSURL_IMPORTED: - path = os.path.normpath(os.path.realpath(NSURL.URLWithString_(string_(url.toString()).filePathURL().path()).rstrip("\0"))) - log.debug('OSX NSURL path detected. Dropped File is: %r', path) - else: - log.error("Unable to get appropriate file path for %r", url.toString(QtCore.QUrl.RemoveUserInfo)) - else: - # Dropping a file from iTunes gives a path with a NULL terminator - path = os.path.normpath(os.path.realpath(url.toLocalFile().rstrip("\0"))) + path = os.path.normpath(os.path.realpath(url.toLocalFile().rstrip("\0"))) if path and os.path.exists(path): mime = 'image/png' if path.lower().endswith('.png') else 'image/jpeg' with open(path, 'rb') as f: diff --git a/picard/ui/itemviews.py b/picard/ui/itemviews.py index 27143f216..418770f4a 100644 --- a/picard/ui/itemviews.py +++ b/picard/ui/itemviews.py @@ -32,14 +32,6 @@ from picard.plugin import ExtensionPoint from picard.ui.ratingwidget import RatingWidget from picard.ui.collectionmenu import CollectionMenu -if sys.platform == 'darwin': - try: - from Foundation import NSURL - NSURL_IMPORTED = True - except ImportError: - NSURL_IMPORTED = False - log.warning("Unable to import NSURL, file drag'n'drop might not work correctly") - class BaseAction(QtWidgets.QAction): NAME = "Unknown" @@ -478,18 +470,7 @@ class BaseTreeView(QtWidgets.QTreeWidget): for url in urls: log.debug("Dropped the URL: %r", url.toString(QtCore.QUrl.RemoveUserInfo)) if url.scheme() == "file" or not url.scheme(): - if sys.platform == 'darwin' and url.path().startswith('/.file/id='): - # Workaround for https://bugreports.qt.io/browse/QTBUG-40449 - # OSX Urls follow the NSURL scheme and need to be converted - if NSURL_IMPORTED: - filename = os.path.normpath(os.path.realpath(NSURL.URLWithString_(url.toString().filePathURL().path()).rstrip("\0"))) - log.debug('OSX NSURL path detected. Dropped File is: %r', filename) - else: - log.error("Unable to get appropriate file path for %r", url.toString(QtCore.QUrl.RemoveUserInfo)) - continue - else: - # Dropping a file from iTunes gives a filename with a NULL terminator - filename = os.path.normpath(os.path.realpath(url.toLocalFile().rstrip("\0"))) + filename = os.path.normpath(os.path.realpath(url.toLocalFile().rstrip("\0"))) file = BaseTreeView.tagger.files.get(filename) if file: files.append(file)