1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the feature permission bar widget. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QLabel, QHBoxLayout, QPushButton |
|
11 |
|
12 from E5Gui.E5AnimatedWidget import E5AnimatedWidget |
|
13 |
|
14 import UI.PixmapCache |
|
15 |
|
16 |
|
17 class FlashCookieNotification(E5AnimatedWidget): |
|
18 """ |
|
19 Class implementing the feature permission bar widget. |
|
20 """ |
|
21 DefaultHeight = 30 |
|
22 |
|
23 def __init__(self, view, manager, noCookies): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param view reference to the web view |
|
28 @type WebBrowserView |
|
29 @param manager reference to the Flash cookie manager object |
|
30 @type FlashCookieManager |
|
31 @param noCookies number of newly detected Flash cookies |
|
32 @type int |
|
33 """ |
|
34 super(FlashCookieNotification, self).__init__(parent=view) |
|
35 |
|
36 self.__manager = manager |
|
37 |
|
38 if noCookies == 1: |
|
39 msg = self.tr("A new flash cookie was detected.") |
|
40 else: |
|
41 msg = self.tr( |
|
42 "{0} new flash cookies were detected." |
|
43 ).format(noCookies) |
|
44 self.setAutoFillBackground(True) |
|
45 self.__layout = QHBoxLayout() |
|
46 self.setLayout(self.__layout) |
|
47 self.__layout.setContentsMargins(9, 0, 0, 0) |
|
48 self.__iconLabel = QLabel(self) |
|
49 self.__iconLabel.setPixmap(UI.PixmapCache.getPixmap("flashCookie")) |
|
50 self.__layout.addWidget(self.__iconLabel) |
|
51 self.__messageLabel = QLabel(msg, self) |
|
52 self.__layout.addWidget(self.__messageLabel) |
|
53 self.__viewButton = QPushButton(self.tr("View"), self) |
|
54 self.__layout.addWidget(self.__viewButton) |
|
55 self.__layout.addStretch() |
|
56 self.__discardButton = QPushButton(UI.PixmapCache.getIcon("close"), |
|
57 "", self) |
|
58 self.__layout.addWidget(self.__discardButton) |
|
59 |
|
60 self.__viewButton.clicked.connect(manager.showFlashCookieManagerDialog) |
|
61 self.__viewButton.clicked.connect(self.hide) |
|
62 self.__discardButton.clicked.connect(self.hide) |
|
63 |
|
64 self.resize(view.width(), self.height()) |
|
65 self.startAnimation() |
|