mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-19 04:26:50 +00:00
Initial code for double click to change to user's file/stream (#65 suggested by bitingsock)
This commit is contained in:
parent
4fa0a9b921
commit
4931cc3720
@ -399,7 +399,7 @@ class SyncplayClient(object):
|
||||
except:
|
||||
size = 0
|
||||
filename, size = self.__executePrivacySettings(filename, size)
|
||||
self.userlist.currentUser.setFile(filename, duration, size)
|
||||
self.userlist.currentUser.setFile(filename, duration, size, path)
|
||||
self.sendFile()
|
||||
|
||||
def __executePrivacySettings(self, filename, size):
|
||||
@ -796,11 +796,12 @@ class SyncplayUser(object):
|
||||
self.file = file_
|
||||
self._controller = False
|
||||
|
||||
def setFile(self, filename, duration, size):
|
||||
def setFile(self, filename, duration, size, path=None):
|
||||
file_ = {
|
||||
"name": filename,
|
||||
"duration": duration,
|
||||
"size": size
|
||||
"size": size,
|
||||
"path": path
|
||||
}
|
||||
self.file = 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 syncplay.players.playerFactory import PlayerFactory
|
||||
from datetime import datetime
|
||||
from syncplay import utils
|
||||
import os
|
||||
import sys
|
||||
from syncplay.messages import getMessage, getLanguages, setLanguage, getInitialLanguage
|
||||
@ -77,15 +78,10 @@ class ConfigDialog(QtGui.QDialog):
|
||||
def openHelp(self):
|
||||
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):
|
||||
if self._isURL(path):
|
||||
if utils.isURL(path):
|
||||
return path
|
||||
else:
|
||||
return os.path.normcase(os.path.normpath(path))
|
||||
@ -104,7 +100,7 @@ class ConfigDialog(QtGui.QDialog):
|
||||
foundpath = ""
|
||||
|
||||
if playerpath != None and playerpath != "":
|
||||
if self._isURL(playerpath):
|
||||
if utils.isURL(playerpath):
|
||||
foundpath = playerpath
|
||||
self.executablepathCombobox.addItem(foundpath)
|
||||
|
||||
@ -119,7 +115,7 @@ class ConfigDialog(QtGui.QDialog):
|
||||
self.executablepathCombobox.addItem(foundpath)
|
||||
|
||||
for path in playerpathlist:
|
||||
if self._isURL(path):
|
||||
if utils.isURL(path):
|
||||
if foundpath == "":
|
||||
foundpath = path
|
||||
if path != playerpath:
|
||||
@ -821,7 +817,6 @@ class ConfigDialog(QtGui.QDialog):
|
||||
|
||||
def __init__(self, config, playerpaths, error, defaultConfig):
|
||||
|
||||
from syncplay import utils
|
||||
self.config = config
|
||||
self.defaultConfig = defaultConfig
|
||||
self.playerpaths = playerpaths
|
||||
|
@ -7,7 +7,7 @@ import time
|
||||
from datetime import datetime
|
||||
import re
|
||||
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
|
||||
lastCheckedForUpdates = None
|
||||
|
||||
@ -230,9 +230,28 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.updateReadyIcon()
|
||||
|
||||
def roomClicked(self, item):
|
||||
username = item.sibling(item.row(), 0).data()
|
||||
filename = item.sibling(item.row(), 3).data()
|
||||
while item.parent().row() != -1:
|
||||
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
|
||||
def userListChange(self):
|
||||
|
@ -218,6 +218,16 @@ def meetsMinVersion(version, minVersion):
|
||||
return tuple(map(int, ver.split(".")))
|
||||
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):
|
||||
CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$")
|
||||
PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}")
|
||||
|
Loading…
Reference in New Issue
Block a user