Network/IRC/IrcNetworkWidget.py

Sat, 14 Dec 2013 23:44:25 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 14 Dec 2013 23:44:25 +0100
branch
Py2 comp.
changeset 3145
a9de05d4a22f
parent 3060
5883ce99ee12
child 3161
06f57a834adf
permissions
-rw-r--r--

# __IGNORE_WARNING__ added/ removed.

2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2279
diff changeset
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the network part of the IRC widget.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2446
diff changeset
11
2442
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
12 from PyQt4.QtCore import pyqtSlot, pyqtSignal, QPoint, QFileInfo, QUrl
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
13 from PyQt4.QtGui import QWidget, QApplication, QMenu, QDesktopServices
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
14
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
15 from E5Gui import E5MessageBox, E5FileDialog
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_IrcNetworkWidget import Ui_IrcNetworkWidget
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .IrcUtilities import ircFilter, ircTimestamp
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import UI.PixmapCache
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Preferences
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
23 import Utilities
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class IrcNetworkWidget(QWidget, Ui_IrcNetworkWidget):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing the network part of the IRC widget.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
30 @signal connectNetwork(str,bool) emitted to connect or disconnect from
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
31 a network
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @signal editNetwork(str) emitted to edit a network configuration
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @signal joinChannel(str) emitted to join a channel
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @signal nickChanged(str) emitted to change the nick name
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
35 @signal sendData(str) emitted to send a message to the channel
2246
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
36 @signal away(bool) emitted to indicate the away status
2258
9ca42fd3ecc0 Added a signal to the IRC widget fired after the autoconnect was initiated. This will make the IRC pane the current one on the right side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
37 @signal autoConnected() emitted after an automatic connection was initiated
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 connectNetwork = pyqtSignal(str, bool)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 editNetwork = pyqtSignal(str)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 joinChannel = pyqtSignal(str)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 nickChanged = pyqtSignal(str)
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
43 sendData = pyqtSignal(str)
2246
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
44 away = pyqtSignal(bool)
2258
9ca42fd3ecc0 Added a signal to the IRC widget fired after the autoconnect was initiated. This will make the IRC pane the current one on the right side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
45 autoConnected = pyqtSignal()
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def __init__(self, parent=None):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Constructor
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param parent reference to the parent widget (QWidget)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2446
diff changeset
53 super(IrcNetworkWidget, self).__init__(parent)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.setupUi(self)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect.png"))
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.editButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png"))
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.joinButton.setIcon(UI.PixmapCache.getIcon("ircJoinChannel.png"))
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
59 self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserPresent.png"))
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
60
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
61 self.joinButton.setEnabled(False)
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
62 self.nickCombo.setEnabled(False)
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
63 self.awayButton.setEnabled(False)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
65 self.channelCombo.lineEdit().returnPressed.connect(
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
66 self.on_joinButton_clicked)
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
67 self.nickCombo.lineEdit().returnPressed.connect(
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
68 self.on_nickCombo_currentIndexChanged)
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
69
2758
eacdcc89b74d Fixed a little (cosmetic) issue in the IRC network widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
70 self.setConnected(False)
eacdcc89b74d Fixed a little (cosmetic) issue in the IRC network widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
71
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
72 self.__initMessagesMenu()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
73
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__manager = None
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__connected = False
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
76 self.__registered = False
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
77 self.__away = False
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 def initialize(self, manager):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 Public method to initialize the widget.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param manager reference to the network manager (IrcNetworkManager)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__manager = manager
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.networkCombo.addItems(self.__manager.getNetworkNames())
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
88
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
89 self.__manager.networksChanged.connect(self.__refreshNetworks)
2279
cbf90feec16f Fixed a non-fatal issue in the IRC widget related to changing an identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
90 self.__manager.identitiesChanged.connect(self.__refreshNetworks)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
91
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
92 def autoConnect(self):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
93 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
94 Public method to perform the IRC auto connection.
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
95 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
96 for networkName in self.__manager.getNetworkNames():
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
97 if self.__manager.getNetwork(networkName).autoConnect():
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
98 row = self.networkCombo.findText(networkName)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
99 self.networkCombo.setCurrentIndex(row)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
100 self.on_connectButton_clicked()
2258
9ca42fd3ecc0 Added a signal to the IRC widget fired after the autoconnect was initiated. This will make the IRC pane the current one on the right side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
101 self.autoConnected.emit()
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
102 break
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
103
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
104 @pyqtSlot()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
105 def __refreshNetworks(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
106 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
107 Private slot to refresh all network related widgets.
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
108 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
109 currentNetwork = self.networkCombo.currentText()
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
110 currentNick = self.nickCombo.currentText()
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
111 currentChannel = self.channelCombo.currentText()
2279
cbf90feec16f Fixed a non-fatal issue in the IRC widget related to changing an identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
112 blocked = self.networkCombo.blockSignals(True)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
113 self.networkCombo.clear()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
114 self.networkCombo.addItems(self.__manager.getNetworkNames())
2279
cbf90feec16f Fixed a non-fatal issue in the IRC widget related to changing an identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
115 self.networkCombo.blockSignals(blocked)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
116 row = self.networkCombo.findText(currentNetwork)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
117 if row == -1:
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
118 row = 0
2279
cbf90feec16f Fixed a non-fatal issue in the IRC widget related to changing an identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
119 blocked = self.nickCombo.blockSignals(True)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
120 self.networkCombo.setCurrentIndex(row)
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
121 self.nickCombo.setEditText(currentNick)
2279
cbf90feec16f Fixed a non-fatal issue in the IRC widget related to changing an identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
122 self.nickCombo.blockSignals(blocked)
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
123 self.channelCombo.setEditText(currentChannel)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @pyqtSlot()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 def on_connectButton_clicked(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 Private slot to connect to a network.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 network = self.networkCombo.currentText()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.connectNetwork.emit(network, not self.__connected)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 @pyqtSlot()
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
134 def on_awayButton_clicked(self):
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
135 """
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
136 Private slot to toggle the away status.
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
137 """
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
138 if self.__away:
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
139 self.sendData.emit("AWAY")
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
140 self.awayButton.setIcon(
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
141 UI.PixmapCache.getIcon("ircUserPresent.png"))
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
142 self.__away = False
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
143 else:
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
144 networkName = self.networkCombo.currentText()
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
145 identityName = self.__manager.getNetwork(networkName)\
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
146 .getIdentityName()
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
147 awayMessage = self.__manager.getIdentity(identityName)\
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
148 .getAwayMessage()
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
149 self.sendData.emit("AWAY :" + awayMessage)
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
150 self.awayButton.setIcon(UI.PixmapCache.getIcon("ircUserAway.png"))
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
151 self.__away = True
2246
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
152 self.away.emit(self.__away)
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
153
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
154 @pyqtSlot()
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 def on_editButton_clicked(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 Private slot to edit a network.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 network = self.networkCombo.currentText()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.editNetwork.emit(network)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @pyqtSlot(str)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def on_channelCombo_editTextChanged(self, txt):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 Private slot to react upon changes of the channel.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @param txt current text of the channel combo (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 """
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
169 on = bool(txt) and self.__registered
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.joinButton.setEnabled(on)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 @pyqtSlot()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 def on_joinButton_clicked(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 Private slot to join a channel.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 channel = self.channelCombo.currentText()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.joinChannel.emit(channel)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @pyqtSlot(str)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 def on_networkCombo_currentIndexChanged(self, networkName):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 Private slot to handle selections of a network.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @param networkName selected network name (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 network = self.__manager.getNetwork(networkName)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
188 self.nickCombo.clear()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
189 self.channelCombo.clear()
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 if network:
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
191 channels = network.getChannelNames()
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self.channelCombo.addItems(channels)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.channelCombo.setEnabled(True)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 identity = self.__manager.getIdentity(
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 network.getIdentityName())
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 if identity:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.nickCombo.addItems(identity.getNickNames())
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.channelCombo.setEnabled(False)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
201 def getNetworkChannels(self):
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
202 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
203 Public method to get the list of channels associated with the
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
204 selected network.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
205
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
206 @return associated channels (list of IrcChannel)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
207 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
208 networkName = self.networkCombo.currentText()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
209 network = self.__manager.getNetwork(networkName)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
210 return network.getChannels()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
211
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 @pyqtSlot(str)
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
213 def on_nickCombo_currentIndexChanged(self, nick=""):
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 Private slot to use another nick name.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 @param nick nick name to use (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 if self.__connected:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.nickChanged.emit(self.nickCombo.currentText())
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 def getNickname(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 Public method to get the currently selected nick name.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 @return selected nick name (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 return self.nickCombo.currentText()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 def setNickName(self, nick):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 Public slot to set the nick name in use.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 @param nick nick name in use (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.nickCombo.blockSignals(True)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.nickCombo.setEditText(nick)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 self.nickCombo.blockSignals(False)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 def addMessage(self, msg):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 Public method to add a message.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 @param msg message to be added (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 s = '<font color="{0}">{1} {2}</font>'.format(
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 Preferences.getIrc("NetworkMessageColour"),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 ircTimestamp(),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 msg
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 )
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 self.messages.append(s)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 def addServerMessage(self, msgType, msg, filterMsg=True):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 Public method to add a server message.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 @param msgType txpe of the message (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 @param msg message to be added (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 @keyparam filterMsg flag indicating to filter the message (boolean)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 if filterMsg:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 msg = ircFilter(msg)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 s = '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format(
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 Preferences.getIrc("ServerMessageColour"),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 ircTimestamp(),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 msgType,
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 msg
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 )
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.messages.append(s)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 def addErrorMessage(self, msgType, msg):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 Public method to add an error message.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 @param msgType txpe of the message (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 @param msg message to be added (string)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 s = '<font color="{0}">{1} <b>[</b>{2}<b>]</b> {3}</font>'.format(
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 Preferences.getIrc("ErrorMessageColour"),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 ircTimestamp(),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 msgType,
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 msg
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 )
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 self.messages.append(s)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 def setConnected(self, connected):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 Public slot to set the connection state.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 @param connected flag indicating the connection state (boolean)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.__connected = connected
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 if self.__connected:
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
294 self.connectButton.setIcon(
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
295 UI.PixmapCache.getIcon("ircDisconnect.png"))
2758
eacdcc89b74d Fixed a little (cosmetic) issue in the IRC network widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
296 self.connectButton.setToolTip(
eacdcc89b74d Fixed a little (cosmetic) issue in the IRC network widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
297 self.trUtf8("Press to disconnect from the network"))
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 else:
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
299 self.connectButton.setIcon(
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
300 UI.PixmapCache.getIcon("ircConnect.png"))
2758
eacdcc89b74d Fixed a little (cosmetic) issue in the IRC network widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
301 self.connectButton.setToolTip(
eacdcc89b74d Fixed a little (cosmetic) issue in the IRC network widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
302 self.trUtf8("Press to connect to the selected network"))
2528
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
303
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
304 def isConnected(self):
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
305 """
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
306 Public method to check, if the network is connected.
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
307
2528
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
308 @return flag indicating a connected network (boolean)
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
309 """
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
310 return self.__connected
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2446
diff changeset
311
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
312 def setRegistered(self, registered):
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
313 """
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
314 Public slot to set the registered state.
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
315
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
316 @param registered flag indicating the registration state (boolean)
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
317 """
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
318 self.__registered = registered
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
319 on = bool(self.channelCombo.currentText()) and self.__registered
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
320 self.joinButton.setEnabled(on)
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2242
diff changeset
321 self.nickCombo.setEnabled(registered)
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
322 self.awayButton.setEnabled(registered)
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
323 if registered:
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
324 self.awayButton.setIcon(
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
325 UI.PixmapCache.getIcon("ircUserPresent.png"))
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
326 self.__away = False
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
327
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
328 def __clearMessages(self):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
329 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
330 Private slot to clear the contents of the messages display.
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
331 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
332 self.messages.clear()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
333
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
334 def __copyMessages(self):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
335 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
336 Private slot to copy the selection of the messages display to
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
337 the clipboard.
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
338 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
339 self.messages.copy()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
340
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
341 def __copyAllMessages(self):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
342 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
343 Private slot to copy the contents of the messages display to
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
344 the clipboard.
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
345 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
346 txt = self.messages.toPlainText()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
347 if txt:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
348 cb = QApplication.clipboard()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
349 cb.setText(txt)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
350
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
351 def __cutAllMessages(self):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
352 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
353 Private slot to cut the contents of the messages display to
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
354 the clipboard.
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
355 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
356 txt = self.messages.toPlainText()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
357 if txt:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
358 cb = QApplication.clipboard()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
359 cb.setText(txt)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
360 self.messages.clear()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
361
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
362 def __saveMessages(self):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
363 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
364 Private slot to save the contents of the messages display.
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
365 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
366 hasText = not self.messages.document().isEmpty()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
367 if hasText:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
368 if Utilities.isWindowsPlatform():
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
369 htmlExtension = "htm"
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
370 else:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
371 htmlExtension = "html"
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
372 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
373 self,
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
374 self.trUtf8("Save Messages"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
375 "",
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
376 self.trUtf8(
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
377 "HTML Files (*.{0});;Text Files (*.txt);;All Files (*)")
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
378 .format(htmlExtension),
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
379 None,
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
380 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
381 if fname:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
382 ext = QFileInfo(fname).suffix()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
383 if not ext:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
384 ex = selectedFilter.split("(*")[1].split(")")[0]
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
385 if ex:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
386 fname += ex
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
387 ext = QFileInfo(fname).suffix()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
388 if QFileInfo(fname).exists():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
389 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
390 self,
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
391 self.trUtf8("Save Messages"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
392 self.trUtf8("<p>The file <b>{0}</b> already exists."
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
393 " Overwrite it?</p>").format(fname),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
394 icon=E5MessageBox.Warning)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
395 if not res:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
396 return
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
397 fname = Utilities.toNativeSeparators(fname)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
398
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
399 try:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
400 if ext.lower() in ["htm", "html"]:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
401 txt = self.messages.toHtml()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
402 else:
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
403 txt = self.messages.toPlainText()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
404 f = open(fname, "w", encoding="utf-8")
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
405 f.write(txt)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
406 f.close()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
407 except IOError as err:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
408 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
409 self,
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
410 self.trUtf8("Error saving Messages"),
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
411 self.trUtf8(
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
412 """<p>The messages contents could not be written"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
413 """ to <b>{0}</b></p><p>Reason: {1}</p>""")
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
414 .format(fname, str(err)))
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
415
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
416 def __initMessagesMenu(self):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
417 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
418 Private slot to initialize the context menu of the messages pane.
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
419 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
420 self.__messagesMenu = QMenu(self)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
421 self.__copyMessagesAct = \
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
422 self.__messagesMenu.addAction(
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
423 UI.PixmapCache.getIcon("editCopy.png"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
424 self.trUtf8("Copy"), self.__copyMessages)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
425 self.__messagesMenu.addSeparator()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
426 self.__cutAllMessagesAct = \
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
427 self.__messagesMenu.addAction(
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
428 UI.PixmapCache.getIcon("editCut.png"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
429 self.trUtf8("Cut all"), self.__cutAllMessages)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
430 self.__copyAllMessagesAct = \
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
431 self.__messagesMenu.addAction(
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
432 UI.PixmapCache.getIcon("editCopy.png"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
433 self.trUtf8("Copy all"), self.__copyAllMessages)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
434 self.__messagesMenu.addSeparator()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
435 self.__clearMessagesAct = \
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
436 self.__messagesMenu.addAction(
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
437 UI.PixmapCache.getIcon("editDelete.png"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
438 self.trUtf8("Clear"), self.__clearMessages)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
439 self.__messagesMenu.addSeparator()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
440 self.__saveMessagesAct = \
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
441 self.__messagesMenu.addAction(
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
442 UI.PixmapCache.getIcon("fileSave.png"),
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
443 self.trUtf8("Save"), self.__saveMessages)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
444
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
445 self.on_messages_copyAvailable(False)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
446
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
447 @pyqtSlot(bool)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
448 def on_messages_copyAvailable(self, yes):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
449 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
450 Private slot to react to text selection/deselection of the
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
451 messages edit.
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
452
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
453 @param yes flag signaling the availability of selected text (boolean)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
454 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
455 self.__copyMessagesAct.setEnabled(yes)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
456
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
457 @pyqtSlot(QPoint)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
458 def on_messages_customContextMenuRequested(self, pos):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
459 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
460 Private slot to show the context menu of the messages pane.
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
461
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
462 @param pos position the menu should be opened at (QPoint)
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
463 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
464 enable = not self.messages.document().isEmpty()
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
465 self.__cutAllMessagesAct.setEnabled(enable)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
466 self.__copyAllMessagesAct.setEnabled(enable)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
467 self.__saveMessagesAct.setEnabled(enable)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
468 self.__messagesMenu.popup(self.messages.mapToGlobal(pos))
2442
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
469
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
470 @pyqtSlot(QUrl)
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
471 def on_messages_anchorClicked(self, url):
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
472 """
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
473 Private slot to open links in the default browser.
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
474
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2758
diff changeset
475 @param url URL to be opened (QUrl)
2442
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
476 """
1dcfd570fa12 Fixed an issue in the IRC widget opening hyperlinks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
477 QDesktopServices.openUrl(url)

eric ide

mercurial