src/eric7/Cooperation/ChatWidget.py

branch
eric7
changeset 10420
5ac83a87954d
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10419:2fda68a9168d 10420:5ac83a87954d
47 47
48 def __init__(self, ui, port=-1, parent=None): 48 def __init__(self, ui, port=-1, parent=None):
49 """ 49 """
50 Constructor 50 Constructor
51 51
52 @param ui reference to the user interface object (UserInterface) 52 @param ui reference to the user interface object
53 @param port port to be used for the cooperation server (integer) 53 @type UserInterface
54 @param parent reference to the parent widget (QWidget) 54 @param port port to be used for the cooperation server
55 @type int
56 @param parent reference to the parent widget
57 @type QWidget
55 """ 58 """
56 super().__init__(parent) 59 super().__init__(parent)
57 self.setupUi(self) 60 self.setupUi(self)
58 61
59 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected")) 62 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected"))
116 119
117 def __setHostsHistory(self, host): 120 def __setHostsHistory(self, host):
118 """ 121 """
119 Private method to remember the given host as the most recent entry. 122 Private method to remember the given host as the most recent entry.
120 123
121 @param host host entry to remember (string) 124 @param host host entry to remember
125 @type str
122 """ 126 """
123 if host in self.__recent: 127 if host in self.__recent:
124 self.__recent.remove(host) 128 self.__recent.remove(host)
125 self.__recent.insert(0, host) 129 self.__recent.insert(0, host)
126 self.__saveHostsHistory() 130 self.__saveHostsHistory()
156 160
157 def __newParticipant(self, nick): 161 def __newParticipant(self, nick):
158 """ 162 """
159 Private slot handling a new participant joining. 163 Private slot handling a new participant joining.
160 164
161 @param nick nick name of the new participant (string) 165 @param nick nick name of the new participant
166 @type str
162 """ 167 """
163 if nick == "": 168 if nick == "":
164 return 169 return
165 170
166 color = self.chatEdit.textColor() 171 color = self.chatEdit.textColor()
192 197
193 def __participantLeft(self, nick): 198 def __participantLeft(self, nick):
194 """ 199 """
195 Private slot handling a participant leaving the session. 200 Private slot handling a participant leaving the session.
196 201
197 @param nick nick name of the participant (string) 202 @param nick nick name of the participant
203 @type str
198 """ 204 """
199 if nick == "": 205 if nick == "":
200 return 206 return
201 207
202 items = self.usersList.findItems(nick, Qt.MatchFlag.MatchExactly) 208 items = self.usersList.findItems(nick, Qt.MatchFlag.MatchExactly)
225 231
226 def appendMessage(self, from_, message): 232 def appendMessage(self, from_, message):
227 """ 233 """
228 Public slot to append a message to the display. 234 Public slot to append a message to the display.
229 235
230 @param from_ originator of the message (string) 236 @param from_ originator of the message
231 @param message message to be appended (string) 237 @type str
238 @param message message to be appended
239 @type str
232 """ 240 """
233 if from_ == "" or message == "": 241 if from_ == "" or message == "":
234 return 242 return
235 243
236 self.chatEdit.append( 244 self.chatEdit.append(
253 @pyqtSlot(str) 261 @pyqtSlot(str)
254 def on_hostEdit_editTextChanged(self, host): 262 def on_hostEdit_editTextChanged(self, host):
255 """ 263 """
256 Private slot handling the entry of a host to connect to. 264 Private slot handling the entry of a host to connect to.
257 265
258 @param host host to connect to (string) 266 @param host host to connect to
267 @type str
259 """ 268 """
260 if not self.__connected: 269 if not self.__connected:
261 self.connectButton.setEnabled(host != "") 270 self.connectButton.setEnabled(host != "")
262 271
263 def __getConnectionParameters(self): 272 def __getConnectionParameters(self):
264 """ 273 """
265 Private method to determine the connection parameters. 274 Private method to determine the connection parameters.
266 275
267 @return tuple with hostname and port (string, integer) 276 @return tuple with hostname and port
277 @rtype tuple of (str, int)
268 """ 278 """
269 hostEntry = self.hostEdit.currentText() 279 hostEntry = self.hostEdit.currentText()
270 if "@" in hostEntry: 280 if "@" in hostEntry:
271 host, port = hostEntry.split("@") 281 host, port = hostEntry.split("@")
272 try: 282 try:
330 340
331 def __setConnected(self, connected): 341 def __setConnected(self, connected):
332 """ 342 """
333 Private slot to set the connected state. 343 Private slot to set the connected state.
334 344
335 @param connected new connected state (boolean) 345 @param connected new connected state
346 @type bool
336 """ 347 """
337 if connected: 348 if connected:
338 self.connectButton.setText(self.tr("Disconnect")) 349 self.connectButton.setText(self.tr("Disconnect"))
339 self.connectButton.setEnabled(True) 350 self.connectButton.setEnabled(True)
340 self.connectionLed.setColor(QColor(Qt.GlobalColor.green)) 351 self.connectionLed.setColor(QColor(Qt.GlobalColor.green))
358 369
359 def __showErrorMessage(self, message): 370 def __showErrorMessage(self, message):
360 """ 371 """
361 Private slot to show an error message. 372 Private slot to show an error message.
362 373
363 @param message error message to show (string) 374 @param message error message to show
375 @type str
364 """ 376 """
365 color = self.chatEdit.textColor() 377 color = self.chatEdit.textColor()
366 self.chatEdit.setTextColor(Qt.GlobalColor.red) 378 self.chatEdit.setTextColor(Qt.GlobalColor.red)
367 self.chatEdit.append( 379 self.chatEdit.append(
368 QDateTime.currentDateTime().toString(Qt.DateFormat.SystemLocaleLongDate) 380 QDateTime.currentDateTime().toString(Qt.DateFormat.SystemLocaleLongDate)
388 400
389 def getClient(self): 401 def getClient(self):
390 """ 402 """
391 Public method to get a reference to the cooperation client. 403 Public method to get a reference to the cooperation client.
392 404
393 @return reference to the cooperation client (CooperationClient) 405 @return reference to the cooperation client
406 @rtype CooperationClient
394 """ 407 """
395 return self.__client 408 return self.__client
396 409
397 def __editorCommandMessage(self, hashStr, fileName, message): 410 def __editorCommandMessage(self, hashStr, fileName, message):
398 """ 411 """
399 Private slot to handle editor command messages from the client. 412 Private slot to handle editor command messages from the client.
400 413
401 @param hashStr hash of the project (string) 414 @param hashStr hash of the project
402 @param fileName project relative file name of the editor (string) 415 @type str
403 @param message command message (string) 416 @param fileName project relative file name of the editor
417 @type str
418 @param message command message
419 @type str
404 """ 420 """
405 from eric7.QScintilla.Editor import Editor 421 from eric7.QScintilla.Editor import Editor
406 422
407 self.editorCommand.emit(hashStr, fileName, message) 423 self.editorCommand.emit(hashStr, fileName, message)
408 424
417 @pyqtSlot(bool) 433 @pyqtSlot(bool)
418 def on_shareButton_clicked(self, checked): 434 def on_shareButton_clicked(self, checked):
419 """ 435 """
420 Private slot to share the current editor. 436 Private slot to share the current editor.
421 437
422 @param checked flag indicating the button state (boolean) 438 @param checked flag indicating the button state
439 @type bool
423 """ 440 """
424 if checked: 441 if checked:
425 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditConnected")) 442 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditConnected"))
426 else: 443 else:
427 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected")) 444 self.shareButton.setIcon(EricPixmapCache.getIcon("sharedEditDisconnected"))
432 @pyqtSlot(bool) 449 @pyqtSlot(bool)
433 def on_startEditButton_clicked(self, checked): 450 def on_startEditButton_clicked(self, checked):
434 """ 451 """
435 Private slot to start a shared edit session. 452 Private slot to start a shared edit session.
436 453
437 @param checked flag indicating the button state (boolean) 454 @param checked flag indicating the button state
455 @type bool
438 """ 456 """
439 if checked: 457 if checked:
440 self.sendEditButton.setEnabled(True) 458 self.sendEditButton.setEnabled(True)
441 self.cancelEditButton.setEnabled(True) 459 self.cancelEditButton.setEnabled(True)
442 self.shareButton.setEnabled(False) 460 self.shareButton.setEnabled(False)
472 490
473 def checkEditorActions(self, editor): 491 def checkEditorActions(self, editor):
474 """ 492 """
475 Public slot to set action according to an editor's state. 493 Public slot to set action according to an editor's state.
476 494
477 @param editor reference to the editor (Editor) 495 @param editor reference to the editor
496 @type Editor
478 """ 497 """
479 shareable, sharing, editing, remoteEditing = editor.getSharingStatus() 498 shareable, sharing, editing, remoteEditing = editor.getSharingStatus()
480 499
481 self.shareButton.setChecked(sharing) 500 self.shareButton.setChecked(sharing)
482 if sharing: 501 if sharing:
519 @pyqtSlot(bool) 538 @pyqtSlot(bool)
520 def on_chatEdit_copyAvailable(self, yes): 539 def on_chatEdit_copyAvailable(self, yes):
521 """ 540 """
522 Private slot to react to text selection/deselection of the chat edit. 541 Private slot to react to text selection/deselection of the chat edit.
523 542
524 @param yes flag signaling the availability of selected text (boolean) 543 @param yes flag signaling the availability of selected text
544 @type bool
525 """ 545 """
526 self.__copyChatAct.setEnabled(yes) 546 self.__copyChatAct.setEnabled(yes)
527 547
528 @pyqtSlot(QPoint) 548 @pyqtSlot(QPoint)
529 def on_chatEdit_customContextMenuRequested(self, pos): 549 def on_chatEdit_customContextMenuRequested(self, pos):
530 """ 550 """
531 Private slot to show the context menu for the chat. 551 Private slot to show the context menu for the chat.
532 552
533 @param pos the position of the mouse pointer (QPoint) 553 @param pos the position of the mouse pointer
554 @type QPoint
534 """ 555 """
535 enable = self.chatEdit.toPlainText() != "" 556 enable = self.chatEdit.toPlainText() != ""
536 self.__saveChatAct.setEnabled(enable) 557 self.__saveChatAct.setEnabled(enable)
537 self.__copyAllChatAct.setEnabled(enable) 558 self.__copyAllChatAct.setEnabled(enable)
538 self.__cutAllChatAct.setEnabled(enable) 559 self.__cutAllChatAct.setEnabled(enable)
638 @pyqtSlot(QPoint) 659 @pyqtSlot(QPoint)
639 def on_usersList_customContextMenuRequested(self, pos): 660 def on_usersList_customContextMenuRequested(self, pos):
640 """ 661 """
641 Private slot to show the context menu for the users list. 662 Private slot to show the context menu for the users list.
642 663
643 @param pos the position of the mouse pointer (QPoint) 664 @param pos the position of the mouse pointer
665 @type QPoint
644 """ 666 """
645 itm = self.usersList.itemAt(pos) 667 itm = self.usersList.itemAt(pos)
646 self.__kickUserAct.setEnabled(itm is not None) 668 self.__kickUserAct.setEnabled(itm is not None)
647 self.__banUserAct.setEnabled(itm is not None) 669 self.__banUserAct.setEnabled(itm is not None)
648 self.__banKickUserAct.setEnabled(itm is not None) 670 self.__banKickUserAct.setEnabled(itm is not None)

eric ide

mercurial