18 from PyQt6.QtWidgets import ( |
18 from PyQt6.QtWidgets import ( |
19 QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem |
19 QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem |
20 ) |
20 ) |
21 from PyQt6.QtNetwork import QNetworkRequest, QNetworkReply |
21 from PyQt6.QtNetwork import QNetworkRequest, QNetworkReply |
22 |
22 |
23 from E5Gui import E5MessageBox |
23 from E5Gui import EricMessageBox |
24 |
24 |
25 from .Ui_ManageDictionariesDialog import Ui_ManageDictionariesDialog |
25 from .Ui_ManageDictionariesDialog import Ui_ManageDictionariesDialog |
26 |
26 |
27 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
27 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
28 |
28 |
176 self.__replies.remove(reply) |
176 self.__replies.remove(reply) |
177 reply.deleteLater() |
177 reply.deleteLater() |
178 |
178 |
179 if reply.error() != QNetworkReply.NetworkError.NoError: |
179 if reply.error() != QNetworkReply.NetworkError.NoError: |
180 if not self.__downloadCancelled: |
180 if not self.__downloadCancelled: |
181 E5MessageBox.warning( |
181 EricMessageBox.warning( |
182 self, |
182 self, |
183 self.tr("Error downloading dictionaries list"), |
183 self.tr("Error downloading dictionaries list"), |
184 self.tr( |
184 self.tr( |
185 """<p>Could not download the dictionaries list""" |
185 """<p>Could not download the dictionaries list""" |
186 """ from {0}.</p><p>Error: {1}</p>""" |
186 """ from {0}.</p><p>Error: {1}</p>""" |
199 reader = SpellCheckDictionariesReader(listFileData, self.addEntry) |
199 reader = SpellCheckDictionariesReader(listFileData, self.addEntry) |
200 reader.readXML() |
200 reader.readXML() |
201 url = Preferences.getWebBrowser("SpellCheckDictionariesUrl") |
201 url = Preferences.getWebBrowser("SpellCheckDictionariesUrl") |
202 if url != self.dictionariesUrlEdit.text(): |
202 if url != self.dictionariesUrlEdit.text(): |
203 self.dictionariesUrlEdit.setText(url) |
203 self.dictionariesUrlEdit.setText(url) |
204 E5MessageBox.warning( |
204 EricMessageBox.warning( |
205 self, |
205 self, |
206 self.tr("Dictionaries URL Changed"), |
206 self.tr("Dictionaries URL Changed"), |
207 self.tr( |
207 self.tr( |
208 """The URL of the spell check dictionaries has""" |
208 """The URL of the spell check dictionaries has""" |
209 """ changed. Select the "Refresh" button to get""" |
209 """ changed. Select the "Refresh" button to get""" |
211 ) |
211 ) |
212 ) |
212 ) |
213 |
213 |
214 if self.locationComboBox.count() == 0: |
214 if self.locationComboBox.count() == 0: |
215 # no writable locations available |
215 # no writable locations available |
216 E5MessageBox.warning( |
216 EricMessageBox.warning( |
217 self, |
217 self, |
218 self.tr("Error installing dictionaries"), |
218 self.tr("Error installing dictionaries"), |
219 self.tr( |
219 self.tr( |
220 """<p>None of the dictionary locations is writable by""" |
220 """<p>None of the dictionary locations is writable by""" |
221 """ you. Please download required dictionaries manually""" |
221 """ you. Please download required dictionaries manually""" |
357 self.__replies.remove(reply) |
357 self.__replies.remove(reply) |
358 reply.deleteLater() |
358 reply.deleteLater() |
359 |
359 |
360 if reply.error() != QNetworkReply.NetworkError.NoError: |
360 if reply.error() != QNetworkReply.NetworkError.NoError: |
361 if not self.__downloadCancelled: |
361 if not self.__downloadCancelled: |
362 E5MessageBox.warning( |
362 EricMessageBox.warning( |
363 self, |
363 self, |
364 self.tr("Error downloading dictionary file"), |
364 self.tr("Error downloading dictionary file"), |
365 self.tr( |
365 self.tr( |
366 """<p>Could not download the requested dictionary""" |
366 """<p>Could not download the requested dictionary""" |
367 """ file from {0}.</p><p>Error: {1}</p>""" |
367 """ file from {0}.</p><p>Error: {1}</p>""" |
372 |
372 |
373 archiveData = reply.readAll() |
373 archiveData = reply.readAll() |
374 archiveFile = io.BytesIO(bytes(archiveData)) |
374 archiveFile = io.BytesIO(bytes(archiveData)) |
375 archive = zipfile.ZipFile(archiveFile, "r") |
375 archive = zipfile.ZipFile(archiveFile, "r") |
376 if archive.testzip() is not None: |
376 if archive.testzip() is not None: |
377 E5MessageBox.critical( |
377 EricMessageBox.critical( |
378 self, |
378 self, |
379 self.tr("Error downloading dictionary"), |
379 self.tr("Error downloading dictionary"), |
380 self.tr( |
380 self.tr( |
381 """<p>The downloaded dictionary archive is invalid.""" |
381 """<p>The downloaded dictionary archive is invalid.""" |
382 """ Skipping it.</p>""") |
382 """ Skipping it.</p>""") |