Hopefully improve cross-platform compatibility (esp. OSX)

This commit is contained in:
Et0h 2014-07-05 11:14:02 +01:00
parent 9bb3edc1db
commit be183e2b7d
3 changed files with 15 additions and 12 deletions

View File

@ -64,6 +64,7 @@ MPV_PATHS = ["mpv", "/opt/mpv/mpv", r"C:\Program Files\mpv\mpv.exe", r"C:\Progra
VLC_PATHS = [ VLC_PATHS = [
r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe", r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",
r"C:\Program Files\VideoLAN\VLC\vlc.exe", r"C:\Program Files\VideoLAN\VLC\vlc.exe",
"/usr/bin/vlc",
"/Applications/VLC.app/Contents/MacOS/VLC" "/Applications/VLC.app/Contents/MacOS/VLC"
] ]

View File

@ -122,6 +122,8 @@ class ConfigDialog(QtGui.QDialog):
defaultdirectory = os.environ["ProgramW6432"] defaultdirectory = os.environ["ProgramW6432"]
elif sys.platform.startswith('linux'): elif sys.platform.startswith('linux'):
defaultdirectory = "/usr/bin" defaultdirectory = "/usr/bin"
elif sys.platform.startswith('darwin'):
defaultdirectory = "/Applications/"
fileName, filtr = QtGui.QFileDialog.getOpenFileName(self, fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,
"Browse for media player executable", "Browse for media player executable",
@ -247,10 +249,10 @@ class ConfigDialog(QtGui.QDialog):
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('linux'): if sys.platform.startswith('windows'):
dropfilepath = unicode(urls[0].path())
else:
dropfilepath = unicode(urls[0].path())[1:] # Removes starting slash dropfilepath = unicode(urls[0].path())[1:] # Removes starting slash
else:
dropfilepath = unicode(urls[0].path())
if dropfilepath[-4:].lower() == ".exe": if dropfilepath[-4:].lower() == ".exe":
self.executablepathCombobox.setEditText(dropfilepath) self.executablepathCombobox.setEditText(dropfilepath)
else: else:
@ -273,10 +275,10 @@ class ConfigDialog(QtGui.QDialog):
self.datacleared = True self.datacleared = True
self.QtGui = QtGui self.QtGui = QtGui
self.error = error self.error = error
if sys.platform.startswith('linux'): if sys.platform.startswith('windows'):
resourcespath = utils.findWorkingDir() + "/resources/"
else:
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + "\\resources\\"
else:
resourcespath = utils.findWorkingDir() + "/resources/"
self.resourcespath = resourcespath self.resourcespath = resourcespath
super(ConfigDialog, self).__init__() super(ConfigDialog, self).__init__()

View File

@ -411,10 +411,10 @@ 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('linux'): if sys.platform.startswith('win'):
dropfilepath = unicode(urls[0].path())
else:
dropfilepath = unicode(urls[0].path().replace("/", "\\"))[1:] # Removes starting slash dropfilepath = unicode(urls[0].path().replace("/", "\\"))[1:] # Removes starting slash
else:
dropfilepath = unicode(urls[0].path())
if rewindFile == False: if rewindFile == False:
self._syncplayClient._player.openFile(dropfilepath) self._syncplayClient._player.openFile(dropfilepath)
else: else:
@ -439,10 +439,10 @@ class MainWindow(QtGui.QMainWindow):
def __init__(self): def __init__(self):
super(MainWindow, self).__init__() super(MainWindow, self).__init__()
self.QtGui = QtGui self.QtGui = QtGui
if sys.platform.startswith('linux'): if sys.platform.startswith('win'):
self.resourcespath = utils.findWorkingDir() + "/resources/"
else:
self.resourcespath = utils.findWorkingDir() + "\\resources\\" self.resourcespath = utils.findWorkingDir() + "\\resources\\"
else:
self.resourcespath = utils.findWorkingDir() + "/resources/"
self.setWindowTitle("Syncplay v" + version) self.setWindowTitle("Syncplay v" + version)
self.mainLayout = QtGui.QVBoxLayout() self.mainLayout = QtGui.QVBoxLayout()
self.addTopLayout(self) self.addTopLayout(self)