287 settings.setFontSize(QWebSettings.DefaultFontSize, standardFont.pointSize()) |
287 settings.setFontSize(QWebSettings.DefaultFontSize, standardFont.pointSize()) |
288 settings.setFontFamily(QWebSettings.FixedFont, fixedFont.family()) |
288 settings.setFontFamily(QWebSettings.FixedFont, fixedFont.family()) |
289 settings.setFontSize(QWebSettings.DefaultFixedFontSize, fixedFont.pointSize()) |
289 settings.setFontSize(QWebSettings.DefaultFixedFontSize, fixedFont.pointSize()) |
290 |
290 |
291 styleSheet = Preferences.getHelp("UserStyleSheet") |
291 styleSheet = Preferences.getHelp("UserStyleSheet") |
292 if styleSheet: |
292 settings.setUserStyleSheetUrl(self.__userStyleSheet(styleSheet)) |
293 settings.setUserStyleSheetUrl(QUrl(styleSheet)) |
|
294 |
293 |
295 settings.setAttribute(QWebSettings.AutoLoadImages, |
294 settings.setAttribute(QWebSettings.AutoLoadImages, |
296 Preferences.getHelp("AutoLoadImages")) |
295 Preferences.getHelp("AutoLoadImages")) |
297 settings.setAttribute(QWebSettings.JavaEnabled, |
296 settings.setAttribute(QWebSettings.JavaEnabled, |
298 Preferences.getHelp("JavaEnabled")) |
297 Preferences.getHelp("JavaEnabled")) |
2669 |
2668 |
2670 def __showAdBlockDialog(self): |
2669 def __showAdBlockDialog(self): |
2671 """ |
2670 """ |
2672 Private slot to show the AdBlock configuration dialog. |
2671 Private slot to show the AdBlock configuration dialog. |
2673 """ |
2672 """ |
2674 self.adblockManager().showDialog() |
2673 self.adBlockManager().showDialog() |
2675 |
2674 |
2676 def __showClickToFlashDialog(self): |
2675 def __showClickToFlashDialog(self): |
2677 """ |
2676 """ |
2678 Private slot to open the ClickToFlash whitelist configuration dialog. |
2677 Private slot to open the ClickToFlash whitelist configuration dialog. |
2679 """ |
2678 """ |
2830 cls._passwordManager = PasswordManager() |
2829 cls._passwordManager = PasswordManager() |
2831 |
2830 |
2832 return cls._passwordManager |
2831 return cls._passwordManager |
2833 |
2832 |
2834 @classmethod |
2833 @classmethod |
2835 def adblockManager(cls): |
2834 def adBlockManager(cls): |
2836 """ |
2835 """ |
2837 Class method to get a reference to the AdBlock manager. |
2836 Class method to get a reference to the AdBlock manager. |
2838 |
2837 |
2839 @return reference to the AdBlock manager (AdBlockManager) |
2838 @return reference to the AdBlock manager (AdBlockManager) |
2840 """ |
2839 """ |
3230 Private slot to initiate the display of the file scan report page. |
3229 Private slot to initiate the display of the file scan report page. |
3231 |
3230 |
3232 @param url URL of the file scan report page (string) |
3231 @param url URL of the file scan report page (string) |
3233 """ |
3232 """ |
3234 self.newTab(url) |
3233 self.newTab(url) |
|
3234 |
|
3235 def reloadUserStyleSheet(self): |
|
3236 """ |
|
3237 Public method to reload the user style sheet. |
|
3238 """ |
|
3239 settings = QWebSettings.globalSettings() |
|
3240 styleSheet = Preferences.getHelp("UserStyleSheet") |
|
3241 settings.setUserStyleSheetUrl(self.__userStyleSheet(styleSheet)) |
|
3242 |
|
3243 def __userStyleSheet(self, styleSheetFile): |
|
3244 """ |
|
3245 Private method to generate the user style sheet. |
|
3246 |
|
3247 @param styleSheetFile name of the user style sheet file (string) |
|
3248 @return style sheet (QUrl) |
|
3249 """ |
|
3250 userStyle = self.adBlockManager().elementHidingRules() + \ |
|
3251 "{display:none !important;}" |
|
3252 |
|
3253 if styleSheetFile: |
|
3254 try: |
|
3255 f = open(styleSheetFile, "r") |
|
3256 fileData = f.read() |
|
3257 f.close() |
|
3258 fileData = fileData.replace("\n", "") |
|
3259 userStyle += fileData |
|
3260 except IOError: |
|
3261 pass |
|
3262 |
|
3263 encodedStyle = bytes(QByteArray(userStyle).toBase64()).decode() |
|
3264 dataString = "data:text/css;charset=utf-8;base64,{0}".format(encodedStyle) |
|
3265 |
|
3266 return QUrl(dataString) |