Helpviewer/AdBlock/AdBlockIcon.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3190
a9a94491c4fd
child 3656
441956d8fce5
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
33 self.__menuAction = None 33 self.__menuAction = None
34 self.__enabled = False 34 self.__enabled = False
35 35
36 self.setMaximumHeight(16) 36 self.setMaximumHeight(16)
37 self.setCursor(Qt.PointingHandCursor) 37 self.setCursor(Qt.PointingHandCursor)
38 self.setToolTip(self.trUtf8( 38 self.setToolTip(self.tr(
39 "AdBlock lets you block unwanted content on web pages.")) 39 "AdBlock lets you block unwanted content on web pages."))
40 40
41 self.clicked.connect(self.__showMenu) 41 self.clicked.connect(self.__showMenu)
42 42
43 def setEnabled(self, enabled): 43 def setEnabled(self, enabled):
70 manager = Helpviewer.HelpWindow.HelpWindow.adBlockManager() 70 manager = Helpviewer.HelpWindow.HelpWindow.adBlockManager()
71 71
72 if manager.isEnabled(): 72 if manager.isEnabled():
73 menu.addAction( 73 menu.addAction(
74 UI.PixmapCache.getIcon("adBlockPlusDisabled.png"), 74 UI.PixmapCache.getIcon("adBlockPlusDisabled.png"),
75 self.trUtf8("Disable AdBlock"), 75 self.tr("Disable AdBlock"),
76 self.__enableAdBlock).setData(False) 76 self.__enableAdBlock).setData(False)
77 else: 77 else:
78 menu.addAction( 78 menu.addAction(
79 UI.PixmapCache.getIcon("adBlockPlus.png"), 79 UI.PixmapCache.getIcon("adBlockPlus.png"),
80 self.trUtf8("Enable AdBlock"), 80 self.tr("Enable AdBlock"),
81 self.__enableAdBlock).setData(True) 81 self.__enableAdBlock).setData(True)
82 menu.addSeparator() 82 menu.addSeparator()
83 if manager.isEnabled() and \ 83 if manager.isEnabled() and \
84 self.__mw.currentBrowser().page().url().host(): 84 self.__mw.currentBrowser().page().url().host():
85 if self.__isCurrentHostExcepted(): 85 if self.__isCurrentHostExcepted():
86 menu.addAction( 86 menu.addAction(
87 UI.PixmapCache.getIcon("adBlockPlus.png"), 87 UI.PixmapCache.getIcon("adBlockPlus.png"),
88 self.trUtf8("Remove AdBlock Exception"), 88 self.tr("Remove AdBlock Exception"),
89 self.__setException).setData(False) 89 self.__setException).setData(False)
90 else: 90 else:
91 menu.addAction( 91 menu.addAction(
92 UI.PixmapCache.getIcon("adBlockPlusGreen.png"), 92 UI.PixmapCache.getIcon("adBlockPlusGreen.png"),
93 self.trUtf8("Add AdBlock Exception"), 93 self.tr("Add AdBlock Exception"),
94 self.__setException).setData(True) 94 self.__setException).setData(True)
95 menu.addAction( 95 menu.addAction(
96 UI.PixmapCache.getIcon("adBlockPlusGreen.png"), 96 UI.PixmapCache.getIcon("adBlockPlusGreen.png"),
97 self.trUtf8("AdBlock Exceptions..."), manager.showExceptionsDialog) 97 self.tr("AdBlock Exceptions..."), manager.showExceptionsDialog)
98 menu.addSeparator() 98 menu.addSeparator()
99 menu.addAction( 99 menu.addAction(
100 UI.PixmapCache.getIcon("adBlockPlus.png"), 100 UI.PixmapCache.getIcon("adBlockPlus.png"),
101 self.trUtf8("AdBlock Configuration..."), manager.showDialog) 101 self.tr("AdBlock Configuration..."), manager.showDialog)
102 menu.addSeparator() 102 menu.addSeparator()
103 103
104 entries = self.__mw.currentBrowser().page().getAdBlockedPageEntries() 104 entries = self.__mw.currentBrowser().page().getAdBlockedPageEntries()
105 if entries: 105 if entries:
106 menu.addAction(self.trUtf8( 106 menu.addAction(self.tr(
107 "Blocked URL (AdBlock Rule) - click to edit rule"))\ 107 "Blocked URL (AdBlock Rule) - click to edit rule"))\
108 .setEnabled(False) 108 .setEnabled(False)
109 for entry in entries: 109 for entry in entries:
110 address = entry.urlString()[-55:] 110 address = entry.urlString()[-55:]
111 actionText = self.trUtf8("{0} with ({1})").format( 111 actionText = self.tr("{0} with ({1})").format(
112 address, entry.rule.filter()).replace("&", "&&") 112 address, entry.rule.filter()).replace("&", "&&")
113 act = menu.addAction(actionText, manager.showRule) 113 act = menu.addAction(actionText, manager.showRule)
114 act.setData(entry.rule) 114 act.setData(entry.rule)
115 else: 115 else:
116 menu.addAction(self.trUtf8("No content blocked")).setEnabled(False) 116 menu.addAction(self.tr("No content blocked")).setEnabled(False)
117 117
118 def menuAction(self): 118 def menuAction(self):
119 """ 119 """
120 Public method to get a reference to the menu action. 120 Public method to get a reference to the menu action.
121 121
122 @return reference to the menu action (QAction) 122 @return reference to the menu action (QAction)
123 """ 123 """
124 if not self.__menuAction: 124 if not self.__menuAction:
125 self.__menuAction = QAction(self.trUtf8("AdBlock")) 125 self.__menuAction = QAction(self.tr("AdBlock"))
126 self.__menuAction.setMenu(QMenu()) 126 self.__menuAction.setMenu(QMenu())
127 self.__menuAction.menu().aboutToShow.connect(self.__createMenu) 127 self.__menuAction.menu().aboutToShow.connect(self.__createMenu)
128 128
129 if self.__enabled: 129 if self.__enabled:
130 self.__menuAction.setIcon( 130 self.__menuAction.setIcon(

eric ide

mercurial