Helpviewer/UrlBar/SslLabel.py

Sun, 29 Jun 2014 20:13:56 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 29 Jun 2014 20:13:56 +0200
changeset 3656
441956d8fce5
parent 3178
f25fc1364c88
child 4021
195a471c327b
permissions
-rw-r--r--

Started porting eric5 to PyQt5.

658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
3 # Copyright (c) 2010 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the label to show some SSL info.
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
12 from PyQt5.QtCore import Qt, pyqtSignal, QPoint
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
13 from PyQt5.QtWidgets import QLabel
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
15
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 class SslLabel(QLabel):
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 Class implementing the label to show some SSL info.
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
20 clicked = pyqtSignal(QPoint)
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
1341
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
22 okStyle = "QLabel { color : white; background-color : green; }"
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
23 nokStyle = "QLabel { color : white; background-color : red; }"
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
24
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25 def __init__(self, parent=None):
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param parent reference to the parent widget (QWidget)
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
31 super(SslLabel, self).__init__(parent)
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setFocusPolicy(Qt.NoFocus)
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.setCursor(Qt.ArrowCursor)
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def mouseReleaseEvent(self, evt):
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Protected method to handle mouse release events.
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @param evt reference to the mouse event (QMouseEvent)
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 if evt.button() == Qt.LeftButton:
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
43 self.clicked.emit(evt.globalPos())
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 else:
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
45 super(SslLabel, self).mouseReleaseEvent(evt)
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def mouseDoubleClickEvent(self, evt):
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Protected method to handle mouse double click events.
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param evt reference to the mouse event (QMouseEvent)
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 if evt.button() == Qt.LeftButton:
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
54 self.clicked.emit(evt.globalPos())
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 else:
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
56 super(SslLabel, self).mouseDoubleClickEvent(evt)
1341
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
57
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
58 def setValidity(self, valid):
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
59 """
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
60 Public method to set the validity indication.
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
61
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
62 @param valid flag indicating the certificate validity (boolean)
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
63 """
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
64 if valid:
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
65 self.setStyleSheet(SslLabel.okStyle)
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
66 else:
6104ae9ceb55 Added code to indicate invalid SSL certificates in the URL entry and the SSL info dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
67 self.setStyleSheet(SslLabel.nokStyle)

eric ide

mercurial