eric6/Helpviewer/UrlBar/SslLabel.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the label to show some SSL info.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import Qt, pyqtSignal, QPoint
13 from PyQt5.QtWidgets import QLabel
14
15
16 class SslLabel(QLabel):
17 """
18 Class implementing the label to show some SSL info.
19
20 @signal clicked(pos) emitted to indicate a click of the label (QPoint)
21 """
22 clicked = pyqtSignal(QPoint)
23
24 okStyle = "QLabel { color : white; background-color : green; }"
25 nokStyle = "QLabel { color : white; background-color : red; }"
26
27 def __init__(self, parent=None):
28 """
29 Constructor
30
31 @param parent reference to the parent widget (QWidget)
32 """
33 super(SslLabel, self).__init__(parent)
34
35 self.setFocusPolicy(Qt.NoFocus)
36 self.setCursor(Qt.ArrowCursor)
37
38 def mouseReleaseEvent(self, evt):
39 """
40 Protected method to handle mouse release events.
41
42 @param evt reference to the mouse event (QMouseEvent)
43 """
44 if evt.button() == Qt.LeftButton:
45 self.clicked.emit(evt.globalPos())
46 else:
47 super(SslLabel, self).mouseReleaseEvent(evt)
48
49 def mouseDoubleClickEvent(self, evt):
50 """
51 Protected method to handle mouse double click events.
52
53 @param evt reference to the mouse event (QMouseEvent)
54 """
55 if evt.button() == Qt.LeftButton:
56 self.clicked.emit(evt.globalPos())
57 else:
58 super(SslLabel, self).mouseDoubleClickEvent(evt)
59
60 def setValidity(self, valid):
61 """
62 Public method to set the validity indication.
63
64 @param valid flag indicating the certificate validity (boolean)
65 """
66 if valid:
67 self.setStyleSheet(SslLabel.okStyle)
68 else:
69 self.setStyleSheet(SslLabel.nokStyle)

eric ide

mercurial