349 |
349 |
350 if hasattr(QWebSettings, "DnsPrefetchEnabled"): |
350 if hasattr(QWebSettings, "DnsPrefetchEnabled"): |
351 settings.setAttribute(QWebSettings.DnsPrefetchEnabled, |
351 settings.setAttribute(QWebSettings.DnsPrefetchEnabled, |
352 Preferences.getHelp("DnsPrefetchEnabled")) |
352 Preferences.getHelp("DnsPrefetchEnabled")) |
353 |
353 |
|
354 if hasattr(QWebSettings, "defaultTextEncoding"): |
|
355 settings.setDefaultTextEncoding( |
|
356 Preferences.getHelp("DefaultTextEncoding")) |
|
357 |
354 def __initActions(self): |
358 def __initActions(self): |
355 """ |
359 """ |
356 Private method to define the user interface actions. |
360 Private method to define the user interface actions. |
357 """ |
361 """ |
358 # list of all actions |
362 # list of all actions |
1154 if self.zoomTextOnlyAct is not None: |
1158 if self.zoomTextOnlyAct is not None: |
1155 menu.addAction(self.zoomTextOnlyAct) |
1159 menu.addAction(self.zoomTextOnlyAct) |
1156 menu.addSeparator() |
1160 menu.addSeparator() |
1157 menu.addAction(self.pageSourceAct) |
1161 menu.addAction(self.pageSourceAct) |
1158 menu.addAction(self.fullScreenAct) |
1162 menu.addAction(self.fullScreenAct) |
|
1163 if hasattr(QWebSettings, 'defaultTextEncoding'): |
|
1164 self.__textEncodingMenu = menu.addMenu(self.trUtf8("Text Encoding")) |
|
1165 self.connect(self.__textEncodingMenu, SIGNAL("aboutToShow()"), |
|
1166 self.__aboutToShowTextEncodingMenu) |
|
1167 self.connect(self.__textEncodingMenu, SIGNAL("triggered(QAction*)"), |
|
1168 self.__setTextEncoding) |
1159 |
1169 |
1160 menu = mb.addMenu(self.trUtf8('&Go')) |
1170 menu = mb.addMenu(self.trUtf8('&Go')) |
1161 menu.setTearOffEnabled(True) |
1171 menu.setTearOffEnabled(True) |
1162 menu.addAction(self.backAct) |
1172 menu.addAction(self.backAct) |
1163 menu.addAction(self.forwardAct) |
1173 menu.addAction(self.forwardAct) |
2966 Public method to get a reference to the opensearch manager object. |
2976 Public method to get a reference to the opensearch manager object. |
2967 |
2977 |
2968 @return reference to the opensearch manager object (OpenSearchManager) |
2978 @return reference to the opensearch manager object (OpenSearchManager) |
2969 """ |
2979 """ |
2970 return self.searchEdit.openSearchManager() |
2980 return self.searchEdit.openSearchManager() |
|
2981 |
|
2982 def __aboutToShowTextEncodingMenu(self): |
|
2983 """ |
|
2984 Private slot to populate the text encoding menu. |
|
2985 """ |
|
2986 self.__textEncodingMenu.clear() |
|
2987 |
|
2988 codecs = [] |
|
2989 for codec in QTextCodec.availableCodecs(): |
|
2990 codecs.append(str(codec, encoding = "utf-8").lower()) |
|
2991 codecs.sort() |
|
2992 |
|
2993 defaultTextEncoding = QWebSettings.globalSettings().defaultTextEncoding().lower() |
|
2994 print(defaultTextEncoding) |
|
2995 try: |
|
2996 currentCodec = codecs.index(defaultTextEncoding) |
|
2997 except ValueError: |
|
2998 currentCodec = -1 |
|
2999 |
|
3000 defaultEncodingAct = self.__textEncodingMenu.addAction(self.trUtf8("Default")) |
|
3001 defaultEncodingAct.setData(-1) |
|
3002 defaultEncodingAct.setCheckable(True) |
|
3003 if currentCodec == -1: |
|
3004 defaultEncodingAct.setChecked(True) |
|
3005 self.__textEncodingMenu.addSeparator() |
|
3006 |
|
3007 for i in range(len(codecs)): |
|
3008 codec = codecs[i] |
|
3009 act = self.__textEncodingMenu.addAction(codec) |
|
3010 act.setData(i) |
|
3011 act.setCheckable(True) |
|
3012 if currentCodec == i: |
|
3013 act.setChecked(True) |
|
3014 |
|
3015 def __setTextEncoding(self, act): |
|
3016 """ |
|
3017 Private slot to set the selected text encoding as the default for |
|
3018 this session. |
|
3019 |
|
3020 @param act reference to the selected action (QAction) |
|
3021 """ |
|
3022 codecs = [] |
|
3023 for codec in QTextCodec.availableCodecs(): |
|
3024 codecs.append(str(codec, encoding = "utf-8").lower()) |
|
3025 codecs.sort() |
|
3026 |
|
3027 offset = act.data() |
|
3028 print(offset, len(codecs)) |
|
3029 if offset < 0 or offset >= len(codecs): |
|
3030 QWebSettings.globalSettings().setDefaultTextEncoding("") |
|
3031 Preferences.setHelp("DefaultTextEncoding", "") |
|
3032 else: |
|
3033 print(codecs[offset]) |
|
3034 QWebSettings.globalSettings().setDefaultTextEncoding(codecs[offset]) |
|
3035 Preferences.setHelp("DefaultTextEncoding", codecs[offset]) |