Fixes issue #146 on shared playlists

This commit is contained in:
alby128 2017-09-15 16:12:43 +02:00
parent 1b873d16e3
commit 0a70819970

View File

@ -11,6 +11,8 @@ import os
from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration, RoomPasswordProvider, formatSize, isURL from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration, RoomPasswordProvider, formatSize, isURL
from functools import wraps from functools import wraps
from twisted.internet import task from twisted.internet import task
if sys.platform.startswith('darwin'):
from Foundation import NSURL
lastCheckedForUpdates = None lastCheckedForUpdates = None
class UserlistItemDelegate(QtGui.QStyledItemDelegate): class UserlistItemDelegate(QtGui.QStyledItemDelegate):
@ -161,6 +163,9 @@ class MainWindow(QtGui.QMainWindow):
indexRow = window.playlist.count() if window.clearedPlaylistNote else 0 indexRow = window.playlist.count() if window.clearedPlaylistNote else 0
for url in urls[::-1]: for url in urls[::-1]:
if sys.platform.startswith('darwin'):
dropfilepath = os.path.abspath(NSURL.URLWithString_(str(url.toString())).filePathURL().path())
else:
dropfilepath = os.path.abspath(unicode(url.toLocalFile())) dropfilepath = os.path.abspath(unicode(url.toLocalFile()))
if os.path.isfile(dropfilepath): if os.path.isfile(dropfilepath):
window.addFileToPlaylist(dropfilepath, indexRow) window.addFileToPlaylist(dropfilepath, indexRow)
@ -263,6 +268,9 @@ class MainWindow(QtGui.QMainWindow):
if indexRow == -1: if indexRow == -1:
indexRow = window.playlist.count() indexRow = window.playlist.count()
for url in urls[::-1]: for url in urls[::-1]:
if sys.platform.startswith('darwin'):
dropfilepath = os.path.abspath(NSURL.URLWithString_(str(url.toString())).filePathURL().path())
else:
dropfilepath = os.path.abspath(unicode(url.toLocalFile())) dropfilepath = os.path.abspath(unicode(url.toLocalFile()))
if os.path.isfile(dropfilepath): if os.path.isfile(dropfilepath):
window.addFileToPlaylist(dropfilepath, indexRow) window.addFileToPlaylist(dropfilepath, indexRow)
@ -809,6 +817,9 @@ class MainWindow(QtGui.QMainWindow):
return return
self.loadMediaBrowseSettings() self.loadMediaBrowseSettings()
if sys.platform.startswith('darwin'):
options = QtGui.QFileDialog.Options(QtGui.QFileDialog.DontUseNativeDialog)
else:
options = QtGui.QFileDialog.Options() options = QtGui.QFileDialog.Options()
self.mediadirectory = "" self.mediadirectory = ""
currentdirectory = os.path.dirname(self._syncplayClient.userlist.currentUser.file["path"]) if self._syncplayClient.userlist.currentUser.file else None currentdirectory = os.path.dirname(self._syncplayClient.userlist.currentUser.file["path"]) if self._syncplayClient.userlist.currentUser.file else None
@ -1489,6 +1500,9 @@ class MainWindow(QtGui.QMainWindow):
data = event.mimeData() data = event.mimeData()
urls = data.urls() urls = data.urls()
if urls and urls[0].scheme() == 'file': if urls and urls[0].scheme() == 'file':
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())) dropfilepath = os.path.abspath(unicode(event.mimeData().urls()[0].toLocalFile()))
if rewindFile == False: if rewindFile == False:
self._syncplayClient._player.openFile(dropfilepath) self._syncplayClient._player.openFile(dropfilepath)