From 0a708199701af028cfb2d8ea542c705c21bb94e8 Mon Sep 17 00:00:00 2001 From: alby128 Date: Fri, 15 Sep 2017 16:12:43 +0200 Subject: [PATCH] Fixes issue #146 on shared playlists --- syncplay/ui/gui.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index a2e1eb5..1a1f023 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -11,6 +11,8 @@ import os from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration, RoomPasswordProvider, formatSize, isURL from functools import wraps from twisted.internet import task +if sys.platform.startswith('darwin'): + from Foundation import NSURL lastCheckedForUpdates = None class UserlistItemDelegate(QtGui.QStyledItemDelegate): @@ -161,7 +163,10 @@ class MainWindow(QtGui.QMainWindow): indexRow = window.playlist.count() if window.clearedPlaylistNote else 0 for url in urls[::-1]: - dropfilepath = os.path.abspath(unicode(url.toLocalFile())) + if sys.platform.startswith('darwin'): + dropfilepath = os.path.abspath(NSURL.URLWithString_(str(url.toString())).filePathURL().path()) + else: + dropfilepath = os.path.abspath(unicode(url.toLocalFile())) if os.path.isfile(dropfilepath): window.addFileToPlaylist(dropfilepath, indexRow) elif os.path.isdir(dropfilepath): @@ -263,7 +268,10 @@ class MainWindow(QtGui.QMainWindow): if indexRow == -1: indexRow = window.playlist.count() for url in urls[::-1]: - dropfilepath = os.path.abspath(unicode(url.toLocalFile())) + if sys.platform.startswith('darwin'): + dropfilepath = os.path.abspath(NSURL.URLWithString_(str(url.toString())).filePathURL().path()) + else: + dropfilepath = os.path.abspath(unicode(url.toLocalFile())) if os.path.isfile(dropfilepath): window.addFileToPlaylist(dropfilepath, indexRow) elif os.path.isdir(dropfilepath): @@ -809,7 +817,10 @@ class MainWindow(QtGui.QMainWindow): return self.loadMediaBrowseSettings() - options = QtGui.QFileDialog.Options() + if sys.platform.startswith('darwin'): + options = QtGui.QFileDialog.Options(QtGui.QFileDialog.DontUseNativeDialog) + else: + options = QtGui.QFileDialog.Options() self.mediadirectory = "" currentdirectory = os.path.dirname(self._syncplayClient.userlist.currentUser.file["path"]) if self._syncplayClient.userlist.currentUser.file else None if currentdirectory and os.path.isdir(currentdirectory): @@ -1489,7 +1500,10 @@ class MainWindow(QtGui.QMainWindow): data = event.mimeData() urls = data.urls() if urls and urls[0].scheme() == 'file': - dropfilepath = os.path.abspath(unicode(event.mimeData().urls()[0].toLocalFile())) + if sys.platform.startswith('darwin'): + dropfilepath = os.path.abspath(NSURL.URLWithString_(str(event.mimeData().urls()[0].toString())).filePathURL().path()) + else: + dropfilepath = os.path.abspath(unicode(event.mimeData().urls()[0].toLocalFile())) if rewindFile == False: self._syncplayClient._player.openFile(dropfilepath) else: