Helpviewer/HelpWindow.py

changeset 637
4e4c729e86cf
parent 634
7b84cbd2f752
child 638
265c31231d9d
equal deleted inserted replaced
635:ab9f99806cf8 637:4e4c729e86cf
2211 def __tabContextMenuCloseOthers(self): 2211 def __tabContextMenuCloseOthers(self):
2212 """ 2212 """
2213 Private slot to close all other tabs. 2213 Private slot to close all other tabs.
2214 """ 2214 """
2215 index = self.tabContextMenuIndex 2215 index = self.tabContextMenuIndex
2216 for i in list(range(self.tabWidget.count() - 1, index, -1)) + list(range(index - 1, -1, -1)): 2216 for i in list(range(self.tabWidget.count() - 1, index, -1)) + \
2217 list(range(index - 1, -1, -1)):
2217 self.__closeAt(i) 2218 self.__closeAt(i)
2218 2219
2219 def __tabContextMenuPrint(self): 2220 def __tabContextMenuPrint(self):
2220 """ 2221 """
2221 Private method to print the selected tab. 2222 Private method to print the selected tab.
2936 for codec in QTextCodec.availableCodecs(): 2937 for codec in QTextCodec.availableCodecs():
2937 codecs.append(str(codec, encoding = "utf-8").lower()) 2938 codecs.append(str(codec, encoding = "utf-8").lower())
2938 codecs.sort() 2939 codecs.sort()
2939 2940
2940 defaultTextEncoding = QWebSettings.globalSettings().defaultTextEncoding().lower() 2941 defaultTextEncoding = QWebSettings.globalSettings().defaultTextEncoding().lower()
2941 print(defaultTextEncoding) 2942 if defaultTextEncoding in codecs:
2942 try: 2943 currentCodec = defaultTextEncoding
2943 currentCodec = codecs.index(defaultTextEncoding) 2944 else:
2944 except ValueError: 2945 currentCodec = ""
2945 currentCodec = -1
2946 2946
2947 defaultEncodingAct = self.__textEncodingMenu.addAction(self.trUtf8("Default")) 2947 defaultEncodingAct = self.__textEncodingMenu.addAction(self.trUtf8("Default"))
2948 defaultEncodingAct.setData(-1) 2948 defaultEncodingAct.setData("")
2949 defaultEncodingAct.setCheckable(True) 2949 defaultEncodingAct.setCheckable(True)
2950 if currentCodec == -1: 2950 if currentCodec == "":
2951 defaultEncodingAct.setChecked(True) 2951 defaultEncodingAct.setChecked(True)
2952 self.__textEncodingMenu.addSeparator() 2952 self.__textEncodingMenu.addSeparator()
2953 2953
2954 for i in range(len(codecs)): 2954 for codec in codecs:
2955 codec = codecs[i]
2956 act = self.__textEncodingMenu.addAction(codec) 2955 act = self.__textEncodingMenu.addAction(codec)
2957 act.setData(i) 2956 act.setData(codec)
2958 act.setCheckable(True) 2957 act.setCheckable(True)
2959 if currentCodec == i: 2958 if currentCodec == codec:
2960 act.setChecked(True) 2959 act.setChecked(True)
2961 2960
2962 def __setTextEncoding(self, act): 2961 def __setTextEncoding(self, act):
2963 """ 2962 """
2964 Private slot to set the selected text encoding as the default for 2963 Private slot to set the selected text encoding as the default for
2965 this session. 2964 this session.
2966 2965
2967 @param act reference to the selected action (QAction) 2966 @param act reference to the selected action (QAction)
2968 """ 2967 """
2969 codecs = [] 2968 codec = act.data()
2970 for codec in QTextCodec.availableCodecs(): 2969 if codec == "":
2971 codecs.append(str(codec, encoding = "utf-8").lower())
2972 codecs.sort()
2973
2974 offset = act.data()
2975 print(offset, len(codecs))
2976 if offset < 0 or offset >= len(codecs):
2977 QWebSettings.globalSettings().setDefaultTextEncoding("") 2970 QWebSettings.globalSettings().setDefaultTextEncoding("")
2978 Preferences.setHelp("DefaultTextEncoding", "")
2979 else: 2971 else:
2980 print(codecs[offset]) 2972 QWebSettings.globalSettings().setDefaultTextEncoding(codec)
2981 QWebSettings.globalSettings().setDefaultTextEncoding(codecs[offset])
2982 Preferences.setHelp("DefaultTextEncoding", codecs[offset])

eric ide

mercurial