WebBrowser/SafeBrowsing/SafeBrowsingInfoWidget.py

branch
safe_browsing
changeset 5829
d3448873ced3
child 6048
82ad8ec9548c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/SafeBrowsing/SafeBrowsingInfoWidget.py	Fri Aug 04 18:38:45 2017 +0200
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a widget to show some threat information.
+"""
+
+from __future__ import unicode_literals
+
+from PyQt5.QtCore import Qt, QPoint
+from PyQt5.QtWidgets import QMenu, QLabel, QHBoxLayout, QSizePolicy
+
+import UI.PixmapCache
+
+
+class SafeBrowsingInfoWidget(QMenu):
+    """
+    Class implementing a widget to show some threat information.
+    """
+    def __init__(self, info, parent=None):
+        """
+        Constructor
+        
+        @param info information string to be shown
+        @type str
+        @param parent reference to the parent widget
+        @type QWidget
+        """
+        super(SafeBrowsingInfoWidget, self).__init__(parent)
+        
+        self.setMinimumWidth(500)
+        
+        layout = QHBoxLayout(self)
+        
+        iconLabel = QLabel(self)
+        iconLabel.setPixmap(UI.PixmapCache.getPixmap("safeBrowsing48.png"))
+        layout.addWidget(iconLabel, 0, Qt.AlignTop)
+        
+        infoLabel = QLabel(self)
+        infoLabel.setWordWrap(True)
+        infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+        infoLabel.setText(info)
+        layout.addWidget(infoLabel, 0, Qt.AlignTop)
+    
+    def showAt(self, pos):
+        """
+        Public method to show the widget.
+        
+        @param pos position to show at
+        @type QPoint
+        """
+        self.adjustSize()
+        xpos = pos.x() - self.width()
+        if xpos < 0:
+            xpos = 10
+        p = QPoint(xpos, pos.y() + 10)
+        self.move(p)
+        self.show()

eric ide

mercurial