Cooperation/ChatWidget.py

Sat, 07 Apr 2012 21:19:24 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 07 Apr 2012 21:19:24 +0200
changeset 1770
c17e67e69ef5
parent 1509
c0b5e693b0eb
child 2190
abd65b78425e
child 2251
3d9fce89b12b
permissions
-rw-r--r--

Added a tool to take screenshots (fullscreen or rectangular selection).

149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
1509
c0b5e693b0eb Updated copyright for 2012.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1221
diff changeset
3 # Copyright (c) 2010 - 2012 Detlev Offenbach <detlev@die-offenbachs.de>
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the chat dialog.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
10 from PyQt4.QtCore import Qt, pyqtSlot, pyqtSignal, QDateTime, QPoint, QFileInfo
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
11 from PyQt4.QtGui import QWidget, QColor, QListWidgetItem, QMenu, QApplication
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
13 from E5Gui.E5Application import e5App
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
14 from E5Gui import E5MessageBox, E5FileDialog
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
15
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
16 from Globals import recentNameHosts
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
17
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
18 from QScintilla.Editor import Editor
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
19
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from .CooperationClient import CooperationClient
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from .Ui_ChatWidget import Ui_ChatWidget
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import Preferences
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
25 import Utilities
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 import UI.PixmapCache
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
28
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 class ChatWidget(QWidget, Ui_ChatWidget):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Class implementing the chat dialog.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
32
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
33 @signal connected(connected) emitted to signal a change of the connected
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 165
diff changeset
34 state (bool)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
35 @signal editorCommand(hash, filename, message) emitted when an editor command
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
36 has been received (string, string, string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
37 @signal shareEditor(share) emitted to signal a share is requested (bool)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
38 @signal startEdit() emitted to start a shared edit session
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
39 @signal sendEdit() emitted to send a shared edit session
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
40 @signal cancelEdit() emitted to cancel a shared edit session
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
42 connected = pyqtSignal(bool)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
43 editorCommand = pyqtSignal(str, str, str)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
44
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
45 shareEditor = pyqtSignal(bool)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
46 startEdit = pyqtSignal()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
47 sendEdit = pyqtSignal()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
48 cancelEdit = pyqtSignal()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
49
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
50 def __init__(self, port=-1, parent=None):
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 Constructor
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @param port port to be used for the cooperation server (integer)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @param parent reference to the parent widget (QWidget)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
1131
7781e396c903 Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
57 super().__init__(parent)
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.setupUi(self)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
60 self.shareButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
61 UI.PixmapCache.getIcon("sharedEditDisconnected.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
62 self.startEditButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
63 UI.PixmapCache.getIcon("sharedEditStart.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
64 self.sendEditButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
65 UI.PixmapCache.getIcon("sharedEditSend.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
66 self.cancelEditButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
67 UI.PixmapCache.getIcon("sharedEditCancel.png"))
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
68 self.clearMessageButton.setIcon(
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
69 UI.PixmapCache.getIcon("clearLeft.png"))
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
70 self.clearHostButton.setIcon(
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
71 UI.PixmapCache.getIcon("clearLeft.png"))
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
72
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
73 self.__client = CooperationClient(self)
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__myNickName = self.__client.nickName()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
76 self.__initChatMenu()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
77 self.__initUsersMenu()
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
78
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.messageEdit.returnPressed.connect(self.__handleMessage)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.sendButton.clicked.connect(self.__handleMessage)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__client.newMessage.connect(self.appendMessage)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__client.newParticipant.connect(self.__newParticipant)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.__client.participantLeft.connect(self.__participantLeft)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.__client.connectionError.connect(self.__showErrorMessage)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__client.cannotConnect.connect(self.__initialConnectionRefused)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
86 self.__client.editorCommand.connect(self.__editorCommandMessage)
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.serverButton.setText(self.trUtf8("Start Server"))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.serverLed.setColor(QColor(Qt.red))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 if port == -1:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 port = Preferences.getCooperation("ServerPort")
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.serverPortSpin.setValue(port)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__setConnected(False)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 if Preferences.getCooperation("AutoStartServer"):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.on_serverButton_clicked()
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
99
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
100 self.recent = []
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
101 self.__loadHostsHistory()
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
102
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
103 def __loadHostsHistory(self):
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
104 """
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
105 Private method to load the recently connected hosts.
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
106 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
107 self.__recent = []
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
108 Preferences.Prefs.rsettings.sync()
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
109 rh = Preferences.Prefs.rsettings.value(recentNameHosts)
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
110 if rh is not None:
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
111 self.__recent = rh[:20]
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
112 self.hostEdit.clear()
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
113 self.hostEdit.addItems(self.__recent)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
114 self.hostEdit.clearEditText()
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
115
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
116 def __saveHostsHistory(self):
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
117 """
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
118 Private method to save the list of recently connected hosts.
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
119 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
120 Preferences.Prefs.rsettings.setValue(recentNameHosts, self.__recent)
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
121 Preferences.Prefs.rsettings.sync()
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
122
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
123 def __setHostsHistory(self, host):
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
124 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
125 Private method to remember the given host as the most recent entry.
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
126
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
127 @param host host entry to remember (string)
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
128 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
129 if host in self.__recent:
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
130 self.__recent.remove(host)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
131 self.__recent.insert(0, host)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
132 self.__saveHostsHistory()
164
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
133 self.hostEdit.clear()
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
134 self.hostEdit.addItems(self.__recent)
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
135
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
136 def __clearHostsHistory(self):
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
137 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
138 Private slot to clear the hosts history.
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
139 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
140 self.__recent = []
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
141 self.__saveHostsHistory()
164
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
142 self.hostEdit.clear()
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
143 self.hostEdit.addItems(self.__recent)
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 def __handleMessage(self):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 Private slot handling the Return key pressed in the message edit.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 text = self.messageEdit.text()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if text == "":
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 return
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if text.startswith("/"):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 self.__showErrorMessage(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 self.trUtf8("! Unknown command: {0}\n").format(text.split()[0]))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 else:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.__client.sendMessage(text)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.appendMessage(self.__myNickName, text)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.messageEdit.clear()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 def __newParticipant(self, nick):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 Private slot handling a new participant joining.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 @param nick nick name of the new participant (string)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if nick == "":
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 return
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 color = self.chatEdit.textColor()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self.chatEdit.setTextColor(Qt.gray)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.chatEdit.append(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":")
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.chatEdit.append(self.trUtf8("* {0} has joined.\n").format(nick))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.chatEdit.setTextColor(color)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 QListWidgetItem(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 UI.PixmapCache.getIcon(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
180 "chatUser{0}.png".format(1 + self.usersList.count() % 6)),
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 nick, self.usersList)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 if not self.__connected:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.__setConnected(True)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 def __participantLeft(self, nick):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 Private slot handling a participant leaving the session.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 @param nick nick name of the participant (string)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 if nick == "":
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 return
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 items = self.usersList.findItems(nick, Qt.MatchExactly)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 for item in items:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.usersList.takeItem(self.usersList.row(item))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 del item
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 color = self.chatEdit.textColor()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self.chatEdit.setTextColor(Qt.gray)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.chatEdit.append(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":")
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.chatEdit.append(self.trUtf8("* {0} has left.\n").format(nick))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.chatEdit.setTextColor(color)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 if not self.__client.hasConnections():
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.__setConnected(False)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def appendMessage(self, from_, message):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Public slot to append a message to the display.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @param from_ originator of the message (string)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 @param message message to be appended (string)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if from_ == "" or message == "":
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 return
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.chatEdit.append(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + \
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 " <" + from_ + ">:")
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 self.chatEdit.append(message + "\n")
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 bar = self.chatEdit.verticalScrollBar()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 bar.setValue(bar.maximum())
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 @pyqtSlot(str)
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
228 def on_hostEdit_editTextChanged(self, host):
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 Private slot handling the entry of a host to connect to.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @param host host to connect to (string)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if not self.__connected:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 self.connectButton.setEnabled(host != "")
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
237 def __getConnectionParameters(self):
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
238 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
239 Private method to determine the connection parameters.
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
240
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
241 @return tuple with hostname and port (string, integer)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
242 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
243 hostEntry = self.hostEdit.currentText()
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
244 if "@" in hostEntry:
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
245 host, port = hostEntry.split("@")
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
246 try:
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
247 port = int(port)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
248 except ValueError:
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
249 port = Preferences.getCooperation("ServerPort")
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
250 self.hostEdit.setEditText("{0}@{1}".format(host, port))
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
251 else:
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
252 host = hostEntry
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
253 port = Preferences.getCooperation("ServerPort")
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
254 self.hostEdit.setEditText("{0}@{1}".format(host, port))
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
255 return host, port
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
256
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 @pyqtSlot()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 def on_connectButton_clicked(self):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 Private slot initiating the connection.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 if not self.__connected:
164
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
263 host, port = self.__getConnectionParameters()
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
264 self.__setHostsHistory(self.hostEdit.currentText())
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
265 if not self.__client.isListening():
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.on_serverButton_clicked()
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
267 if self.__client.isListening():
164
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
268 self.__client.connectToHost(host, port)
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.__setConnected(True)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 else:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 self.__client.disconnectConnections()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 self.__setConnected(False)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 @pyqtSlot()
164
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
275 def on_clearHostsButton_clicked(self):
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
276 """
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
277 Private slot to clear the hosts list.
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
278 """
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
279 self.__clearHostsHistory()
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
280
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
281 @pyqtSlot()
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 def on_serverButton_clicked(self):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 Private slot to start the server.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 """
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
286 if self.__client.isListening():
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
287 self.__client.close()
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 self.serverButton.setText(self.trUtf8("Start Server"))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.serverPortSpin.setEnabled(True)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 if self.serverPortSpin.value() != Preferences.getCooperation("ServerPort"):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 self.serverPortSpin.setValue(Preferences.getCooperation("ServerPort"))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.serverLed.setColor(QColor(Qt.red))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 else:
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
294 res, port = self.__client.startListening(self.serverPortSpin.value())
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 if res:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 self.serverButton.setText(self.trUtf8("Stop Server"))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.serverPortSpin.setValue(port)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.serverPortSpin.setEnabled(False)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 self.serverLed.setColor(QColor(Qt.green))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 else:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 self.__showErrorMessage(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 self.trUtf8("! Server Error: {0}\n").format(
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
303 self.__client.errorString())
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 )
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 def __setConnected(self, connected):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 Private slot to set the connected state.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 @param connected new connected state (boolean)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 if connected:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 self.connectButton.setText(self.trUtf8("Disconnect"))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 self.connectButton.setEnabled(True)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 self.connectionLed.setColor(QColor(Qt.green))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 else:
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self.connectButton.setText(self.trUtf8("Connect"))
161
bb3cc98f4104 Added code to remember the 20 most recently connected hosts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
318 self.connectButton.setEnabled(self.hostEdit.currentText() != "")
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.connectionLed.setColor(QColor(Qt.red))
164
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
320 self.on_cancelEditButton_clicked()
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
321 self.shareButton.setChecked(False)
b395b006d2a8 Fixed a few issues with the new cooperation stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 163
diff changeset
322 self.on_shareButton_clicked(False)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
323 self.__connected = connected
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
324 self.hostEdit.setEnabled(not connected)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
325 self.serverButton.setEnabled(not connected)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
326 self.sharingGroup.setEnabled(connected)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
327
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
328 if connected:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
329 vm = e5App().getObject("ViewManager")
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
330 aw = vm.activeWindow()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
331 if aw:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
332 self.checkEditorActions(aw)
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 def __showErrorMessage(self, message):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 Private slot to show an error message.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 @param message error message to show (string)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 color = self.chatEdit.textColor()
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 self.chatEdit.setTextColor(Qt.red)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.chatEdit.append(
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":")
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
344 self.chatEdit.append(message + "\n")
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 self.chatEdit.setTextColor(color)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 def __initialConnectionRefused(self):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 Private slot to handle the refusal of the initial connection.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 self.__setConnected(False)
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 def preferencesChanged(self):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 """
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 Public slot to handle a change of preferences.
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 """
1221
291dc0a51947 Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
357 if not self.__client.isListening():
149
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 self.serverPortSpin.setValue(Preferences.getCooperation("ServerPort"))
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 if Preferences.getCooperation("AutoStartServer"):
a134031209be Added stage 1 of the cooperation functions (chat system).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 self.on_serverButton_clicked()
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 149
diff changeset
361
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 149
diff changeset
362 def getClient(self):
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 149
diff changeset
363 """
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 149
diff changeset
364 Public method to get a reference to the cooperation client.
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 149
diff changeset
365 """
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 149
diff changeset
366 return self.__client
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
367
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
368 def __editorCommandMessage(self, hash, fileName, message):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
369 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
370 Private slot to handle editor command messages from the client.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
371
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
372 @param hash hash of the project (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
373 @param fileName project relative file name of the editor (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
374 @param message command message (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
375 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
376 self.editorCommand.emit(hash, fileName, message)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
377
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
378 if message.startswith(Editor.StartEditToken + Editor.Separator) or \
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
379 message.startswith(Editor.EndEditToken + Editor.Separator):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
380 vm = e5App().getObject("ViewManager")
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
381 aw = vm.activeWindow()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
382 if aw:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
383 self.checkEditorActions(aw)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
384
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
385 @pyqtSlot(bool)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
386 def on_shareButton_clicked(self, checked):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
387 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
388 Private slot to share the current editor.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
389
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
390 @param checked flag indicating the button state (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
391 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
392 if checked:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
393 self.shareButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
394 UI.PixmapCache.getIcon("sharedEditConnected.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
395 else:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
396 self.shareButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
397 UI.PixmapCache.getIcon("sharedEditDisconnected.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
398 self.startEditButton.setEnabled(checked)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
399
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
400 self.shareEditor.emit(checked)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
401
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
402 @pyqtSlot(bool)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
403 def on_startEditButton_clicked(self, checked):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
404 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
405 Private slot to start a shared edit session.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
406
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
407 @param checked flag indicating the button state (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
408 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
409 if checked:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
410 self.sendEditButton.setEnabled(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
411 self.cancelEditButton.setEnabled(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
412 self.shareButton.setEnabled(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
413 self.startEditButton.setEnabled(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
414
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
415 self.startEdit.emit()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
416
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
417 @pyqtSlot()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
418 def on_sendEditButton_clicked(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
419 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
420 Private slot to end a shared edit session and send the changes.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
421 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
422 self.sendEditButton.setEnabled(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
423 self.cancelEditButton.setEnabled(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
424 self.shareButton.setEnabled(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
425 self.startEditButton.setEnabled(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
426 self.startEditButton.setChecked(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
427
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
428 self.sendEdit.emit()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
429
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
430 @pyqtSlot()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
431 def on_cancelEditButton_clicked(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
432 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
433 Private slot to cancel a shared edit session.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
434 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
435 self.sendEditButton.setEnabled(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
436 self.cancelEditButton.setEnabled(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
437 self.shareButton.setEnabled(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
438 self.startEditButton.setEnabled(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
439 self.startEditButton.setChecked(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
440
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
441 self.cancelEdit.emit()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
442
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
443 def checkEditorActions(self, editor):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
444 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
445 Public slot to set action according to an editor's state.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
446
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
447 @param editor reference to the editor (Editor)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
448 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
449 shareable, sharing, editing, remoteEditing = editor.getSharingStatus()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
450
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
451 self.shareButton.setChecked(sharing)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
452 if sharing:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
453 self.shareButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
454 UI.PixmapCache.getIcon("sharedEditConnected.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
455 else:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
456 self.shareButton.setIcon(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
457 UI.PixmapCache.getIcon("sharedEditDisconnected.png"))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
458 self.startEditButton.setChecked(editing)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
459
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
460 self.shareButton.setEnabled(shareable and not editing)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
461 self.startEditButton.setEnabled(sharing and not editing and not remoteEditing)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
462 self.sendEditButton.setEnabled(editing)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
463 self.cancelEditButton.setEnabled(editing)
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
464
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
465 def __initChatMenu(self):
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
466 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
467 Private slot to initialize the chat edit context menu.
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
468 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
469 self.__chatMenu = QMenu(self)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
470 self.__cutChatAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
471 self.__chatMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
472 UI.PixmapCache.getIcon("editCut.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
473 self.trUtf8("Cut"), self.__cutChat)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
474 self.__copyChatAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
475 self.__chatMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
476 UI.PixmapCache.getIcon("editCopy.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
477 self.trUtf8("Copy"), self.__copyChat)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
478 self.__chatMenu.addSeparator()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
479 self.__cutAllChatAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
480 self.__chatMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
481 UI.PixmapCache.getIcon("editCut.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
482 self.trUtf8("Cut all"), self.__cutAllChat)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
483 self.__copyAllChatAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
484 self.__chatMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
485 UI.PixmapCache.getIcon("editCopy.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
486 self.trUtf8("Copy all"), self.__copyAllChat)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
487 self.__chatMenu.addSeparator()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
488 self.__clearChatAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
489 self.__chatMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
490 UI.PixmapCache.getIcon("editDelete.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
491 self.trUtf8("Clear"), self.__clearChat)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
492 self.__chatMenu.addSeparator()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
493 self.__saveChatAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
494 self.__chatMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
495 UI.PixmapCache.getIcon("fileSave.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
496 self.trUtf8("Save"), self.__saveChat)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
497
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
498 @pyqtSlot(bool)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
499 def on_chatEdit_copyAvailable(self, yes):
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
500 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
501 Private slot to react to text selection/deselection of the chat edit.
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
502
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
503 @param yes flag signaling the availability of selected text (boolean)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
504 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
505 self.__copyChatAct.setEnabled(yes)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
506 self.__cutChatAct.setEnabled(yes)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
507
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
508 @pyqtSlot(QPoint)
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
509 def on_chatEdit_customContextMenuRequested(self, pos):
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
510 """
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
511 Private slot to show the context menu for the chat.
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
512
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
513 @param pos the position of the mouse pointer (QPoint)
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
514 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
515 enable = self.chatEdit.toPlainText() != ""
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
516 self.__saveChatAct.setEnabled(enable)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
517 self.__copyAllChatAct.setEnabled(enable)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
518 self.__cutAllChatAct.setEnabled(enable)
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
519 self.__chatMenu.popup(self.chatEdit.mapToGlobal(pos))
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
520
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
521 def __clearChat(self):
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
522 """
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
523 Private slot to clear the contents of the chat display.
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
524 """
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
525 self.chatEdit.clear()
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
526
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
527 def __saveChat(self):
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
528 """
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
529 Private slot to save the contents of the chat display.
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
530 """
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
531 txt = self.chatEdit.toPlainText()
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
532 if txt:
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
533 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
534 self,
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
535 self.trUtf8("Save Chat"),
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
536 "",
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
537 self.trUtf8("Text Files (*.txt);;All Files (*)"),
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
538 None,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
539 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
540 if fname:
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
541 ext = QFileInfo(fname).suffix()
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
542 if not ext:
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
543 ex = selectedFilter.split("(*")[1].split(")")[0]
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
544 if ex:
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
545 fname += ex
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
546 if QFileInfo(fname).exists():
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
547 res = E5MessageBox.yesNo(self,
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
548 self.trUtf8("Save Chat"),
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
549 self.trUtf8("<p>The file <b>{0}</b> already exists."
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
550 " Overwrite it?</p>").format(fname),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
551 icon=E5MessageBox.Warning)
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
552 if not res:
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
553 return
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
554 fname = Utilities.toNativeSeparators(fname)
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
555
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
556 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
557 f = open(fname, "w", encoding="utf-8")
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
558 f.write(txt)
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
559 f.close()
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
560 except IOError as err:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
561 E5MessageBox.critical(self,
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
562 self.trUtf8("Error saving Chat"),
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
563 self.trUtf8("""<p>The chat contents could not be written"""
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
564 """ to <b>{0}</b></p><p>Reason: {1}</p>""")\
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
565 .format(fname, str(err)))
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
566
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
567 def __copyChat(self):
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
568 """
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
569 Private slot to copy the contents of the chat display to the clipboard.
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
570 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
571 self.chatEdit.copy()
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
572
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
573 def __cutChat(self):
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
574 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
575 Private slot to cut the contents of the chat display to the clipboard.
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
576 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
577 self.chatEdit.cut()
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
578
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
579 def __copyAllChat(self):
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
580 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
581 Private slot to copy the contents of the chat display to the clipboard.
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
582 """
160
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
583 txt = self.chatEdit.toPlainText()
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
584 if txt:
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
585 cb = QApplication.clipboard()
32cc58d56d4d Added a context menu to the chat widget to clear the chat, to save it or to copy it to the clipboard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
586 cb.setText(txt)
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
587
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
588 def __cutAllChat(self):
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
589 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
590 Private slot to cut the contents of the chat display to the clipboard.
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
591 """
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
592 txt = self.chatEdit.toPlainText()
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
593 if txt:
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
594 cb = QApplication.clipboard()
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
595 cb.setText(txt)
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 161
diff changeset
596 self.chatEdit.clear()
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
597
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
598 def __initUsersMenu(self):
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
599 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
600 Private slot to initialize the users list context menu.
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
601 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
602 self.__usersMenu = QMenu(self)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
603 self.__kickUserAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
604 self.__usersMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
605 UI.PixmapCache.getIcon("chatKickUser.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
606 self.trUtf8("Kick User"), self.__kickUser)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
607 self.__banUserAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
608 self.__usersMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
609 UI.PixmapCache.getIcon("chatBanUser.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
610 self.trUtf8("Ban User"), self.__banUser)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
611 self.__banKickUserAct = \
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
612 self.__usersMenu.addAction(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
613 UI.PixmapCache.getIcon("chatBanKickUser.png"),
165
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
614 self.trUtf8("Ban and Kick User"), self.__banKickUser)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
615
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
616 @pyqtSlot(QPoint)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
617 def on_usersList_customContextMenuRequested(self, pos):
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
618 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
619 Private slot to show the context menu for the users list.
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
620
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
621 @param pos the position of the mouse pointer (QPoint)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
622 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
623 itm = self.usersList.itemAt(pos)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
624 self.__kickUserAct.setEnabled(itm is not None)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
625 self.__banUserAct.setEnabled(itm is not None)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
626 self.__banKickUserAct.setEnabled(itm is not None)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
627 self.__usersMenu.popup(self.usersList.mapToGlobal(pos))
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
628
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
629 def __kickUser(self):
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
630 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
631 Private slot to disconnect a user.
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
632 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
633 itm = self.usersList.currentItem()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
634 self.__client.kickUser(itm.text())
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
635
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
636 color = self.chatEdit.textColor()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
637 self.chatEdit.setTextColor(Qt.darkYellow)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
638 self.chatEdit.append(
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
639 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":")
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
640 self.chatEdit.append(self.trUtf8("* {0} has been kicked.\n").format(
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
641 itm.text().split(":")[0]))
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
642 self.chatEdit.setTextColor(color)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
643
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
644 def __banUser(self):
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
645 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
646 Private slot to ban a user.
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
647 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
648 itm = self.usersList.currentItem()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
649 self.__client.banUser(itm.text())
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
650
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
651 color = self.chatEdit.textColor()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
652 self.chatEdit.setTextColor(Qt.darkYellow)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
653 self.chatEdit.append(
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
654 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":")
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
655 self.chatEdit.append(self.trUtf8("* {0} has been banned.\n").format(
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
656 itm.text().split(":")[0]))
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
657 self.chatEdit.setTextColor(color)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
658
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
659 def __banKickUser(self):
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
660 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
661 Private slot to ban and kick a user.
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
662 """
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
663 itm = self.usersList.currentItem()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
664 self.__client.banKickUser(itm.text())
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
665
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
666 color = self.chatEdit.textColor()
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
667 self.chatEdit.setTextColor(Qt.darkYellow)
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
668 self.chatEdit.append(
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
669 QDateTime.currentDateTime().toString(Qt.SystemLocaleLongDate) + ":")
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
670 self.chatEdit.append(self.trUtf8("* {0} has been banned and kicked.\n").format(
3302a726fd1e Added functionality to kick and ban users and to manage banned users.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 164
diff changeset
671 itm.text().split(":")[0]))
880
52ed20236a1c Added the option to not use the native file dialog to prevent crashes on Linux.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
672 self.chatEdit.setTextColor(color)

eric ide

mercurial