Mon, 07 Nov 2022 17:19:58 +0100
Corrected/acknowledged some bad import style and removed some obsolete code.
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8561
diff
changeset
|
3 | # Copyright (c) 2016 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to edit the SSL error exceptions. |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
10 | from PyQt6.QtCore import QPoint, Qt, pyqtSlot |
8553
10d31e5ce9e5
First batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
11 | from PyQt6.QtWebEngineCore import QWebEngineCertificateError |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
12 | from PyQt6.QtWidgets import QDialog, QMenu, QTreeWidgetItem |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from .Ui_SslErrorExceptionsDialog import Ui_SslErrorExceptionsDialog |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | class SslErrorExceptionsDialog(QDialog, Ui_SslErrorExceptionsDialog): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | Class implementing a dialog to edit the SSL error exceptions. |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
21 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | def __init__(self, errorsDict, parent=None): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
25 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | @param errorsDict error exceptions |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | @type dict of list of int |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | @param parent reference to the parent widget |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | @type QWidget |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
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
|
31 | super().__init__(parent) |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
33 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.__errorDescriptions = { |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | QWebEngineCertificateError.Type.SslPinnedKeyNotInCertificateChain: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | "The certificate did not match the built-in public" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | " keys pinned for the host name." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | QWebEngineCertificateError.Type.CertificateCommonNameInvalid: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | "The certificate's common name did not match the" " host name." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | QWebEngineCertificateError.Type.CertificateDateInvalid: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | "The certificate is not valid at the current date" " and time." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | QWebEngineCertificateError.Type.CertificateAuthorityInvalid: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | "The certificate is not signed by a trusted" " authority." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | QWebEngineCertificateError.Type.CertificateContainsErrors: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | "The certificate contains errors." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | QWebEngineCertificateError.Type.CertificateNoRevocationMechanism: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | "The certificate has no mechanism for determining if" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | " it has been revoked." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | QWebEngineCertificateError.Type.CertificateUnableToCheckRevocation: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | "Revocation information for the certificate is" " not available." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | QWebEngineCertificateError.Type.CertificateRevoked: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | "The certificate has been revoked." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | QWebEngineCertificateError.Type.CertificateInvalid: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | "The certificate is invalid." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
63 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | QWebEngineCertificateError.Type.CertificateWeakSignatureAlgorithm: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | "The certificate is signed using a weak signature" " algorithm." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | QWebEngineCertificateError.Type.CertificateNonUniqueName: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | "The host name specified in the certificate is" " not unique." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
69 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
70 | QWebEngineCertificateError.Type.CertificateWeakKey: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | "The certificate contains a weak key." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
73 | QWebEngineCertificateError.Type.CertificateNameConstraintViolation: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
74 | "The certificate claimed DNS names that are in" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | " violation of name constraints." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | QWebEngineCertificateError.Type.CertificateValidityTooLong: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
78 | "The certificate has a validity period that is" " too long." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
79 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
80 | QWebEngineCertificateError.Type.CertificateTransparencyRequired: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | "Certificate Transparency was required for this" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
82 | " connection, but the server did not provide" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
83 | " information that complied with the policy." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
85 | QWebEngineCertificateError.Type.CertificateKnownInterceptionBlocked: ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
86 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
87 | "The certificate is known to be used for interception" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
88 | " by an entity other than the device owner." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
89 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
91 | QWebEngineCertificateError.Type.SslObsoleteVersion: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
92 | "The connection uses an obsolete version of SSL/TLS." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
93 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | QWebEngineCertificateError.Type.CertificateSymantecLegacy: self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | "The certificate is a legacy Symantec one that's no" " longer valid." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
96 | ), |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | for host, errors in errorsDict.items(): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | itm = QTreeWidgetItem(self.errorsTree, [host]) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | self.errorsTree.setFirstItemColumnSpanned(itm, True) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | for error in errors: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | try: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | errorDesc = self.__errorDescriptions[error] |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | except KeyError: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | errorDesc = self.tr("No error description available.") |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | QTreeWidgetItem(itm, [str(error), errorDesc]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
108 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | self.errorsTree.expandAll() |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | for i in range(self.errorsTree.columnCount()): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | self.errorsTree.resizeColumnToContents(i) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
112 | self.errorsTree.sortItems(0, Qt.SortOrder.AscendingOrder) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
113 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | self.__setRemoveButtons() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
115 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | def __setRemoveButtons(self): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | Private method to set the state of the 'remove' buttons. |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | if self.errorsTree.topLevelItemCount() == 0: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | self.removeButton.setEnabled(False) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | self.removeAllButton.setEnabled(False) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | else: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | self.removeAllButton.setEnabled(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
125 | self.removeButton.setEnabled(len(self.errorsTree.selectedItems()) > 0) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
126 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | @pyqtSlot(QPoint) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | def on_errorsTree_customContextMenuRequested(self, pos): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | Private slot to show the context menu. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
131 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | @param pos cursor position |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @type QPoint |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | menu = QMenu() |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | menu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
137 | self.tr("Remove Selected"), self.on_removeButton_clicked |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
138 | ).setEnabled( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | self.errorsTree.topLevelItemCount() > 0 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | and len(self.errorsTree.selectedItems()) > 0 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
141 | ) |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | menu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
143 | self.tr("Remove All"), self.on_removeAllButton_clicked |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
144 | ).setEnabled(self.errorsTree.topLevelItemCount() > 0) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
145 | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
146 | menu.exec(self.errorsTree.mapToGlobal(pos)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
147 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | @pyqtSlot() |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | def on_errorsTree_itemSelectionChanged(self): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | Private slot handling the selection of entries. |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | self.__setRemoveButtons() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
154 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | @pyqtSlot() |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | def on_removeButton_clicked(self): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | Private slot to remove the selected items. |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | for itm in self.errorsTree.selectedItems(): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | pitm = itm.parent() |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | if pitm: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | pitm.removeChild(itm) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | else: |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | index = self.errorsTree.indexOfTopLevelItem(itm) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | self.errorsTree.takeTopLevelItem(index) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | del itm |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
168 | |
4820
f38e4fb83ecd
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4817
diff
changeset
|
169 | # remove all hosts without an exception |
f38e4fb83ecd
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4817
diff
changeset
|
170 | for index in range(self.errorsTree.topLevelItemCount() - 1, -1, -1): |
f38e4fb83ecd
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4817
diff
changeset
|
171 | itm = self.errorsTree.topLevelItem(index) |
f38e4fb83ecd
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4817
diff
changeset
|
172 | if itm.childCount() == 0: |
f38e4fb83ecd
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4817
diff
changeset
|
173 | self.errorsTree.takeTopLevelItem(index) |
f38e4fb83ecd
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4817
diff
changeset
|
174 | del itm |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
175 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | @pyqtSlot() |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | def on_removeAllButton_clicked(self): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | Private slot to remove all entries. |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | self.errorsTree.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
182 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | def getSslErrorExceptions(self): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | Public method to retrieve the list of SSL error exceptions. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
186 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | @return error exceptions |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | @rtype dict of list of int |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | """ |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | errors = {} |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
191 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | for index in range(self.errorsTree.topLevelItemCount()): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | itm = self.errorsTree.topLevelItem(index) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | host = itm.text(0) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | errors[host] = [] |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | for cindex in range(itm.childCount()): |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | citm = itm.child(cindex) |
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | errors[host].append(int(citm.text(0))) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
199 | |
4817
0a4e2fb0e93c
Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | return errors |