# 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
  reference to the user interface object (UserInterface)
port
  port to be used for the cooperation server (integer)
parent
  reference to the parent widget (QWidget)

#### 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
  hash of the project (string)
fileName
  project relative file name of the editor (string)
message
  command message (string)

#### ChatWidget.__getConnectionParameters

__getConnectionParameters()

Private method to determine the connection parameters.

Return:
  tuple with hostname and port (string, integer)

#### 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
  nick name of the new participant (string)

#### ChatWidget.__participantLeft

__participantLeft(nick)

Private slot handling a participant leaving the session.

nick
  nick name of the participant (string)

#### 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
  new connected state (boolean)

#### ChatWidget.__setHostsHistory

__setHostsHistory(host)

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

host
  host entry to remember (string)

#### ChatWidget.__showErrorMessage

__showErrorMessage(message)

Private slot to show an error message.

message
  error message to show (string)

#### ChatWidget.appendMessage

appendMessage(from_, message)

Public slot to append a message to the display.

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

#### ChatWidget.checkEditorActions

checkEditorActions(editor)

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

editor
  reference to the editor (Editor)

#### ChatWidget.getClient

getClient()

Public method to get a reference to the cooperation client.

Return:
  reference to the cooperation client (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
  flag signaling the availability of selected text (boolean)

#### ChatWidget.on_chatEdit_customContextMenuRequested

on_chatEdit_customContextMenuRequested(pos)

Private slot to show the context menu for the chat.

pos
  the position of the mouse pointer (QPoint)

#### 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
  host to connect to (string)

#### 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
  flag indicating the button state (boolean)

#### ChatWidget.on_startEditButton_clicked

on_startEditButton_clicked(checked)

Private slot to start a shared edit session.

checked
  flag indicating the button state (boolean)

#### ChatWidget.on_usersList_customContextMenuRequested

on_usersList_customContextMenuRequested(pos)

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

pos
  the position of the mouse pointer (QPoint)

#### ChatWidget.preferencesChanged

preferencesChanged()

Public slot to handle a change of preferences.

#### ChatWidget.shutdown

shutdown()

Public method to shut down the cooperation system.

Up