# eric7.Cooperation.ChatWidget

Module implementing the chat dialog.

### Global Attributes

None

### Classes

ChatWidget | Class implementing the chat dialog.

### Functions

None

## ChatWidget

Class implementing the chat dialog.

### Signals

cancelEdit()
  emitted to cancel a shared edit session
connected(connected)
  emitted to signal a change of the connected state (bool)
editorCommand(hashStr, filename, message)
  emitted when an editor command has been received (string, string, string)
sendEdit()
  emitted to send a shared edit session
shareEditor(share)
  emitted to signal a share is requested (bool)
startEdit()
  emitted to start a shared edit session

### Derived from

QWidget, Ui_ChatWidget

### Class Attributes

None

### Class Methods

None

### Methods

ChatWidget | Constructor
__banKickUser | Private slot to ban and kick a user.
__banUser | Private slot to ban a user.
__clearChat | Private slot to clear the contents of the chat display.
__clearHostsHistory | Private slot to clear the hosts history.
__copyAllChat | Private slot to copy the contents of the chat display to the clipboard.
__copyChat | Private slot to copy the contents of the chat display to the clipboard.
__cutAllChat | Private slot to cut the contents of the chat display to the clipboard.
__editorCommandMessage | Private slot to handle editor command messages from the client.
__getConnectionParameters | Private method to determine the connection parameters.
__handleMessage | Private slot handling the Return key pressed in the message edit.
__initChatMenu | Private slot to initialize the chat edit context menu.
__initUsersMenu | Private slot to initialize the users list context menu.
__initialConnectionRefused | Private slot to handle the refusal of the initial connection.
__kickUser | Private slot to disconnect a user.
__loadHostsHistory | Private method to load the recently connected hosts.
__newParticipant | Private slot handling a new participant joining.
__participantLeft | Private slot handling a participant leaving the session.
__saveChat | Private slot to save the contents of the chat display.
__saveHostsHistory | Private method to save the list of recently connected hosts.
__setConnected | Private slot to set the connected state.
__setHostsHistory | Private method to remember the given host as the most recent entry.
__showErrorMessage | Private slot to show an error message.
appendMessage | Public slot to append a message to the display.
checkEditorActions | Public slot to set action according to an editor's state.
getClient | Public method to get a reference to the cooperation client.
on_cancelEditButton_clicked | Private slot to cancel a shared edit session.
on_chatEdit_copyAvailable | Private slot to react to text selection/deselection of the chat edit.
on_chatEdit_customContextMenuRequested | Private slot to show the context menu for the chat.
on_clearHostsButton_clicked | Private slot to clear the hosts list.
on_connectButton_clicked | Private slot initiating the connection.
on_hostEdit_editTextChanged | Private slot handling the entry of a host to connect to.
on_sendEditButton_clicked | Private slot to end a shared edit session and send the changes.
on_serverButton_clicked | Private slot to start the server.
on_shareButton_clicked | Private slot to share the current editor.
on_startEditButton_clicked | Private slot to start a shared edit session.
on_usersList_customContextMenuRequested | Private slot to show the context menu for the users list.
preferencesChanged | Public slot to handle a change of preferences.
shutdown | Public method to shut down the cooperation system.

### Static Methods

None

#### ChatWidget (Constructor)

ChatWidget(ui, port=-1, parent=None)

Constructor

ui (UserInterface)
  reference to the user interface object
port (int)
  port to be used for the cooperation server
parent (QWidget)
  reference to the parent widget

#### ChatWidget.__banKickUser

__banKickUser()

Private slot to ban and kick a user.

#### ChatWidget.__banUser

__banUser()

Private slot to ban a user.

#### ChatWidget.__clearChat

__clearChat()

Private slot to clear the contents of the chat display.

#### ChatWidget.__clearHostsHistory

__clearHostsHistory()

Private slot to clear the hosts history.

#### ChatWidget.__copyAllChat

__copyAllChat()

Private slot to copy the contents of the chat display to the clipboard.

#### ChatWidget.__copyChat

__copyChat()

Private slot to copy the contents of the chat display to the clipboard.

#### ChatWidget.__cutAllChat

__cutAllChat()

Private slot to cut the contents of the chat display to the clipboard.

#### ChatWidget.__editorCommandMessage

__editorCommandMessage(hashStr, fileName, message)

Private slot to handle editor command messages from the client.

