From 586c12ec688d3ef94b0884fcabfb06818eaa37d2 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 3 Jul 2016 17:48:42 +0100 Subject: [PATCH] Add chat to GUI --- buildPy2exe.py | 1 + resources/email_go.png | Bin 0 -> 754 bytes syncplay/__init__.py | 2 +- syncplay/client.py | 1 - syncplay/constants.py | 1 + syncplay/messages_de.py | 3 +++ syncplay/messages_en.py | 3 +++ syncplay/messages_ru.py | 3 +++ syncplay/protocols.py | 3 ++- syncplay/ui/gui.py | 25 +++++++++++++++++++++++++ 10 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 resources/email_go.png diff --git a/buildPy2exe.py b/buildPy2exe.py index 403bd4a..0d72229 100644 --- a/buildPy2exe.py +++ b/buildPy2exe.py @@ -657,6 +657,7 @@ guiIcons = ['resources/accept.png', 'resources/arrow_undo.png', 'resources/clock 'resources/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', 'resources/bullet_right_grey.png', 'resources/film_folder_edit.png', 'resources/shield_edit.png', + 'resources/email_go.png', 'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png', 'resources/spinner.mng' ] resources = ["resources/icon.ico", "resources/syncplay.png"] diff --git a/resources/email_go.png b/resources/email_go.png new file mode 100644 index 0000000000000000000000000000000000000000..4a6c5d396ad024567a769d1f2285c525bef8c88b GIT binary patch literal 754 zcmV~0d>kmp9&fG9>#5EaEn(MD9Xvl47<{Rb2T3D!0$wpy4@P!Tnn zB0fxQ2!aPL_fZ@!=Wv9zmj8jnf5JO`<=MmZs@#@p z5O*{}9L5B6J+L7ORza<+9h)-B~<&cwIhUkd?cp4is-ziNrfY^u-7xdbFt=#%1534Oi8ajBBo}VZvCxd1 zTu*VtX+~P45)Om?dG5aS`PPW(%?lDPBwaz$6C^$8$_Q#plJTjpbgj;_rYi*?oK~m+ zDD`C->dkZKh0j6|Q^-0bJxIFHnHJOo$@r8{VNIUWU>31rp3@BVvYIZG2D0>Yuj2Y- zg?b?AObc>pK`oG+zkPsr3x_BTWXX8H*w}0@e;@>?SdsP&!-HMidhRn*4VkHi+<58} zTg6ae0~aSoNqRq(^;(g}0#Yiz)&q*YIg-f)mmeJA&3%nD3aJ$X-6L%1+fEQRIeTL* zS5K6|3cOaNtTtBowSZzzj!ZfM7L<|f+jtyp4ccf7mf6J$n}&ALkZlfLEYRoNvtG0Q zzJh|U~_Rdjkv}0kGt_?V}5$?sXN`N zTt|nOa)sx)IIf_-7XW**;!X9`USPjuUUsJrREk)6q*M9ZHEb zl2A!T3LBjrrTx74{FsUNcVA1zw%IWoiGNMw=s9P8>+qh!B*saR2}S literal 0 HcmV?d00001 diff --git a/syncplay/__init__.py b/syncplay/__init__.py index 31a5492..8e7ceec 100644 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,4 +1,4 @@ -version = '1.4.0' +version = '1.5.0' milestone = 'Yoitsu' release_number = '28' projectURL = 'http://syncplay.pl/' diff --git a/syncplay/client.py b/syncplay/client.py index a79e465..d363db2 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -1703,7 +1703,6 @@ class FileSwitchManager(object): if highPriority and self.folderSearchEnabled: directoryList = self.mediaDirectories # Spin up hard drives to prevent premature timeout - randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+u".txt" for directory in directoryList: startTime = time.time() if os.path.isfile(os.path.join(directory, randomFilename)): diff --git a/syncplay/constants.py b/syncplay/constants.py index d5cbb7d..dfbab0c 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -79,6 +79,7 @@ MPV_UNRESPONSIVE_THRESHOLD = 60.0 CONTROLLED_ROOMS_MIN_VERSION = "1.3.0" USER_READY_MIN_VERSION = "1.3.0" SHARED_PLAYLIST_MIN_VERSION = "1.4.0" +CHAT_MIN_VERSION = "1.5.0" MPC_PATHS = [ r"c:\program files (x86)\mpc-hc\mpc-hc.exe", r"c:\program files\mpc-hc\mpc-hc.exe", diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index f8f560e..6529800 100644 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -248,6 +248,8 @@ de = { "autoplay-guipushbuttonlabel" : u"Automatisch abspielen wenn alle bereit sind", "autoplay-minimum-label" : u"Minimum an Nutzern:", + "sendmessage-label" : u"Send", # TODO: Translate + "ready-guipushbuttonlabel" : u"Ich bin bereit den Film anzuschauen!", "roomuser-heading-label" : u"Raum / Benutzer", @@ -350,6 +352,7 @@ de = { "ready-tooltip" : u"Zeigt an, ob du bereit zum anschauen bist", "autoplay-tooltip" : u"Automatisch abspielen, wenn alle Nutzer bereit sind oder die minimale Nutzerzahl erreicht ist.", "switch-to-file-tooltip" : u"Doppelklicken um zu {} zu wechseln", # Filename + "sendmessage-tooltip" : u"Send message to room", # TODO: Translate # In-userlist notes (GUI) "differentsize-note" : u"Verschiedene Größe!", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index e31ffb7..7bb63c6 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -250,6 +250,8 @@ en = { "autoplay-guipushbuttonlabel" : u"Play when all ready", "autoplay-minimum-label" : u"Min users:", + "sendmessage-label" : u"Send", + "ready-guipushbuttonlabel" : u"I'm ready to watch!", "roomuser-heading-label" : "Room / User", @@ -350,6 +352,7 @@ en = { "ready-tooltip" : "Indicates whether you are ready to watch.", "autoplay-tooltip" : "Auto-play when all users who have readiness indicator are ready and minimum user threshold met.", "switch-to-file-tooltip" : u"Double click to switch to {}", # Filename + "sendmessage-tooltip" : u"Send message to room", # In-userlist notes (GUI) "differentsize-note" : "Different size!", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 94804e4..81ecf7c 100644 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -250,6 +250,8 @@ ru = { "autoplay-guipushbuttonlabel" : u"Воспроизвести автоматически, когда все будут готовы", "autoplay-minimum-label" : u"Минимум пользователей:", + "sendmessage-label" : u"Send", # TODO: Translate + "ready-guipushbuttonlabel" : u"Я готов к просмотру!", "roomuser-heading-label" : u"Комната / Пользователь", @@ -350,6 +352,7 @@ ru = { "ready-tooltip" : u"Показывает, готовы ли Вы к просмотру или нет.", "autoplay-tooltip" : u"Автоматическое воспроизведение, когда все пользователи с индикаторами готовности будут готовы и присутствует достаточное число пользователей.", "switch-to-file-tooltip" : u"Double click to switch to {}", # Filename # TODO: Translate to Russian + "sendmessage-tooltip" : u"Send message to room", # TODO: Translate # In-userlist notes (GUI) "differentsize-note" : u"Размер файла не совпадает!", diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 3c6c17e..096f19d 100644 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -246,7 +246,8 @@ class SyncClientProtocol(JSONCommandProtocol): } }) def handleChat(self,message): - messageString = '<'+message['username']+'>'+message['message'] + userMessage = message['message'].replace(u"<",u"<<").replace(u">",u">>") + messageString = u"<{}> {}".format(message['username'], userMessage) self._client.ui.showMessage(messageString) #TODO diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index dc62c85..40eb494 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -328,8 +328,12 @@ class MainWindow(QtGui.QMainWindow): def showMessage(self, message, noTimestamp=False): message = unicode(message) message = message.replace(u"&", u"&").replace(u'"', u""").replace(u"<", u"<").replace(">", u">") + message = message.replace(u"<<", u"") + message = message.replace(u">>", u"") message = message.replace(u"<", u"<".format(constants.STYLE_USERNAME)) message = message.replace(u">", u">") + message = message.replace(u";", u"<") + message = message.replace(u"", u">") message = message.replace(u"\n", u"
") if noTimestamp: self.newMessage(u"{}
".format(message)) @@ -962,6 +966,11 @@ class MainWindow(QtGui.QMainWindow): self._syncplayClient.playlist.changePlaylist(newPlaylist) self._syncplayClient.fileSwitch.updateInfo() + def sendChatMessage(self): + if self.chatInput.text() <> "": + self._syncplayClient.sendChat(self.chatInput.text()) + self.chatInput.setText("") + def addTopLayout(self, window): window.topSplit = self.topSplitter(Qt.Horizontal, self) @@ -977,12 +986,28 @@ class MainWindow(QtGui.QMainWindow): window.outputbox.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) window.outputlabel = QtGui.QLabel(getMessage("notifications-heading-label")) + window.chatInput = QtGui.QLineEdit() + window.chatInput.returnPressed.connect(self.sendChatMessage) + window.chatButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'email_go.png'), + getMessage("sendmessage-label")) + window.chatButton.pressed.connect(self.sendChatMessage) + window.chatLayout = QtGui.QHBoxLayout() + window.chatFrame = QtGui.QFrame() + window.chatFrame.setLayout(self.chatLayout) + window.chatFrame.setContentsMargins(0,0,0,0) + window.chatFrame.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + window.chatLayout.setContentsMargins(0,0,0,0) + self.chatButton.setToolTip(getMessage("sendmessage-tooltip")) + window.chatLayout.addWidget(window.chatInput) + window.chatLayout.addWidget(window.chatButton) + window.chatFrame.setMaximumHeight(window.chatFrame.sizeHint().height()) window.outputFrame = QtGui.QFrame() window.outputFrame.setLineWidth(0) window.outputFrame.setMidLineWidth(0) window.outputLayout.setContentsMargins(0, 0, 0, 0) window.outputLayout.addWidget(window.outputlabel) window.outputLayout.addWidget(window.outputbox) + window.outputLayout.addWidget(window.chatFrame) window.outputFrame.setLayout(window.outputLayout) window.listLayout = QtGui.QVBoxLayout()