From e3255d1b92f932009565b118762c5ca039532098 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sat, 29 Nov 2014 17:17:39 +0000 Subject: [PATCH] Move controlled room messages to messages.py --- syncplay/client.py | 9 ++++----- syncplay/messages.py | 16 +++++++++++++++- syncplay/ui/gui.py | 14 +++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 2d42674..1c34c04 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -445,8 +445,7 @@ class SyncplayClient(object): @requireMinServerVersion("1.3.0") def createControlledRoom(self, roomName): - controlPassword = utils.RandomStringGenerator.generate_room_ - password() + controlPassword = utils.RandomStringGenerator.generate_room_password() self.ui.showMessage(u"Attempting to create controlled room '{}' with password '{}'...".format(roomName, controlPassword)) self.lastControlPasswordAttempt = controlPassword self._protocol.requestControlledRoom(roomName, controlPassword) @@ -467,18 +466,18 @@ class SyncplayClient(object): @requireMinServerVersion("1.3.0") def identifyAsController(self, controlPassword): controlPassword = self.stripControlPassword(controlPassword) - self.ui.showMessage(u"Identifying as room controller with password '{}'...".format(controlPassword)) + self.ui.showMessage(getMessage("identifying-as-controller-notification").format(controlPassword)) self.lastControlPasswordAttempt = controlPassword self._protocol.requestControlledRoom(self.getRoom(), controlPassword) def controllerIdentificationError(self, username, room): - self.ui.showErrorMessage(u"<{}> failed to identify as a room controller.".format(username)) + self.ui.showErrorMessage(getMessage("failed-to-identify-as-controller-notification").format(username)) def controllerIdentificationSuccess(self, username, roomname): self.userlist.setUserAsController(username) if self.userlist.isRoomSame(roomname): hideFromOSD = not constants.SHOW_SAME_ROOM_OSD - self.ui.showMessage(u"<{}> authenticated as a room controller".format(username), hideFromOSD) + self.ui.showMessage(getMessage("authenticated-as-controller-notification").format(username), hideFromOSD) if username == self.userlist.currentUser.username: self.storeControlPassword(roomname, self.lastControlPasswordAttempt) self.ui.userListChange() diff --git a/syncplay/messages.py b/syncplay/messages.py index b5ad9a6..7d6d481 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -31,8 +31,12 @@ en = { "playing-notification" : "<{}> is playing '{}' ({})", # User, file, duration "playing-notification/room-addendum" : " in room: '{}'", # Room + "identifying-as-controller-notification" : u"Identifying as room controller with password '{}'...", + "failed-to-identify-as-controller-notification" : u"<{}> failed to identify as a room controller.", + "authenticated-as-controller-notification" : u"<{}> authenticated as a room controller", + "file-different-notification" : "File you are playing appears to be different from <{}>'s", # User - "file-differences-notification" : "Your file differs in the following way(s): ", + "file-differences-notification" : "Your file differs in the following way(s): ", # controlPassword "room-files-not-same" : "Not all files played in the room are the same", "alone-in-the-room": "You're alone in the room", @@ -188,12 +192,22 @@ en = { "exit-menu-label" : "E&xit", "advanced-menu-label" : "&Advanced", "setoffset-menu-label" : "Set &offset", + "createcontrolledroom-menu-label" : "&Create controlled room", + "identifyascontroller-menu-label" : "&Identify as room controller", + "help-menu-label" : "&Help", "userguide-menu-label" : "Open user &guide", "setoffset-msgbox-label" : "Set offset", "offsetinfo-msgbox-label" : "Offset (see http://syncplay.pl/guide/ for usage instructions):", + + "createcontrolledroom-msgbox-label" : "Create controlled room", + "controlledroominfo-msgbox-label" : "Enter name of controlled room\r\n(see http://syncplay.pl/guide/ for usage instructions):", + + "identifyascontroller-msgbox-label" : "Identify as Room Controller", + "identifyinfo-msgbox-label" : "Enter controller password for this room\r\n(see http://syncplay.pl/guide/ for usage instructions):", + "megabyte-suffix" : " MB", # Tooltips diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 2a9e39e..c1765fc 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -364,16 +364,16 @@ class MainWindow(QtGui.QMainWindow): self._syncplayClient._player.openFile(fileName) def createControlledRoom(self): - controlroom, ok = QtGui.QInputDialog.getText(self, "Create controlled room", - "Enter name of controlled room\r\n(see http://syncplay.pl/guide/ for usage instructions):", QtGui.QLineEdit.Normal, + controlroom, ok = QtGui.QInputDialog.getText(self, getMessage("createcontrolledroom-msgbox-label"), + getMessage("controlledroominfo-msgbox-label"), QtGui.QLineEdit.Normal, utils.stripRoomName(self._syncplayClient.getRoom())) if ok and controlroom != '': self._syncplayClient.createControlledRoom(controlroom) def identifyAsController(self): - tooltip = "Enter controller password for this room\r\n(see http://syncplay.pl/guide/ for usage instructions):" - name = "Identify as Room Controller" - controlpassword, ok = QtGui.QInputDialog.getText(self, name, tooltip, QtGui.QLineEdit.Normal, "") + msgboxtitle = getMessage("identifyascontroller-msgbox-label") + msgboxtext = getMessage("identifyinfo-msgbox-label") + controlpassword, ok = QtGui.QInputDialog.getText(self, msgboxtitle, msgboxtext, QtGui.QLineEdit.Normal, "") if ok and controlpassword != '': self._syncplayClient.identifyAsController(controlpassword) @@ -568,10 +568,10 @@ class MainWindow(QtGui.QMainWindow): window.setoffsetAction.triggered.connect(self.setOffset) window.createcontrolledroomAction = window.advancedMenu.addAction( - QtGui.QIcon(self.resourcespath + 'page_white_key.png'), "&Create controlled room suffix") + QtGui.QIcon(self.resourcespath + 'page_white_key.png'), getMessage("createcontrolledroom-menu-label")) window.createcontrolledroomAction.triggered.connect(self.createControlledRoom) window.identifyascontroller = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'key_go.png'), - "&Identify as room controller") + getMessage("identifyascontroller-menu-label")) window.identifyascontroller.triggered.connect(self.identifyAsController) window.menuBar.addMenu(window.advancedMenu)