eric6/WebBrowser/Network/SslErrorExceptionsDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2016 - 2021 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
4820
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt, QPoint
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QMenu
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtWebEngineWidgets import QWebEngineCertificateError
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 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 def __init__(self, errorsDict, parent=None):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @param errorsDict error exceptions
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @type dict of list of int
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param parent reference to the parent widget
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @type QWidget
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 super(SslErrorExceptionsDialog, self).__init__(parent)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.setupUi(self)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.__errorDescriptions = {
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 QWebEngineCertificateError.SslPinnedKeyNotInCertificateChain:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.tr("The certificate did not match the built-in public"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 " keys pinned for the host name."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 QWebEngineCertificateError.CertificateCommonNameInvalid:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.tr("The certificate's common name did not match the"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 " host name."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 QWebEngineCertificateError.CertificateDateInvalid:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.tr("The certificate is not valid at the current date"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 " and time."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 QWebEngineCertificateError.CertificateAuthorityInvalid:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.tr("The certificate is not signed by a trusted"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 " authority."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 QWebEngineCertificateError.CertificateContainsErrors:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.tr("The certificate contains errors."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 QWebEngineCertificateError.CertificateNoRevocationMechanism:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.tr("The certificate has no mechanism for determining if"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 " it has been revoked."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 QWebEngineCertificateError.CertificateUnableToCheckRevocation:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.tr("Revocation information for the certificate is"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 " not available."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 QWebEngineCertificateError.CertificateRevoked:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.tr("The certificate has been revoked."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 QWebEngineCertificateError.CertificateInvalid:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.tr("The certificate is invalid."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 QWebEngineCertificateError.CertificateWeakSignatureAlgorithm:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.tr("The certificate is signed using a weak signature"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 " algorithm."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 QWebEngineCertificateError.CertificateNonUniqueName:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.tr("The host name specified in the certificate is"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 " not unique."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 QWebEngineCertificateError.CertificateWeakKey:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.tr("The certificate contains a weak key."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 QWebEngineCertificateError.CertificateNameConstraintViolation:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.tr("The certificate claimed DNS names that are in"
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 " violation of name constraints."),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 }
5201
21601e86a3f5 Added a message to the SSL error dialog that was introduced with Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
70 try:
21601e86a3f5 Added a message to the SSL error dialog that was introduced with Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
71 self.__errorDescriptions[
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
72 QWebEngineCertificateError.CertificateValidityTooLong
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
73 ] = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
74 "The certificate has a validity period that is too long."
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
75 )
5201
21601e86a3f5 Added a message to the SSL error dialog that was introduced with Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
76 except AttributeError:
21601e86a3f5 Added a message to the SSL error dialog that was introduced with Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
77 # the value was added in Qt 5.7
21601e86a3f5 Added a message to the SSL error dialog that was introduced with Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4820
diff changeset
78 pass
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
79 try:
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
80 self.__errorDescriptions[
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
81 QWebEngineCertificateError.CertificateTransparencyRequired
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
82 ] = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
83 "Certificate Transparency was required for this"
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
84 " connection, but the server did not provide"
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
85 " information that complied with the policy."
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
86 )
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
87 except AttributeError:
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
88 # the value was added in Qt 5.8
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
89 pass
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 for host, errors in errorsDict.items():
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 itm = QTreeWidgetItem(self.errorsTree, [host])
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.errorsTree.setFirstItemColumnSpanned(itm, True)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 for error in errors:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 try:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 errorDesc = self.__errorDescriptions[error]
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 except KeyError:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 errorDesc = self.tr("No error description available.")
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 QTreeWidgetItem(itm, [str(error), errorDesc])
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.errorsTree.expandAll()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 for i in range(self.errorsTree.columnCount()):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 self.errorsTree.resizeColumnToContents(i)
4820
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
104 self.errorsTree.sortItems(0, Qt.AscendingOrder)
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__setRemoveButtons()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 def __setRemoveButtons(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 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
111 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 if self.errorsTree.topLevelItemCount() == 0:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.removeButton.setEnabled(False)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.removeAllButton.setEnabled(False)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 else:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.removeAllButton.setEnabled(True)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.removeButton.setEnabled(
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 len(self.errorsTree.selectedItems()) > 0)
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 @pyqtSlot(QPoint)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 def on_errorsTree_customContextMenuRequested(self, pos):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 Private slot to show the context menu.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @param pos cursor position
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 @type QPoint
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 menu = QMenu()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 menu.addAction(
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.tr("Remove Selected"),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.on_removeButton_clicked).setEnabled(
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.errorsTree.topLevelItemCount() > 0 and
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 len(self.errorsTree.selectedItems()) > 0)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 menu.addAction(
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.tr("Remove All"),
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.on_removeAllButton_clicked).setEnabled(
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 self.errorsTree.topLevelItemCount() > 0)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
139 menu.exec(self.errorsTree.mapToGlobal(pos))
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 @pyqtSlot()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def on_errorsTree_itemSelectionChanged(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Private slot handling the selection of entries.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.__setRemoveButtons()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
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_removeButton_clicked(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 to remove the selected items.
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 for itm in self.errorsTree.selectedItems():
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 pitm = itm.parent()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 if pitm:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 pitm.removeChild(itm)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 else:
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 index = self.errorsTree.indexOfTopLevelItem(itm)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.errorsTree.takeTopLevelItem(index)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 del itm
4820
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
161
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
162 # remove all hosts without an exception
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
163 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
164 itm = self.errorsTree.topLevelItem(index)
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
165 if itm.childCount() == 0:
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
166 self.errorsTree.takeTopLevelItem(index)
f38e4fb83ecd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4817
diff changeset
167 del itm
4817
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 @pyqtSlot()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def on_removeAllButton_clicked(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 Private slot to remove all entries.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 self.errorsTree.clear()
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 def getSslErrorExceptions(self):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 Public method to retrieve the list of SSL error exceptions.
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @return error exceptions
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 @rtype dict of list of int
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 errors = {}
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 for index in range(self.errorsTree.topLevelItemCount()):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 itm = self.errorsTree.topLevelItem(index)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 host = itm.text(0)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 errors[host] = []
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 for cindex in range(itm.childCount()):
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 citm = itm.child(cindex)
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 errors[host].append(int(citm.text(0)))
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
0a4e2fb0e93c Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 return errors

eric ide

mercurial