Execute /commands in chat as if console input
This commit is contained in:
parent
b57e5e28c0
commit
55e5d8f270
@ -625,8 +625,8 @@ class SyncplayClient(object):
|
|||||||
if self._protocol and self._protocol.logged:
|
if self._protocol and self._protocol.logged:
|
||||||
self._protocol.sendList()
|
self._protocol.sendList()
|
||||||
|
|
||||||
def showUserList(self):
|
def showUserList(self, altUI=None):
|
||||||
self.userlist.showUserList()
|
self.userlist.showUserList(altUI)
|
||||||
|
|
||||||
def getPassword(self):
|
def getPassword(self):
|
||||||
return self._serverPassword
|
return self._serverPassword
|
||||||
@ -1298,7 +1298,7 @@ class SyncplayUserlist(object):
|
|||||||
def hasRoomStateChanged(self):
|
def hasRoomStateChanged(self):
|
||||||
return self._roomUsersChanged
|
return self._roomUsersChanged
|
||||||
|
|
||||||
def showUserList(self):
|
def showUserList(self, altUI=None):
|
||||||
rooms = {}
|
rooms = {}
|
||||||
for user in self._users.itervalues():
|
for user in self._users.itervalues():
|
||||||
if user.room not in rooms:
|
if user.room not in rooms:
|
||||||
@ -1308,6 +1308,9 @@ class SyncplayUserlist(object):
|
|||||||
rooms[self.currentUser.room] = []
|
rooms[self.currentUser.room] = []
|
||||||
rooms[self.currentUser.room].append(self.currentUser)
|
rooms[self.currentUser.room].append(self.currentUser)
|
||||||
rooms = self.sortList(rooms)
|
rooms = self.sortList(rooms)
|
||||||
|
if altUI:
|
||||||
|
altUI.showUserList(self.currentUser, rooms)
|
||||||
|
else:
|
||||||
self.ui.showUserList(self.currentUser, rooms)
|
self.ui.showUserList(self.currentUser, rooms)
|
||||||
self._client.autoplayCheck()
|
self._client.autoplayCheck()
|
||||||
|
|
||||||
@ -1407,6 +1410,9 @@ class UiManager(object):
|
|||||||
def updateRoomName(self, room=""):
|
def updateRoomName(self, room=""):
|
||||||
self.__ui.updateRoomName(room)
|
self.__ui.updateRoomName(room)
|
||||||
|
|
||||||
|
def executeCommand(self, command):
|
||||||
|
self.__ui.executeCommand(command)
|
||||||
|
|
||||||
def drop(self):
|
def drop(self):
|
||||||
self.__ui.drop()
|
self.__ui.drop()
|
||||||
|
|
||||||
|
|||||||
@ -338,6 +338,15 @@ class MplayerPlayer(BasePlayer):
|
|||||||
self.__playerController.drop()
|
self.__playerController.drop()
|
||||||
|
|
||||||
def sendChat(self, message):
|
def sendChat(self, message):
|
||||||
|
if message:
|
||||||
|
if message[:1] == "/" and message <> "/":
|
||||||
|
command = message[1:]
|
||||||
|
if command and command[:1] == "/":
|
||||||
|
message = message[1:]
|
||||||
|
else:
|
||||||
|
self.__playerController.reactor.callFromThread(self.__playerController._client.ui.executeCommand,
|
||||||
|
command)
|
||||||
|
return
|
||||||
self.__playerController.reactor.callFromThread(self.__playerController._client.sendChat, message)
|
self.__playerController.reactor.callFromThread(self.__playerController._client.sendChat, message)
|
||||||
|
|
||||||
def isReadyForSend(self):
|
def isReadyForSend(self):
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class ConsoleUI(threading.Thread):
|
|||||||
self.PromptResult = data
|
self.PromptResult = data
|
||||||
self.promptMode.set()
|
self.promptMode.set()
|
||||||
elif self._syncplayClient:
|
elif self._syncplayClient:
|
||||||
self._executeCommand(data)
|
self.executeCommand(data)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ class ConsoleUI(threading.Thread):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _executeCommand(self, data):
|
def executeCommand(self, data):
|
||||||
command = re.match(constants.UI_COMMAND_REGEX, data)
|
command = re.match(constants.UI_COMMAND_REGEX, data)
|
||||||
if not command:
|
if not command:
|
||||||
return
|
return
|
||||||
@ -145,7 +145,7 @@ class ConsoleUI(threading.Thread):
|
|||||||
self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
|
self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
|
||||||
self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
|
self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
|
||||||
elif command.group('command') in constants.COMMANDS_LIST:
|
elif command.group('command') in constants.COMMANDS_LIST:
|
||||||
self._syncplayClient.getUserList()
|
self.getUserlist()
|
||||||
elif command.group('command') in constants.COMMANDS_CHAT:
|
elif command.group('command') in constants.COMMANDS_CHAT:
|
||||||
message= command.group('parameter')
|
message= command.group('parameter')
|
||||||
self._syncplayClient.sendChat(message)
|
self._syncplayClient.sendChat(message)
|
||||||
@ -158,8 +158,8 @@ class ConsoleUI(threading.Thread):
|
|||||||
room = self._syncplayClient.userlist.currentUser.file["name"]
|
room = self._syncplayClient.userlist.currentUser.file["name"]
|
||||||
else:
|
else:
|
||||||
room = self._syncplayClient.defaultRoom
|
room = self._syncplayClient.defaultRoom
|
||||||
|
|
||||||
self._syncplayClient.setRoom(room, resetAutoplay=True)
|
self._syncplayClient.setRoom(room, resetAutoplay=True)
|
||||||
|
self._syncplayClient.ui.updateRoomName(room)
|
||||||
self._syncplayClient.sendRoom()
|
self._syncplayClient.sendRoom()
|
||||||
elif command.group('command') in constants.COMMANDS_CREATE:
|
elif command.group('command') in constants.COMMANDS_CREATE:
|
||||||
roombasename = command.group('parameter')
|
roombasename = command.group('parameter')
|
||||||
@ -191,3 +191,5 @@ class ConsoleUI(threading.Thread):
|
|||||||
self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True)
|
self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True)
|
||||||
self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)
|
self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)
|
||||||
|
|
||||||
|
def getUserlist(self):
|
||||||
|
self._syncplayClient.getUserList()
|
||||||
@ -11,8 +11,25 @@ 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
|
||||||
|
from syncplay.ui.consoleUI import ConsoleUI
|
||||||
lastCheckedForUpdates = None
|
lastCheckedForUpdates = None
|
||||||
|
|
||||||
|
class ConsoleInGUI(ConsoleUI):
|
||||||
|
def showMessage(self, message, noTimestamp=False):
|
||||||
|
self._syncplayClient.ui.showMessage(message, True)
|
||||||
|
|
||||||
|
def showDebugMessage(self, message):
|
||||||
|
self._syncplayClient.ui.showDebugMessage(message)
|
||||||
|
|
||||||
|
def showErrorMessage(self, message, criticalerror=False):
|
||||||
|
self._syncplayClient.ui.showErrorMessage(message, criticalerror)
|
||||||
|
|
||||||
|
def updateRoomName(self, room=""):
|
||||||
|
self._syncplayClient.ui.updateRoomName(room)
|
||||||
|
|
||||||
|
def getUserlist(self):
|
||||||
|
self._syncplayClient.showUserList(self)
|
||||||
|
|
||||||
class UserlistItemDelegate(QtGui.QStyledItemDelegate):
|
class UserlistItemDelegate(QtGui.QStyledItemDelegate):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QtGui.QStyledItemDelegate.__init__(self)
|
QtGui.QStyledItemDelegate.__init__(self)
|
||||||
@ -297,6 +314,8 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
|
|
||||||
def addClient(self, client):
|
def addClient(self, client):
|
||||||
self._syncplayClient = client
|
self._syncplayClient = client
|
||||||
|
if self.console:
|
||||||
|
self.console.addClient(client)
|
||||||
self.roomInput.setText(self._syncplayClient.getRoom())
|
self.roomInput.setText(self._syncplayClient.getRoom())
|
||||||
self.config = self._syncplayClient.getConfig()
|
self.config = self._syncplayClient.getConfig()
|
||||||
try:
|
try:
|
||||||
@ -330,8 +349,6 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
def setFeatures(self, featureList):
|
def setFeatures(self, featureList):
|
||||||
if not featureList["readiness"]:
|
if not featureList["readiness"]:
|
||||||
self.readyPushButton.setEnabled(False)
|
self.readyPushButton.setEnabled(False)
|
||||||
if not featureList["chat"]:
|
|
||||||
self.chatFrame.setEnabled(False)
|
|
||||||
if not featureList["sharedPlaylists"]:
|
if not featureList["sharedPlaylists"]:
|
||||||
self.playlistGroup.setEnabled(False)
|
self.playlistGroup.setEnabled(False)
|
||||||
|
|
||||||
@ -1046,10 +1063,22 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self._syncplayClient.playlist.changePlaylist(newPlaylist)
|
self._syncplayClient.playlist.changePlaylist(newPlaylist)
|
||||||
self._syncplayClient.fileSwitch.updateInfo()
|
self._syncplayClient.fileSwitch.updateInfo()
|
||||||
|
|
||||||
|
def executeCommand(self, command):
|
||||||
|
self.showMessage(u"/{}".format(command))
|
||||||
|
self.console.executeCommand(command)
|
||||||
|
|
||||||
def sendChatMessage(self):
|
def sendChatMessage(self):
|
||||||
if self.chatInput.text() <> "":
|
chatText = self.chatInput.text()
|
||||||
self._syncplayClient.sendChat(self.chatInput.text())
|
|
||||||
self.chatInput.setText("")
|
self.chatInput.setText("")
|
||||||
|
if chatText <> "":
|
||||||
|
if chatText[:1] == "/" and chatText <> "/":
|
||||||
|
command = chatText[1:]
|
||||||
|
if command and command[:1] == "/":
|
||||||
|
chatText = chatText[1:]
|
||||||
|
else:
|
||||||
|
self.executeCommand(command)
|
||||||
|
return
|
||||||
|
self._syncplayClient.sendChat(chatText)
|
||||||
|
|
||||||
def addTopLayout(self, window):
|
def addTopLayout(self, window):
|
||||||
window.topSplit = self.topSplitter(Qt.Horizontal, self)
|
window.topSplit = self.topSplitter(Qt.Horizontal, self)
|
||||||
@ -1608,6 +1637,8 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
|
self.console = ConsoleInGUI()
|
||||||
|
self.console.setDaemon(True)
|
||||||
self.newWatchlist = []
|
self.newWatchlist = []
|
||||||
self.publicServerList = []
|
self.publicServerList = []
|
||||||
self.lastCheckedForUpdates = None
|
self.lastCheckedForUpdates = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user