eric6/WebBrowser/FlashCookieManager/FlashCookieNotification.py

Wed, 30 Dec 2020 11:00:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:05 +0100
changeset 7923
91e843545d9a
parent 7781
607a6098cb44
permissions
-rw-r--r--

Updated copyright for 2021.

# -*- coding: utf-8 -*-

# Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the feature permission bar widget.
"""

from PyQt5.QtWidgets import QLabel, QHBoxLayout, QPushButton

from E5Gui.E5AnimatedWidget import E5AnimatedWidget

import UI.PixmapCache


class FlashCookieNotification(E5AnimatedWidget):
    """
    Class implementing the feature permission bar widget.
    """
    DefaultHeight = 30
    
    def __init__(self, view, manager, noCookies):
        """
        Constructor
        
        @param view reference to the web view
        @type WebBrowserView
        @param manager reference to the Flash cookie manager object
        @type FlashCookieManager
        @param noCookies number of newly detected Flash cookies
        @type int
        """
        super(FlashCookieNotification, self).__init__(parent=view)
        
        self.__manager = manager
        
        if noCookies == 1:
            msg = self.tr("A new flash cookie was detected.")
        else:
            msg = self.tr(
                "{0} new flash cookies were detected."
            ).format(noCookies)
        self.setAutoFillBackground(True)
        self.__layout = QHBoxLayout()
        self.setLayout(self.__layout)
        self.__layout.setContentsMargins(9, 0, 0, 0)
        self.__iconLabel = QLabel(self)
        self.__iconLabel.setPixmap(UI.PixmapCache.getPixmap("flashCookie"))
        self.__layout.addWidget(self.__iconLabel)
        self.__messageLabel = QLabel(msg, self)
        self.__layout.addWidget(self.__messageLabel)
        self.__viewButton = QPushButton(self.tr("View"), self)
        self.__layout.addWidget(self.__viewButton)
        self.__layout.addStretch()
        self.__discardButton = QPushButton(UI.PixmapCache.getIcon("close"),
                                           "", self)
        self.__layout.addWidget(self.__discardButton)
        
        self.__viewButton.clicked.connect(manager.showFlashCookieManagerDialog)
        self.__viewButton.clicked.connect(self.hide)
        self.__discardButton.clicked.connect(self.hide)
        
        self.resize(view.width(), self.height())
        self.startAnimation()

eric ide

mercurial