eric7/WebBrowser/SafeBrowsing/SafeBrowsingInfoWidget.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a widget to show some threat information.
8 """
9
10 from PyQt5.QtCore import Qt, QPoint
11 from PyQt5.QtWidgets import QMenu, QLabel, QHBoxLayout, QSizePolicy
12
13 import UI.PixmapCache
14
15
16 class SafeBrowsingInfoWidget(QMenu):
17 """
18 Class implementing a widget to show some threat information.
19 """
20 def __init__(self, info, parent=None):
21 """
22 Constructor
23
24 @param info information string to be shown
25 @type str
26 @param parent reference to the parent widget
27 @type QWidget
28 """
29 super().__init__(parent)
30
31 self.setMinimumWidth(500)
32
33 layout = QHBoxLayout(self)
34
35 iconLabel = QLabel(self)
36 iconLabel.setPixmap(UI.PixmapCache.getPixmap("safeBrowsing48"))
37 layout.addWidget(iconLabel, 0, Qt.AlignmentFlag.AlignTop)
38
39 infoLabel = QLabel(self)
40 infoLabel.setWordWrap(True)
41 infoLabel.setSizePolicy(QSizePolicy.Policy.Expanding,
42 QSizePolicy.Policy.Expanding)
43 infoLabel.setText(info)
44 layout.addWidget(infoLabel, 0, Qt.AlignmentFlag.AlignTop)
45
46 def showAt(self, pos):
47 """
48 Public method to show the widget.
49
50 @param pos position to show at
51 @type QPoint
52 """
53 self.adjustSize()
54 xpos = pos.x() - self.width()
55 if xpos < 0:
56 xpos = 10
57 p = QPoint(xpos, pos.y() + 10)
58 self.move(p)
59 self.show()

eric ide

mercurial