Mon, 22 Apr 2024 18:23:20 +0200
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10428
diff
changeset
|
3 | # Copyright (c) 2012 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog for editing the IRC server configuration. |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtCore import pyqtSlot |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | from .Ui_IrcServerEditDialog import Ui_IrcServerEditDialog |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | class IrcServerEditDialog(QDialog, Ui_IrcServerEditDialog): |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | Class implementing a dialog for editing the IRC server configuration. |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | def __init__(self, server, parent=None): |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
25 | @param server reference to the IRC server object |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
26 | @type IrcServer |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
27 | @param parent reference to the parent widget |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
28 | @type QWidget |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
30 | super().__init__(parent) |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
32 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
33 | self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2238
diff
changeset
|
35 | if server: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2238
diff
changeset
|
36 | self.serverEdit.setText(server.getName()) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2238
diff
changeset
|
37 | self.portSpinBox.setValue(server.getPort()) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2238
diff
changeset
|
38 | self.passwordEdit.setText(server.getPassword()) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2238
diff
changeset
|
39 | self.sslCheckBox.setChecked(server.useSSL()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.__updateOkButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
3366
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
43 | msh = self.minimumSizeHint() |
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
44 | self.resize(max(self.width(), msh.width()), msh.height()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | def __updateOkButton(self): |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | Private method to update the OK button state. |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | self.__okButton.setEnabled(self.serverEdit.text() != "") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @pyqtSlot(str) |
10690
fab36645aa7d
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
53 | def on_serverEdit_textChanged(self, _name): |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | Private slot handling changes of the server name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | |
10690
fab36645aa7d
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
57 | @param _name current name of the server (unused) |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
58 | @type str |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | self.__updateOkButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | def getServer(self): |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | """ |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | Public method to create a server object from the data entered into |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | the dialog. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
67 | @return server object |
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
68 | @rtype IrcServer |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
2404
cba0ff902c2b
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
70 | from .IrcNetworkManager import IrcServer |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | server = IrcServer(self.serverEdit.text()) |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | server.setPort(self.portSpinBox.value()) |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | server.setPassword(self.passwordEdit.text()) |
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | server.setUseSSL(self.sslCheckBox.isChecked()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | |
2238
9977d3081ab6
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | return server |