eric6/Plugins/UiExtensionPlugins/Translator/ConfigurationPage/TranslatorPage.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
69 languages = TranslatorLanguagesDb() 69 languages = TranslatorLanguagesDb()
70 for languageCode in languages.getAllLanguages(): 70 for languageCode in languages.getAllLanguages():
71 itm = QListWidgetItem() 71 itm = QListWidgetItem()
72 itm.setText(languages.getLanguage(languageCode)) 72 itm.setText(languages.getLanguage(languageCode))
73 itm.setIcon(languages.getLanguageIcon(languageCode)) 73 itm.setIcon(languages.getLanguageIcon(languageCode))
74 itm.setData(Qt.UserRole, languageCode) 74 itm.setData(Qt.ItemDataRole.UserRole, languageCode)
75 if languageCode in enabledLanguages or not enabledLanguages: 75 if languageCode in enabledLanguages or not enabledLanguages:
76 itm.setCheckState(Qt.Checked) 76 itm.setCheckState(Qt.CheckState.Checked)
77 else: 77 else:
78 itm.setCheckState(Qt.Unchecked) 78 itm.setCheckState(Qt.CheckState.Unchecked)
79 self.languagesList.addItem(itm) 79 self.languagesList.addItem(itm)
80 self.languagesList.sortItems() 80 self.languagesList.sortItems()
81 81
82 # DeepL settings 82 # DeepL settings
83 self.deeplKeyEdit.setText( 83 self.deeplKeyEdit.setText(
107 def save(self): 107 def save(self):
108 """ 108 """
109 Public slot to save the Pyramid configuration. 109 Public slot to save the Pyramid configuration.
110 """ 110 """
111 enabledLanguages = [ 111 enabledLanguages = [
112 itm.data(Qt.UserRole) 112 itm.data(Qt.ItemDataRole.UserRole)
113 for itm in self.__checkedLanguageItems() 113 for itm in self.__checkedLanguageItems()
114 ] 114 ]
115 self.__plugin.setPreferences( 115 self.__plugin.setPreferences(
116 "EnabledLanguages", enabledLanguages) 116 "EnabledLanguages", enabledLanguages)
117 117
145 @return list of checked language items (list of QListWidgetItem) 145 @return list of checked language items (list of QListWidgetItem)
146 """ 146 """
147 items = [] 147 items = []
148 for index in range(self.languagesList.count()): 148 for index in range(self.languagesList.count()):
149 itm = self.languagesList.item(index) 149 itm = self.languagesList.item(index)
150 if itm.checkState() == Qt.Checked: 150 if itm.checkState() == Qt.CheckState.Checked:
151 items.append(itm) 151 items.append(itm)
152 152
153 return items 153 return items
154 154
155 @pyqtSlot() 155 @pyqtSlot()
161 161
162 unset = len(self.__checkedLanguageItems()) > 0 162 unset = len(self.__checkedLanguageItems()) > 0
163 for index in range(self.languagesList.count()): 163 for index in range(self.languagesList.count()):
164 itm = self.languagesList.item(index) 164 itm = self.languagesList.item(index)
165 if unset: 165 if unset:
166 itm.setCheckState(Qt.Unchecked) 166 itm.setCheckState(Qt.CheckState.Unchecked)
167 else: 167 else:
168 itm.setCheckState(Qt.Checked) 168 itm.setCheckState(Qt.CheckState.Checked)
169 169
170 self.__enableLanguageWarning = True 170 self.__enableLanguageWarning = True
171 171
172 @pyqtSlot() 172 @pyqtSlot()
173 def on_defaultButton_clicked(self): 173 def on_defaultButton_clicked(self):
177 self.__enableLanguageWarning = False 177 self.__enableLanguageWarning = False
178 178
179 defaults = self.__plugin.getPreferencesDefault("EnabledLanguages") 179 defaults = self.__plugin.getPreferencesDefault("EnabledLanguages")
180 for index in range(self.languagesList.count()): 180 for index in range(self.languagesList.count()):
181 itm = self.languagesList.item(index) 181 itm = self.languagesList.item(index)
182 if itm.data(Qt.UserRole) in defaults: 182 if itm.data(Qt.ItemDataRole.UserRole) in defaults:
183 itm.setCheckState(Qt.Checked) 183 itm.setCheckState(Qt.CheckState.Checked)
184 else: 184 else:
185 itm.setCheckState(Qt.Unchecked) 185 itm.setCheckState(Qt.CheckState.Unchecked)
186 186
187 self.__enableLanguageWarning = True 187 self.__enableLanguageWarning = True
188 188
189 @pyqtSlot(QListWidgetItem) 189 @pyqtSlot(QListWidgetItem)
190 def on_languagesList_itemChanged(self, item): 190 def on_languagesList_itemChanged(self, item):

eric ide

mercurial