eric6/Network/IRC/IrcNetworkEditDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog for editing IRC network definitions.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
10 import copy
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtCore import pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
15 from E5Gui import E5MessageBox
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
16
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import UI.PixmapCache
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 class IrcNetworkEditDialog(QDialog, Ui_IrcNetworkEditDialog):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing a dialog for editing IRC network definitions.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 def __init__(self, manager, networkName, parent=None):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Constructor
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
30 @param manager reference to the IRC network manager object
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
31 (IrcNetworkManager)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param networkName name of the network to work on (string)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget (QWidget)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
35 super(IrcNetworkEditDialog, self).__init__(parent)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__manager = manager
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
40 self.editIdentitiesButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
41 UI.PixmapCache.getIcon("ircConfigure"))
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
42 self.editServerButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
43 UI.PixmapCache.getIcon("ircConfigure"))
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
44 self.editChannelButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
45 UI.PixmapCache.getIcon("ircConfigure"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
46 self.addChannelButton.setIcon(UI.PixmapCache.getIcon("plus"))
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
47 self.deleteChannelButton.setIcon(UI.PixmapCache.getIcon("minus"))
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
51 if networkName:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
52 self.__network = copy.deepcopy(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
53 self.__manager.getNetwork(networkName))
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
54 else:
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
55 from .IrcNetworkManager import IrcNetwork
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
56 self.__network = IrcNetwork("")
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
57
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
58 # network name
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.networkEdit.setText(networkName)
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
60
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
61 # identities
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
62 self.__refreshIdentityCombo(self.__network.getIdentityName())
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
63
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
64 # server
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
65 self.serverEdit.setText(self.__network.getServerName())
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
66
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
67 # channels
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
68 for channelName in sorted(self.__network.getChannelNames()):
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
69 channel = self.__network.getChannel(channelName)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
70 if channel.autoJoin():
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
71 autoJoin = self.tr("Yes")
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
72 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
73 autoJoin = self.tr("No")
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
74 QTreeWidgetItem(self.channelList, [channelName, autoJoin])
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__updateOkButton()
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
77 self.on_channelList_itemSelectionChanged()
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 def __updateOkButton(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 Private method to update the OK button state.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 enable = True
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 enable &= self.networkEdit.text() != ""
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
85 enable &= self.serverEdit.text() != ""
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__okButton.setEnabled(enable)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @pyqtSlot(str)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 def on_networkEdit_textChanged(self, txt):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Private slot to handle changes of the network name.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 @param txt text entered into the network name edit (string)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__updateOkButton()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
98 def __refreshIdentityCombo(self, currentIdentity):
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
99 """
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
100 Private method to refresh the identity combo.
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
101
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
102 @param currentIdentity name of the identity to select (string)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
103 """
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
104 self.identityCombo.clear()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
105
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
106 from .IrcNetworkManager import IrcIdentity
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
107 identities = list(sorted(self.__manager.getIdentityNames()))
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
108 identities[identities.index(IrcIdentity.DefaultIdentityName)] = (
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
109 IrcIdentity.DefaultIdentityDisplay
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
110 )
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
111 self.identityCombo.addItems(identities)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
112 if currentIdentity == IrcIdentity.DefaultIdentityName:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
113 currentIdentity = IrcIdentity.DefaultIdentityDisplay
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
114 index = self.identityCombo.findText(currentIdentity)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
115 if index == -1:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
116 index = 0
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
117 self.identityCombo.setCurrentIndex(index)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
118
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
119 @pyqtSlot(str)
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
120 def on_identityCombo_currentIndexChanged(self, identity):
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
121 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
122 Private slot to handle the selection of an identity.
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
123
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
124 @param identity selected entity (string)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
125 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
126 from .IrcNetworkManager import IrcIdentity
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
127 if identity == IrcIdentity.DefaultIdentityDisplay:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
128 identity = IrcIdentity.DefaultIdentityName
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
129 self.__network.setIdentityName(identity)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
130
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 def on_editIdentitiesButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
134 Private slot to edit the identities.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
136 from .IrcIdentitiesEditDialog import IrcIdentitiesEditDialog
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
137 currentIdentity = self.identityCombo.currentText()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
138 dlg = IrcIdentitiesEditDialog(self.__manager, currentIdentity, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
139 dlg.exec()
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
140 self.__refreshIdentityCombo(currentIdentity)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
142 @pyqtSlot(str)
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
143 def on_serverEdit_textChanged(self, txt):
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
144 """
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
145 Private slot to handle changes of the server name.
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
146
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
147 @param txt text entered into the server name edit (string)
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
148 """
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
149 self.__updateOkButton()
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
150
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 @pyqtSlot()
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
152 def on_editServerButton_clicked(self):
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
153 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
154 Private slot to edit the server configuration.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
156 from .IrcServerEditDialog import IrcServerEditDialog
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
157 dlg = IrcServerEditDialog(self.__network.getServer())
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
158 if dlg.exec() == QDialog.Accepted:
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
159 self.__network.setServer(dlg.getServer())
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
160 self.serverEdit.setText(self.__network.getServerName())
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def on_addChannelButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
165 Private slot to add a channel.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
167 self.__editChannel(None)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def on_editChannelButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
172 Private slot to edit the selected channel.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
174 itm = self.channelList.selectedItems()[0]
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
175 if itm:
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
176 self.__editChannel(itm)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 def on_deleteChannelButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
181 Private slot to delete the selected channel.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
183 itm = self.channelList.selectedItems()[0]
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
184 if itm:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
185 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
186 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
187 self.tr("Delete Channel"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
188 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
189 """Do you really want to delete channel <b>{0}</b>?""")
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
190 .format(itm.text(0)))
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
191 if res:
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
192 self.__network.deleteChannel(itm.text(0))
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
193
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
194 index = self.channelList.indexOfTopLevelItem(itm)
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
195 self.channelList.takeTopLevelItem(index)
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
196 del itm
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @pyqtSlot(QTreeWidgetItem, int)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 def on_channelList_itemActivated(self, item, column):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
201 Private slot to handle the activation of a channel entry.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
202
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
203 @param item reference to the activated item (QTreeWidgetItem)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
204 @param column column the activation occurred in (integer)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
206 self.__editChannel(item)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 def on_channelList_itemSelectionChanged(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
211 Private slot to handle changes of the selection of channels.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
212 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
213 selectedItems = self.channelList.selectedItems()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
214 if len(selectedItems) == 0:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
215 enable = False
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
216 else:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
217 enable = True
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
218 self.editChannelButton.setEnabled(enable)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
219 self.deleteChannelButton.setEnabled(enable)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
220
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
221 def __editChannel(self, itm):
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
222 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
223 Private method to edit a channel.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
224
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
225 @param itm reference to the item to be edited (QTreeWidgetItem)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 """
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
227 if itm:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
228 channel = self.__network.getChannel(itm.text(0))
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
229 name = channel.getName()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
230 key = channel.getKey()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
231 autoJoin = channel.autoJoin()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
232 else:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
233 # add a new channel
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
234 name = ""
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
235 key = ""
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
236 autoJoin = False
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
237
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
238 from .IrcChannelEditDialog import IrcChannelEditDialog
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
239 dlg = IrcChannelEditDialog(name, key, autoJoin, itm is not None, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
240 if dlg.exec() == QDialog.Accepted:
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
241 from .IrcNetworkManager import IrcChannel
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
242 name, key, autoJoin = dlg.getData()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
243 channel = IrcChannel(name)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
244 channel.setKey(key)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
245 channel.setAutoJoin(autoJoin)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
246 if itm:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
247 if autoJoin:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
248 itm.setText(1, self.tr("Yes"))
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
249 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
250 itm.setText(1, self.tr("No"))
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
251 self.__network.setChannel(channel)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
252 else:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
253 if autoJoin:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
254 autoJoinTxt = self.tr("Yes")
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
255 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
256 autoJoinTxt = self.tr("No")
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
257 QTreeWidgetItem(self.channelList, [name, autoJoinTxt])
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
258 self.__network.addChannel(channel)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
259
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
260 def getNetwork(self):
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
261 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
262 Public method to get the network object.
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
263
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
264 @return edited network object (IrcNetwork)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
265 """
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
266 self.__network.setName(self.networkEdit.text())
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
267 return self.__network

eric ide

mercurial