Continued porting the web browser. QtWebEngine

Sat, 19 Mar 2016 18:18:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 19 Mar 2016 18:18:09 +0100
branch
QtWebEngine
changeset 4880
561f2bd9cfb9
parent 4875
4ee26909ac0d
child 4881
c269212cceac

Continued porting the web browser.

- really finished porting the AdBlock code

WebBrowser/AdBlock/AdBlockIcon.py file | annotate | diff | comparison | revisions
WebBrowser/AdBlock/AdBlockTreeWidget.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserView.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
--- a/WebBrowser/AdBlock/AdBlockIcon.py	Sat Mar 19 16:05:11 2016 +0100
+++ b/WebBrowser/AdBlock/AdBlockIcon.py	Sat Mar 19 18:18:09 2016 +0100
@@ -105,7 +105,7 @@
         @return reference to the menu action (QAction)
         """
         if not self.__menuAction:
-            self.__menuAction = QAction(self.tr("AdBlock"))
+            self.__menuAction = QAction(self.tr("AdBlock"), self)
             self.__menuAction.setMenu(QMenu())
             self.__menuAction.menu().aboutToShow.connect(self.__createMenu)
         
--- a/WebBrowser/AdBlock/AdBlockTreeWidget.py	Sat Mar 19 16:05:11 2016 +0100
+++ b/WebBrowser/AdBlock/AdBlockTreeWidget.py	Sat Mar 19 18:18:09 2016 +0100
@@ -126,18 +126,7 @@
         
         from .AdBlockRule import AdBlockRule
         rule = AdBlockRule(filter, self.__subscription)
-        offset = self.__subscription.addRule(rule)
-        
-        item = QTreeWidgetItem()
-        item.setText(0, filter)
-        item.setData(0, Qt.UserRole, offset)
-        item.setFlags(item.flags() | Qt.ItemIsEditable)
-        
-        self.__itemChangingBlock = True
-        self.__topItem.addChild(item)
-        self.__itemChangingBlock = False
-        
-        self.__adjustItemFeatures(item, rule)
+        self.__subscription.addRule(rule)
     
     def removeRule(self):
         """
--- a/WebBrowser/WebBrowserView.py	Sat Mar 19 16:05:11 2016 +0100
+++ b/WebBrowser/WebBrowserView.py	Sat Mar 19 18:18:09 2016 +0100
@@ -551,9 +551,8 @@
         
         self.__createContextMenu(self.__menu, hitTest)
         
-        # TODO: AdBlock
-##        if not hitTest.isContentEditable() and not hitTest.isContentSelected():
-##            self.__menu.addAction(self.__mw.adBlockIcon().menuAction())
+        if not hitTest.isContentEditable() and not hitTest.isContentSelected():
+            self.__menu.addAction(self.__mw.adBlockIcon().menuAction())
         
         if Preferences.getWebBrowser("WebInspectorEnabled"):
             self.__menu.addSeparator()
@@ -688,12 +687,11 @@
             UI.PixmapCache.getIcon("mailSend.png"),
             self.tr("Send Image Link"),
             self.__sendLink).setData(hitTest.imageUrl())
