Initial code for double click to change to user's file/stream (#65 suggested by bitingsock)

This commit is contained in:
Et0h 2015-06-18 17:54:10 +01:00
parent 4fa0a9b921
commit 4931cc3720
4 changed files with 39 additions and 14 deletions

View File

@ -399,7 +399,7 @@ class SyncplayClient(object):
except: except:
size = 0 size = 0
filename, size = self.__executePrivacySettings(filename, size) filename, size = self.__executePrivacySettings(filename, size)
self.userlist.currentUser.setFile(filename, duration, size) self.userlist.currentUser.setFile(filename, duration, size, path)
self.sendFile() self.sendFile()
def __executePrivacySettings(self, filename, size): def __executePrivacySettings(self, filename, size):
@ -796,11 +796,12 @@ class SyncplayUser(object):
self.file = file_ self.file = file_
self._controller = False self._controller = False
def setFile(self, filename, duration, size): def setFile(self, filename, duration, size, path=None):
file_ = { file_ = {
"name": filename, "name": filename,
"duration": duration, "duration": duration,
"size": size "size": size,
"path": path
} }
self.file = file_ self.file = file_

View File

@ -3,6 +3,7 @@ from PySide.QtCore import QSettings, Qt, QCoreApplication, QUrl
from PySide.QtGui import QApplication, QLineEdit, QCursor, QLabel, QCheckBox, QDesktopServices, QIcon, QImage, QButtonGroup, QRadioButton, QDoubleSpinBox from PySide.QtGui import QApplication, QLineEdit, QCursor, QLabel, QCheckBox, QDesktopServices, QIcon, QImage, QButtonGroup, QRadioButton, QDoubleSpinBox
from syncplay.players.playerFactory import PlayerFactory from syncplay.players.playerFactory import PlayerFactory
from datetime import datetime from datetime import datetime
from syncplay import utils
import os import os
import sys import sys
from syncplay.messages import getMessage, getLanguages, setLanguage, getInitialLanguage from syncplay.messages import getMessage, getLanguages, setLanguage, getInitialLanguage
@ -77,15 +78,10 @@ class ConfigDialog(QtGui.QDialog):
def openHelp(self): def openHelp(self):
self.QtGui.QDesktopServices.openUrl(QUrl("http://syncplay.pl/guide/client/")) self.QtGui.QDesktopServices.openUrl(QUrl("http://syncplay.pl/guide/client/"))
def _isURL(self, path):
if path is None:
return False
if "http://" in path:
return True
def safenormcaseandpath(self, path): def safenormcaseandpath(self, path):
if self._isURL(path): if utils.isURL(path):
return path return path
else: else:
return os.path.normcase(os.path.normpath(path)) return os.path.normcase(os.path.normpath(path))
@ -104,7 +100,7 @@ class ConfigDialog(QtGui.QDialog):
foundpath = "" foundpath = ""
if playerpath != None and playerpath != "": if playerpath != None and playerpath != "":
if self._isURL(playerpath): if utils.isURL(playerpath):
foundpath = playerpath foundpath = playerpath
self.executablepathCombobox.addItem(foundpath) self.executablepathCombobox.addItem(foundpath)
@ -119,7 +115,7 @@ class ConfigDialog(QtGui.QDialog):
self.executablepathCombobox.addItem(foundpath) self.executablepathCombobox.addItem(foundpath)
for path in playerpathlist: for path in playerpathlist:
if self._isURL(path): if utils.isURL(path):
if foundpath == "": if foundpath == "":
foundpath = path foundpath = path
if path != playerpath: if path != playerpath:
@ -821,7 +817,6 @@ class ConfigDialog(QtGui.QDialog):
def __init__(self, config, playerpaths, error, defaultConfig): def __init__(self, config, playerpaths, error, defaultConfig):
from syncplay import utils
self.config = config self.config = config
self.defaultConfig = defaultConfig self.defaultConfig = defaultConfig
self.playerpaths = playerpaths self.playerpaths = playerpaths

View File

@ -7,7 +7,7 @@ import time
from datetime import datetime from datetime import datetime
import re import re
import os import os
from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration, RoomPasswordProvider, formatSize from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration, RoomPasswordProvider, formatSize, isURL
from functools import wraps from functools import wraps
lastCheckedForUpdates = None lastCheckedForUpdates = None
@ -230,9 +230,28 @@ class MainWindow(QtGui.QMainWindow):
self.updateReadyIcon() self.updateReadyIcon()
def roomClicked(self, item): def roomClicked(self, item):
username = item.sibling(item.row(), 0).data()
filename = item.sibling(item.row(), 3).data()
while item.parent().row() != -1: while item.parent().row() != -1:
item = item.parent() item = item.parent()
self.joinRoom(item.sibling(item.row(), 0).data()) roomToJoin = item.sibling(item.row(), 0).data()
if roomToJoin <> self._syncplayClient.getRoom():
self.joinRoom(item.sibling(item.row(), 0).data())
elif username and filename and username <> self._syncplayClient.userlist.currentUser.username:
if self._syncplayClient.userlist.currentUser.file and filename == self._syncplayClient.userlist.currentUser.file:
return
if isURL(filename):
self._syncplayClient._player.openFile(filename) #bob
else:
currentPath = self._syncplayClient.userlist.currentUser.file["path"]
if currentPath is not None:
currentDirectory = os.path.dirname(currentPath)
newPath = os.path.join(currentDirectory, filename)
if os.path.isfile(newPath):
self._syncplayClient._player.openFile(newPath)
# TODO: Add error messages
# TODO: Change media players (mpv/VLC) to give URL of stream
@needsClient @needsClient
def userListChange(self): def userListChange(self):

View File

@ -218,6 +218,16 @@ def meetsMinVersion(version, minVersion):
return tuple(map(int, ver.split("."))) return tuple(map(int, ver.split(".")))
return versiontotuple(version) >= versiontotuple(minVersion) return versiontotuple(version) >= versiontotuple(minVersion)
def isURL(path):
if path is None:
return False
if "http://" in path:
return True
elif "https://" in path:
return True
class RoomPasswordProvider(object): class RoomPasswordProvider(object):
CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$") CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$")
PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}") PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}")