eric6/WebBrowser/FlashCookieManager/FlashCookieNotification.py

Thu, 19 Sep 2019 19:39:04 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 19 Sep 2019 19:39:04 +0200
changeset 7249
0bf517e60f54
parent 7229
53054eb5b15a
child 7268
a28338eaf694
permissions
-rw-r--r--

Fixed some code style issues.

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

# Copyright (c) 2015 - 2019 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.png"))
        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.png"),
                                           "", 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