hashStr (str)
  hash of the project
fileName (str)
  project relative file name of the editor
message (str)
  command message

#### ChatWidget.__getConnectionParameters

__getConnectionParameters()

Private method to determine the connection parameters.

Return:
  tuple with hostname and port

Return Type:
  tuple of (str, int)

#### ChatWidget.__handleMessage

__handleMessage()

Private slot handling the Return key pressed in the message edit.

#### ChatWidget.__initChatMenu

__initChatMenu()

Private slot to initialize the chat edit context menu.

#### ChatWidget.__initUsersMenu

__initUsersMenu()

Private slot to initialize the users list context menu.

#### ChatWidget.__initialConnectionRefused

__initialConnectionRefused()

Private slot to handle the refusal of the initial connection.

#### ChatWidget.__kickUser

__kickUser()

Private slot to disconnect a user.

#### ChatWidget.__loadHostsHistory

__loadHostsHistory()

Private method to load the recently connected hosts.

#### ChatWidget.__newParticipant

__newParticipant(nick)

Private slot handling a new participant joining.

nick (str)
  nick name of the new participant

#### ChatWidget.__participantLeft

__participantLeft(nick)

Private slot handling a participant leaving the session.

nick (str)
  nick name of the participant

#### ChatWidget.__saveChat

__saveChat()

Private slot to save the contents of the chat display.

#### ChatWidget.__saveHostsHistory

__saveHostsHistory()

Private method to save the list of recently connected hosts.

#### ChatWidget.__setConnected

__setConnected(connected)

Private slot to set the connected state.

connected (bool)
  new connected state

#### ChatWidget.__setHostsHistory

__setHostsHistory(host)

Private method to remember the given host as the most recent entry.

host (str)
  host entry to remember

#### ChatWidget.__showErrorMessage

__showErrorMessage(message)

Private slot to show an error message.

message (str)
  error message to show

#### ChatWidget.appendMessage

appendMessage(from_, message)

Public slot to append a message to the display.

from_ (str)
  originator of the message
message (str)
  message to be appended

#### ChatWidget.checkEditorActions

checkEditorActions(editor)

Public slot to set action according to an editor's state.

editor (Editor)
  reference to the editor

#### ChatWidget.getClient

getClient()

Public method to get a reference to the cooperation client.

Return:
  reference to the cooperation client

Return Type:
  CooperationClient

#### ChatWidget.on_cancelEditButton_clicked

on_cancelEditButton_clicked()

Private slot to cancel a shared edit session.

#### ChatWidget.on_chatEdit_copyAvailable

on_chatEdit_copyAvailable(yes)

Private slot to react to text selection/deselection of the chat edit.

yes (bool)
  flag signaling the availability of selected text

#### ChatWidget.on_chatEdit_customContextMenuRequested

on_chatEdit_customContextMenuRequested(pos)

Private slot to show the context menu for the chat.

pos (QPoint)
  the position of the mouse pointer

#### ChatWidget.on_clearHostsButton_clicked

on_clearHostsButton_clicked()

Private slot to clear the hosts list.

#### ChatWidget.on_connectButton_clicked

on_connectButton_clicked()

Private slot initiating the connection.

#### ChatWidget.on_hostEdit_editTextChanged

on_hostEdit_editTextChanged(host)

Private slot handling the entry of a host to connect to.

host (str)
  host to connect to

#### ChatWidget.on_sendEditButton_clicked

on_sendEditButton_clicked()

Private slot to end a shared edit session and send the changes.

#### ChatWidget.on_serverButton_clicked

on_serverButton_clicked()

Private slot to start the server.

#### ChatWidget.on_shareButton_clicked

on_shareButton_clicked(checked)

Private slot to share the current editor.

checked (bool)
  flag indicating the button state

#### ChatWidget.on_startEditButton_clicked

on_startEditButton_clicked(checked)

Private slot to start a shared edit session.

checked (bool)
  flag indicating the button state

#### ChatWidget.on_usersList_customContextMenuRequested

on_usersList_customContextMenuRequested(pos)

Private slot to show the context menu for the users list.

pos (QPoint)
  the position of the mouse pointer

#### ChatWidget.preferencesChanged

preferencesChanged()

Public slot to handle a change of preferences.

#### ChatWidget.shutdown

shutdown()

Public method to shut down the cooperation system.

Up