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 = [
r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe",
r"C:\Program Files\VideoLAN\VLC\vlc.exe",
"/usr/bin/vlc",
"/Applications/VLC.app/Contents/MacOS/VLC"
]

View File

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

View File

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