WebBrowser/Network/SslErrorExceptionsDialog.py

Sun, 03 Feb 2019 16:10:39 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 03 Feb 2019 16:10:39 +0100
changeset 6695
0a51887c13cd
parent 6645
ad476851d7e0
permissions
-rw-r--r--

Web Browser (NG):
- added a site info widget that is show when the site icon in the URL entry is clicked
- added code to register custom protocol handlers (upon request of the user via the site info widget)

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

eric ide

mercurial