eric6/WebBrowser/SafeBrowsing/SafeBrowsingInfoWidget.py

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

eric ide

mercurial