src/eric7/WebBrowser/SafeBrowsing/SafeBrowsingLabel.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
12 12
13 13
14 class SafeBrowsingLabel(QLabel): 14 class SafeBrowsingLabel(QLabel):
15 """ 15 """
16 Class implementing a label to show some Safe Browsing info. 16 Class implementing a label to show some Safe Browsing info.
17 17
18 @signal clicked(pos) emitted to indicate a click of the label (QPoint) 18 @signal clicked(pos) emitted to indicate a click of the label (QPoint)
19 """ 19 """
20
20 clicked = pyqtSignal(QPoint) 21 clicked = pyqtSignal(QPoint)
21 22
22 nokStyle = "QLabel { color : white; background-color : red; }" 23 nokStyle = "QLabel { color : white; background-color : red; }"
23 24
24 def __init__(self, parent=None): 25 def __init__(self, parent=None):
25 """ 26 """
26 Constructor 27 Constructor
27 28
28 @param parent reference to the parent widget (QWidget) 29 @param parent reference to the parent widget (QWidget)
29 """ 30 """
30 super().__init__(parent) 31 super().__init__(parent)
31 32
32 self.setFocusPolicy(Qt.FocusPolicy.NoFocus) 33 self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
33 self.setCursor(Qt.CursorShape.PointingHandCursor) 34 self.setCursor(Qt.CursorShape.PointingHandCursor)
34 35
35 self.setStyleSheet(SafeBrowsingLabel.nokStyle) 36 self.setStyleSheet(SafeBrowsingLabel.nokStyle)
36 37
37 self.__threatType = "" 38 self.__threatType = ""
38 self.__threatMessages = "" 39 self.__threatMessages = ""
39 40
40 self.__deafultText = self.tr("Malicious Site") 41 self.__deafultText = self.tr("Malicious Site")
41 self.__updateLabel() 42 self.__updateLabel()
42 43
43 def mouseReleaseEvent(self, evt): 44 def mouseReleaseEvent(self, evt):
44 """ 45 """
45 Protected method to handle mouse release events. 46 Protected method to handle mouse release events.
46 47
47 @param evt reference to the mouse event (QMouseEvent) 48 @param evt reference to the mouse event (QMouseEvent)
48 """ 49 """
49 if evt.button() == Qt.MouseButton.LeftButton: 50 if evt.button() == Qt.MouseButton.LeftButton:
50 self.clicked.emit(evt.globalPosition().toPoint()) 51 self.clicked.emit(evt.globalPosition().toPoint())
51 else: 52 else:
52 super().mouseReleaseEvent(evt) 53 super().mouseReleaseEvent(evt)
53 54
54 def mouseDoubleClickEvent(self, evt): 55 def mouseDoubleClickEvent(self, evt):
55 """ 56 """
56 Protected method to handle mouse double click events. 57 Protected method to handle mouse double click events.
57 58
58 @param evt reference to the mouse event (QMouseEvent) 59 @param evt reference to the mouse event (QMouseEvent)
59 """ 60 """
60 if evt.button() == Qt.MouseButton.LeftButton: 61 if evt.button() == Qt.MouseButton.LeftButton:
61 self.clicked.emit(evt.globalPosition().toPoint()) 62 self.clicked.emit(evt.globalPosition().toPoint())
62 else: 63 else:
63 super().mouseDoubleClickEvent(evt) 64 super().mouseDoubleClickEvent(evt)
64 65
65 @pyqtSlot() 66 @pyqtSlot()
66 def __updateLabel(self): 67 def __updateLabel(self):
67 """ 68 """
68 Private slot to update the label text. 69 Private slot to update the label text.
69 """ 70 """
70 if self.__threatType: 71 if self.__threatType:
71 self.setText(self.__threatType) 72 self.setText(self.__threatType)
72 else: 73 else:
73 self.setText(self.__deafultText) 74 self.setText(self.__deafultText)
74 75
75 @pyqtSlot(str, str) 76 @pyqtSlot(str, str)
76 def setThreatInfo(self, threatType, threatMessages): 77 def setThreatInfo(self, threatType, threatMessages):
77 """ 78 """
78 Public slot to set threat information. 79 Public slot to set threat information.
79 80
80 @param threatType threat type 81 @param threatType threat type
81 @type str 82 @type str
82 @param threatMessages more verbose info about detected threats 83 @param threatMessages more verbose info about detected threats
83 @type str 84 @type str
84 """ 85 """
85 self.__threatType = threatType 86 self.__threatType = threatType
86 self.__threatMessages = threatMessages 87 self.__threatMessages = threatMessages
87 88
88 self.__updateLabel() 89 self.__updateLabel()
89 90
90 def getThreatInfo(self): 91 def getThreatInfo(self):
91 """ 92 """
92 Public method to get the threat info text. 93 Public method to get the threat info text.
93 94
94 @return threat info text 95 @return threat info text
95 @rtype str 96 @rtype str
96 """ 97 """
97 return self.__threatMessages 98 return self.__threatMessages

eric ide

mercurial