45 shareEditor = pyqtSignal(bool) |
45 shareEditor = pyqtSignal(bool) |
46 startEdit = pyqtSignal() |
46 startEdit = pyqtSignal() |
47 sendEdit = pyqtSignal() |
47 sendEdit = pyqtSignal() |
48 cancelEdit = pyqtSignal() |
48 cancelEdit = pyqtSignal() |
49 |
49 |
50 def __init__(self, port=-1, parent=None): |
50 def __init__(self, ui, port=-1, parent=None): |
51 """ |
51 """ |
52 Constructor |
52 Constructor |
53 |
53 |
|
54 @param ui reference to the user interface object (UserInterface) |
54 @param port port to be used for the cooperation server (integer) |
55 @param port port to be used for the cooperation server (integer) |
55 @param parent reference to the parent widget (QWidget) |
56 @param parent reference to the parent widget (QWidget) |
56 """ |
57 """ |
57 super().__init__(parent) |
58 super().__init__(parent) |
58 self.setupUi(self) |
59 self.setupUi(self) |
68 self.clearMessageButton.setIcon( |
69 self.clearMessageButton.setIcon( |
69 UI.PixmapCache.getIcon("clearLeft.png")) |
70 UI.PixmapCache.getIcon("clearLeft.png")) |
70 self.clearHostButton.setIcon( |
71 self.clearHostButton.setIcon( |
71 UI.PixmapCache.getIcon("clearLeft.png")) |
72 UI.PixmapCache.getIcon("clearLeft.png")) |
72 |
73 |
|
74 self.__ui = ui |
73 self.__client = CooperationClient(self) |
75 self.__client = CooperationClient(self) |
74 self.__myNickName = self.__client.nickName() |
76 self.__myNickName = self.__client.nickName() |
75 |
77 |
76 self.__initChatMenu() |
78 self.__initChatMenu() |
77 self.__initUsersMenu() |
79 self.__initUsersMenu() |
180 "chatUser{0}.png".format(1 + self.usersList.count() % 6)), |
182 "chatUser{0}.png".format(1 + self.usersList.count() % 6)), |
181 nick, self.usersList) |
183 nick, self.usersList) |
182 |
184 |
183 if not self.__connected: |
185 if not self.__connected: |
184 self.__setConnected(True) |
186 self.__setConnected(True) |
|
187 |
|
188 if not self.isVisible(): |
|
189 self.__ui.showNotification(UI.PixmapCache.getPixmap("cooperation48.png"), |
|
190 self.trUtf8("New User"), self.trUtf8("{0} has joined.").format(nick)) |
185 |
191 |
186 def __participantLeft(self, nick): |
192 def __participantLeft(self, nick): |
187 """ |
193 """ |
188 Private slot handling a participant leaving the session. |
194 Private slot handling a participant leaving the session. |
189 |
195 |
204 self.chatEdit.append(self.trUtf8("* {0} has left.\n").format(nick)) |
210 self.chatEdit.append(self.trUtf8("* {0} has left.\n").format(nick)) |
205 self.chatEdit.setTextColor(color) |
211 self.chatEdit.setTextColor(color) |
206 |
212 |
207 if not self.__client.hasConnections(): |
213 if not self.__client.hasConnections(): |
208 self.__setConnected(False) |
214 self.__setConnected(False) |
|
215 |
|
216 if not self.isVisible(): |
|
217 self.__ui.showNotification(UI.PixmapCache.getPixmap("cooperation48.png"), |
|
218 self.trUtf8("User Left"), self.trUtf8("{0} has left.").format(nick)) |
209 |
219 |
210 def appendMessage(self, from_, message): |
220 def appendMessage(self, from_, message): |
211 """ |
221 """ |
212 Public slot to append a message to the display. |
222 Public slot to append a message to the display. |
213 |
223 |
221 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + \ |
231 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + \ |
222 " <" + from_ + ">:") |
232 " <" + from_ + ">:") |
223 self.chatEdit.append(message + "\n") |
233 self.chatEdit.append(message + "\n") |
224 bar = self.chatEdit.verticalScrollBar() |
234 bar = self.chatEdit.verticalScrollBar() |
225 bar.setValue(bar.maximum()) |
235 bar.setValue(bar.maximum()) |
|
236 |
|
237 if not self.isVisible(): |
|
238 self.__ui.showNotification(UI.PixmapCache.getPixmap("cooperation48.png"), |
|
239 self.trUtf8("Message from <{0}>").format(from_), message) |
226 |
240 |
227 @pyqtSlot(str) |
241 @pyqtSlot(str) |
228 def on_hostEdit_editTextChanged(self, host): |
242 def on_hostEdit_editTextChanged(self, host): |
229 """ |
243 """ |
230 Private slot handling the entry of a host to connect to. |
244 Private slot handling the entry of a host to connect to. |
668 self.chatEdit.append( |
682 self.chatEdit.append( |
669 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":") |
683 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":") |
670 self.chatEdit.append(self.trUtf8("* {0} has been banned and kicked.\n").format( |
684 self.chatEdit.append(self.trUtf8("* {0} has been banned and kicked.\n").format( |
671 itm.text().split(":")[0])) |
685 itm.text().split(":")[0])) |
672 self.chatEdit.setTextColor(color) |
686 self.chatEdit.setTextColor(color) |
|
687 |
|
688 def shutdown(self): |
|
689 """ |
|
690 Public method to shut down the cooperation system. |
|
691 """ |
|
692 self.__client.disconnectConnections() |
|
693 self.__setConnected(False) |