src/eric7/Network/IRC/IrcNetworkWidget.py

branch
eric7
changeset 10428
a071d4065202
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10427:3733e2b23cf7 10428:a071d4065202
47 47
48 def __init__(self, parent=None): 48 def __init__(self, parent=None):
49 """ 49 """
50 Constructor 50 Constructor
51 51
52 @param parent reference to the parent widget (QWidget) 52 @param parent reference to the parent widget
53 @type QWidget
53 """ 54 """
54 super().__init__(parent) 55 super().__init__(parent)
55 self.setupUi(self) 56 self.setupUi(self)
56 57
57 self.connectButton.setIcon(EricPixmapCache.getIcon("ircConnect")) 58 self.connectButton.setIcon(EricPixmapCache.getIcon("ircConnect"))
79 80
80 def initialize(self, manager): 81 def initialize(self, manager):
81 """ 82 """
82 Public method to initialize the widget. 83 Public method to initialize the widget.
83 84
84 @param manager reference to the network manager (IrcNetworkManager) 85 @param manager reference to the network manager
86 @type IrcNetworkManager
85 """ 87 """
86 self.__manager = manager 88 self.__manager = manager
87 89
88 self.networkCombo.addItems(self.__manager.getNetworkNames()) 90 self.networkCombo.addItems(self.__manager.getNetworkNames())
89 91
210 @pyqtSlot(str) 212 @pyqtSlot(str)
211 def on_channelCombo_editTextChanged(self, txt): 213 def on_channelCombo_editTextChanged(self, txt):
212 """ 214 """
213 Private slot to react upon changes of the channel. 215 Private slot to react upon changes of the channel.
214 216
215 @param txt current text of the channel combo (string) 217 @param txt current text of the channel combo
218 @type str
216 """ 219 """
217 on = bool(txt) and self.__registered 220 on = bool(txt) and self.__registered
218 self.joinButton.setEnabled(on) 221 self.joinButton.setEnabled(on)
219 222
220 @pyqtSlot() 223 @pyqtSlot()
250 def getNetworkChannels(self): 253 def getNetworkChannels(self):
251 """ 254 """
252 Public method to get the list of channels associated with the 255 Public method to get the list of channels associated with the
253 selected network. 256 selected network.
254 257
255 @return associated channels (list of IrcChannel) 258 @return associated channels
259 @rtype list of IrcChannel
256 """ 260 """
257 networkName = self.networkCombo.currentText() 261 networkName = self.networkCombo.currentText()
258 network = self.__manager.getNetwork(networkName) 262 network = self.__manager.getNetwork(networkName)
259 return network.getChannels() 263 return network.getChannels()
260 264
263 def on_nickCombo_currentIndexChanged(self, nick=0): 267 def on_nickCombo_currentIndexChanged(self, nick=0):
264 """ 268 """
265 Private slot to use another nick name. 269 Private slot to use another nick name.
266 270
267 @param nick index of the selected nick name (unused) 271 @param nick index of the selected nick name (unused)
272 @type int
268 """ 273 """
269 if self.__connected: 274 if self.__connected:
270 self.nickChanged.emit(self.nickCombo.currentText()) 275 self.nickChanged.emit(self.nickCombo.currentText())
271 276
272 def getNickname(self): 277 def getNickname(self):
273 """ 278 """
274 Public method to get the currently selected nick name. 279 Public method to get the currently selected nick name.
275 280
276 @return selected nick name (string) 281 @return selected nick name
282 @rtype str
277 """ 283 """
278 return self.nickCombo.currentText() 284 return self.nickCombo.currentText()
279 285
280 def setNickName(self, nick): 286 def setNickName(self, nick):
281 """ 287 """
282 Public slot to set the nick name in use. 288 Public slot to set the nick name in use.
283 289
284 @param nick nick name in use (string) 290 @param nick nick name in use
291 @type str
285 """ 292 """
286 self.nickCombo.blockSignals(True) 293 self.nickCombo.blockSignals(True)
287 self.nickCombo.setEditText(nick) 294 self.nickCombo.setEditText(nick)
288 self.nickCombo.blockSignals(False) 295 self.nickCombo.blockSignals(False)
289 296
290 def addMessage(self, msg): 297 def addMessage(self, msg):
291 """ 298 """
292 Public method to add a message. 299 Public method to add a message.
293 300
294 @param msg message to be added (string) 301 @param msg message to be added
302 @type str
295 """ 303 """
296 s = '<font color="{0}">{1} {2}</font>'.format( 304 s = '<font color="{0}">{1} {2}</font>'.format(
297 Preferences.getIrc("NetworkMessageColour"), ircTimestamp(), msg 305 Preferences.getIrc("NetworkMessageColour"), ircTimestamp(), msg
298 ) 306 )
299 self.messages.append(s) 307 self.messages.append(s)
300 308
301 def addServerMessage(self, msgType, msg, filterMsg=True): 309 def addServerMessage(self, msgType, msg, filterMsg=True):
302 """ 310 """
303 Public method to add a server message. 311 Public method to add a server message.
304 312
305 @param msgType txpe of the message (string) 313 @param msgType txpe of the message
306 @param msg message to be added (string) 314 @type str
307 @param filterMsg flag indicating to filter the message (boolean) 315 @param msg message to be added
316 @type str
317 @param filterMsg flag indicating to filter the message
318 @type bool
308 """ 319 """
309 if filterMsg: 320 if filterMsg:
310 msg = ircFilter(msg) 321 msg = ircFilter(msg)
311 s = '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format( 322 s = '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format(
312 Preferences.getIrc("ServerMessageColour"), ircTimestamp(), msgType, msg 323 Preferences.getIrc("ServerMessageColour"), ircTimestamp(), msgType, msg
315 326
316 def addErrorMessage(self, msgType, msg): 327 def addErrorMessage(self, msgType, msg):
317 """ 328 """
318 Public method to add an error message. 329 Public method to add an error message.
319 330
320 @param msgType txpe of the message (string) 331 @param msgType txpe of the message
321 @param msg message to be added (string) 332 @type str
333 @param msg message to be added
334 @type str
322 """ 335 """
323 s = '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format( 336 s = '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format(
324 Preferences.getIrc("ErrorMessageColour"), ircTimestamp(), msgType, msg 337 Preferences.getIrc("ErrorMessageColour"), ircTimestamp(), msgType, msg
325 ) 338 )
326 self.messages.append(s) 339 self.messages.append(s)
327 340
328 def setConnected(self, connected): 341 def setConnected(self, connected):
329 """ 342 """
330 Public slot to set the connection state. 343 Public slot to set the connection state.
331 344
332 @param connected flag indicating the connection state (boolean) 345 @param connected flag indicating the connection state
346 @type bool
333 """ 347 """
334 self.__connected = connected 348 self.__connected = connected
335 if self.__connected: 349 if self.__connected:
336 self.connectButton.setIcon(EricPixmapCache.getIcon("ircDisconnect")) 350 self.connectButton.setIcon(EricPixmapCache.getIcon("ircDisconnect"))
337 self.connectButton.setToolTip( 351 self.connectButton.setToolTip(
345 359
346 def isConnected(self): 360 def isConnected(self):
347 """ 361 """
348 Public method to check, if the network is connected. 362 Public method to check, if the network is connected.
349 363
350 @return flag indicating a connected network (boolean) 364 @return flag indicating a connected network
365 @rtype bool
351 """ 366 """
352 return self.__connected 367 return self.__connected
353 368
354 def setRegistered(self, registered): 369 def setRegistered(self, registered):
355 """ 370 """
356 Public slot to set the registered state. 371 Public slot to set the registered state.
357 372
358 @param registered flag indicating the registration state (boolean) 373 @param registered flag indicating the registration state
374 @type bool
359 """ 375 """
360 self.__registered = registered 376 self.__registered = registered
361 on = bool(self.channelCombo.currentText()) and self.__registered 377 on = bool(self.channelCombo.currentText()) and self.__registered
362 self.joinButton.setEnabled(on) 378 self.joinButton.setEnabled(on)
363 self.nickCombo.setEnabled(registered) 379 self.nickCombo.setEnabled(registered)
493 def on_messages_copyAvailable(self, yes): 509 def on_messages_copyAvailable(self, yes):
494 """ 510 """
495 Private slot to react to text selection/deselection of the 511 Private slot to react to text selection/deselection of the
496 messages edit. 512 messages edit.
497 513
498 @param yes flag signaling the availability of selected text (boolean) 514 @param yes flag signaling the availability of selected text
515 @type bool
499 """ 516 """
500 self.__copyMessagesAct.setEnabled(yes) 517 self.__copyMessagesAct.setEnabled(yes)
501 518
502 @pyqtSlot(QPoint) 519 @pyqtSlot(QPoint)
503 def on_messages_customContextMenuRequested(self, pos): 520 def on_messages_customContextMenuRequested(self, pos):
504 """ 521 """
505 Private slot to show the context menu of the messages pane. 522 Private slot to show the context menu of the messages pane.
506 523
507 @param pos position the menu should be opened at (QPoint) 524 @param pos position the menu should be opened at
525 @type QPoint
508 """ 526 """
509 enable = not self.messages.document().isEmpty() 527 enable = not self.messages.document().isEmpty()
510 self.__cutAllMessagesAct.setEnabled(enable) 528 self.__cutAllMessagesAct.setEnabled(enable)
511 self.__copyAllMessagesAct.setEnabled(enable) 529 self.__copyAllMessagesAct.setEnabled(enable)
512 self.__saveMessagesAct.setEnabled(enable) 530 self.__saveMessagesAct.setEnabled(enable)
515 @pyqtSlot(QUrl) 533 @pyqtSlot(QUrl)
516 def on_messages_anchorClicked(self, url): 534 def on_messages_anchorClicked(self, url):
517 """ 535 """
518 Private slot to open links in the default browser. 536 Private slot to open links in the default browser.
519 537
520 @param url URL to be opened (QUrl) 538 @param url URL to be opened
539 @type QUrl
521 """ 540 """
522 QDesktopServices.openUrl(url) 541 QDesktopServices.openUrl(url)

eric ide

mercurial