-        # TODO: AdBlock
-##        menu.addSeparator()
-##        menu.addAction(
-##            UI.PixmapCache.getIcon("adBlockPlus.png"),
-##            self.tr("Block Image"), self.__blockImage)\
-##            .setData(hitTest.imageUrl().toString())
+        menu.addSeparator()
+        menu.addAction(
+            UI.PixmapCache.getIcon("adBlockPlus.png"),
+            self.tr("Block Image"), self.__blockImage)\
+            .setData(hitTest.imageUrl().toString())
         if Preferences.getWebBrowser("VirusTotalEnabled") and \
            Preferences.getWebBrowser("VirusTotalServiceKey") != "":
             menu.addAction(
@@ -1038,16 +1036,15 @@
 ##        """
 ##        self.triggerPageAction(QWebEnginePage.CopyImageToClipboard)
     
-    # TODO: AdBlock
-##    def __blockImage(self):
-##        """
-##        Private slot to add a block rule for an image URL.
-##        """
-##        import WebBrowser.WebBrowserWindow
-##        act = self.sender()
-##        url = act.data()
-##        dlg = WebBrowser.WebBrowserWindow.WebBrowserWindow.adBlockManager().showDialog()
-##        dlg.addCustomRule(url)
+    def __blockImage(self):
+        """
+        Private slot to add a block rule for an image URL.
+        """
+        from WebBrowser.WebBrowserWindow import WebBrowserWindow
+        act = self.sender()
+        url = act.data()
+        dlg = WebBrowserWindow.adBlockManager().showDialog()
+        dlg.addCustomRule(url)
     
     # TODO: Qt 5.6
 ##    def __downloadMedia(self):
@@ -1535,8 +1532,8 @@
         
         if ok:
             self.__mw.historyManager().addHistoryEntry(self)
-            # TODO: AdBlock
-##            self.__mw.adBlockManager().page().hideBlockedPageEntries(self.page())
+            self.__mw.adBlockManager().page().hideBlockedPageEntries(
+                self.page())
             self.__mw.passwordManager().completePage(self.page())
     
     def isLoading(self):
--- a/WebBrowser/WebBrowserWindow.py	Sat Mar 19 16:05:11 2016 +0100
+++ b/WebBrowser/WebBrowserWindow.py	Sat Mar 19 18:18:09 2016 +0100
@@ -1568,23 +1568,22 @@
             self.passwordsAct.triggered.connect(self.__showPasswordsDialog)
         self.__actions.append(self.passwordsAct)
         
-        # TODO: AdBlock
-##        self.adblockAct = E5Action(
-##            self.tr('Ad Block'),
-##            UI.PixmapCache.getIcon("adBlockPlus.png"),
-##            self.tr('&Ad Block...'),
-##            0, 0,
-##            self, 'webbrowser_adblock')
-##        self.adblockAct.setStatusTip(self.tr(
-##            'Configure AdBlock subscriptions and rules'))
-##        self.adblockAct.setWhatsThis(self.tr(
-##            """<b>Ad Block...</b>"""
-##            """<p>Opens a dialog to configure AdBlock subscriptions and"""
-##            """ rules.</p>"""
-##        ))
-##        if not self.__initShortcutsOnly:
-##            self.adblockAct.triggered.connect(self.__showAdBlockDialog)
-##        self.__actions.append(self.adblockAct)
+        self.adblockAct = E5Action(
+            self.tr('Ad Block'),
+            UI.PixmapCache.getIcon("adBlockPlus.png"),
+            self.tr('&Ad Block...'),
+            0, 0,
+            self, 'webbrowser_adblock')
+        self.adblockAct.setStatusTip(self.tr(
+            'Configure AdBlock subscriptions and rules'))
+        self.adblockAct.setWhatsThis(self.tr(
+            """<b>Ad Block...</b>"""
+            """<p>Opens a dialog to configure AdBlock subscriptions and"""
+            """ rules.</p>"""
+        ))
+        if not self.__initShortcutsOnly:
+            self.adblockAct.triggered.connect(self.__showAdBlockDialog)
+        self.__actions.append(self.adblockAct)
         
         # TODO: Click2Flash (?)
 ##        self.flashblockAct = E5Action(
@@ -1911,7 +1910,7 @@
         menu.addAction(self.zoomValuesAct)
         menu.addAction(self.manageIconsAct)
         menu.addSeparator()
-##        menu.addAction(self.adblockAct)
+        menu.addAction(self.adblockAct)
 ##        menu.addAction(self.flashblockAct)
 ##        menu.addSeparator()
         self.__settingsMenu = menu
@@ -3394,13 +3393,12 @@
         """
         self.networkManager().showSslErrorExceptionsDialog()
     
-    # TODO: AdBlock
-##    def __showAdBlockDialog(self):
-##        """
-##        Private slot to show the AdBlock configuration dialog.
-##        """
-##        self.adBlockManager().showDialog()
-##        
+    def __showAdBlockDialog(self):
+        """
+        Private slot to show the AdBlock configuration dialog.
+        """
+        self.adBlockManager().showDialog()
+        
     # TODO: Click2Flash
 ##    def __showClickToFlashDialog(self):
 ##        """

eric ide

mercurial