15 |
15 |
16 class SafeBrowsingInfoWidget(QMenu): |
16 class SafeBrowsingInfoWidget(QMenu): |
17 """ |
17 """ |
18 Class implementing a widget to show some threat information. |
18 Class implementing a widget to show some threat information. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, info, parent=None): |
21 def __init__(self, info, parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param info information string to be shown |
25 @param info information string to be shown |
25 @type str |
26 @type str |
26 @param parent reference to the parent widget |
27 @param parent reference to the parent widget |
27 @type QWidget |
28 @type QWidget |
28 """ |
29 """ |
29 super().__init__(parent) |
30 super().__init__(parent) |
30 |
31 |
31 self.setMinimumWidth(500) |
32 self.setMinimumWidth(500) |
32 |
33 |
33 layout = QHBoxLayout(self) |
34 layout = QHBoxLayout(self) |
34 |
35 |
35 iconLabel = QLabel(self) |
36 iconLabel = QLabel(self) |
36 iconLabel.setPixmap(UI.PixmapCache.getPixmap("safeBrowsing48")) |
37 iconLabel.setPixmap(UI.PixmapCache.getPixmap("safeBrowsing48")) |
37 layout.addWidget(iconLabel, 0, Qt.AlignmentFlag.AlignTop) |
38 layout.addWidget(iconLabel, 0, Qt.AlignmentFlag.AlignTop) |
38 |
39 |
39 infoLabel = QLabel(self) |
40 infoLabel = QLabel(self) |
40 infoLabel.setWordWrap(True) |
41 infoLabel.setWordWrap(True) |
41 infoLabel.setSizePolicy(QSizePolicy.Policy.Expanding, |
42 infoLabel.setSizePolicy( |
42 QSizePolicy.Policy.Expanding) |
43 QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding |
|
44 ) |
43 infoLabel.setText(info) |
45 infoLabel.setText(info) |
44 layout.addWidget(infoLabel, 0, Qt.AlignmentFlag.AlignTop) |
46 layout.addWidget(infoLabel, 0, Qt.AlignmentFlag.AlignTop) |
45 |
47 |
46 def showAt(self, pos): |
48 def showAt(self, pos): |
47 """ |
49 """ |
48 Public method to show the widget. |
50 Public method to show the widget. |
49 |
51 |
50 @param pos position to show at |
52 @param pos position to show at |
51 @type QPoint |
53 @type QPoint |
52 """ |
54 """ |
53 self.adjustSize() |
55 self.adjustSize() |
54 xpos = pos.x() - self.width() |
56 xpos = pos.x() - self.width() |