eric6/WebBrowser/SpellCheck/ManageDictionariesDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7946
6901746220fc
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to install spell checking dictionaries.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
10 import os
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
11 import io
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
12 import zipfile
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
13 import glob
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
14 import shutil
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
15
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from PyQt5.QtCore import pyqtSlot, Qt, QUrl
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
17 from PyQt5.QtWidgets import (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
18 QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
19 )
7946
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
20 from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from E5Gui import E5MessageBox
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
24 from .Ui_ManageDictionariesDialog import Ui_ManageDictionariesDialog
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from WebBrowser.WebBrowserWindow import WebBrowserWindow
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Preferences
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
31 class ManageDictionariesDialog(QDialog, Ui_ManageDictionariesDialog):
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Class implementing a dialog to install spell checking dictionaries.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 FilenameRole = Qt.UserRole
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
36 UrlRole = Qt.UserRole + 1
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
37 DocumentationDirRole = Qt.UserRole + 2
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
38 LocalesRole = Qt.UserRole + 3
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 def __init__(self, writeableDirectories, parent=None):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Constructor
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @param writeableDirectories list of writable directories
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @type list of str
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param parent reference to the parent widget
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @type QWidget
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
49 super(ManageDictionariesDialog, self).__init__(parent)
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setupUi(self)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__refreshButton = self.buttonBox.addButton(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.tr("Refresh"), QDialogButtonBox.ActionRole)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__installButton = self.buttonBox.addButton(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.tr("Install Selected"), QDialogButtonBox.ActionRole)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__installButton.setEnabled(False)
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
57 self.__uninstallButton = self.buttonBox.addButton(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
58 self.tr("Uninstall Selected"), QDialogButtonBox.ActionRole)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
59 self.__uninstallButton.setEnabled(False)
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__cancelButton = self.buttonBox.addButton(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.tr("Cancel"), QDialogButtonBox.ActionRole)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__cancelButton.setEnabled(False)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.locationComboBox.addItems(writeableDirectories)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.dictionariesUrlEdit.setText(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Preferences.getWebBrowser("SpellCheckDictionariesUrl"))
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__replies = []
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__downloadCancelled = False
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__dictionariesToDownload = []
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__populateList()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 @pyqtSlot(QAbstractButton)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def on_buttonBox_clicked(self, button):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Private slot to handle the click of a button of the button box.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param button reference to the button pressed
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @type QAbstractButton
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if button == self.__refreshButton:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__populateList()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 elif button == self.__cancelButton:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__downloadCancel()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 elif button == self.__installButton:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__installSelected()
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
90 elif button == self.__uninstallButton:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
91 self.__uninstallSelected()
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @pyqtSlot()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def on_dictionariesList_itemSelectionChanged(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 Private slot to handle a change of the selection.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__installButton.setEnabled(
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
99 self.locationComboBox.count() > 0 and
7946
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
100 len(self.dictionariesList.selectedItems()) > 0
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
101 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
102
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
103 self.__uninstallButton.setEnabled(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
104 self.locationComboBox.count() > 0 and
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
105 len([itm
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
106 for itm in self.dictionariesList.selectedItems()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
107 if itm.checkState() == Qt.Checked
5873
331a5ece2c32 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5872
diff changeset
108 ])
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
109 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
110
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
111 @pyqtSlot(bool)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
112 def on_dictionariesUrlEditButton_toggled(self, checked):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
113 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
114 Private slot to set the read only status of the dictionaries URL line
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
115 edit.
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
116
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
117 @param checked state of the push button (boolean)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
118 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
119 self.dictionariesUrlEdit.setReadOnly(not checked)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
120
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
121 @pyqtSlot(str)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
122 def on_locationComboBox_currentTextChanged(self, txt):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
123 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
124 Private slot to handle a change of the installation location.
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
125
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
126 @param txt installation location
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
127 @type str
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
128 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
129 self.__checkInstalledDictionaries()
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 def __populateList(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 Private method to populate the list of available plugins.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.dictionariesList.clear()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.downloadProgress.setValue(0)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
138 url = self.dictionariesUrlEdit.text()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
139
7946
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
140 self.__refreshButton.setEnabled(False)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
141 self.__installButton.setEnabled(False)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
142 self.__uninstallButton.setEnabled(False)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
143 self.__cancelButton.setEnabled(True)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
144
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
145 self.statusLabel.setText(url)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
146
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
147 self.__downloadCancelled = False
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
148
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
149 request = QNetworkRequest(QUrl(url))
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
150 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
151 QNetworkRequest.AlwaysNetwork)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
152 reply = WebBrowserWindow.networkManager().get(request)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
153 reply.finished.connect(
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
154 lambda: self.__listFileDownloaded(reply))
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
155 reply.downloadProgress.connect(self.__downloadProgress)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
156 self.__replies.append(reply)
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
158 def __listFileDownloaded(self, reply):
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 Private method called, after the dictionaries list file has been
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 downloaded from the Internet.
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
162
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
163 @param reply reference to the network reply
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
164 @type QNetworkReply
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.__refreshButton.setEnabled(True)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.__cancelButton.setEnabled(False)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
169 self.downloadProgress.setValue(0)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
170
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 if reply in self.__replies:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 self.__replies.remove(reply)
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
173 reply.deleteLater()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
174
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 if reply.error() != QNetworkReply.NoError:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if not self.__downloadCancelled:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 E5MessageBox.warning(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self,
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.tr("Error downloading dictionaries list"),
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.tr(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """<p>Could not download the dictionaries list"""
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """ from {0}.</p><p>Error: {1}</p>"""
6469
70855c97dd09 ManageDictionariesDialog: fixed an issue referencing a non existing widget (silly copy&paste error).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6121
diff changeset
183 ).format(self.dictionariesUrlEdit.text(),
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 reply.errorString())
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 )
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.downloadProgress.setValue(0)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 return
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 listFileData = reply.readAll()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 # extract the dictionaries
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
192 from E5XML.SpellCheckDictionariesReader import (
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 SpellCheckDictionariesReader
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
194 )
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 reader = SpellCheckDictionariesReader(listFileData, self.addEntry)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 reader.readXML()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 url = Preferences.getWebBrowser("SpellCheckDictionariesUrl")
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 if url != self.dictionariesUrlEdit.text():
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.dictionariesUrlEdit.setText(url)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 E5MessageBox.warning(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self,
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.tr("Dictionaries URL Changed"),
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.tr(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 """The URL of the spell check dictionaries has"""
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """ changed. Select the "Refresh" button to get"""
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
206 """ the new dictionaries list."""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
207 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
208 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
209
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
210 if self.locationComboBox.count() == 0:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
211 # no writable locations available
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
212 E5MessageBox.warning(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
213 self,
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
214 self.tr("Error installing dictionaries"),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
215 self.tr(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
216 """<p>None of the dictionary locations is writable by"""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
217 """ you. Please download required dictionaries manually"""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
218 """ and install them as administrator.</p>"""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
219 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
220 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
221
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
222 self.__checkInstalledDictionaries()
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 def __downloadCancel(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 Private slot to cancel the current download.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 if self.__replies:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 reply = self.__replies[0]
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.__downloadCancelled = True
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.__dictionariesToDownload = []
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 reply.abort()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 def __downloadProgress(self, done, total):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 Private slot to show the download progress.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 @param done number of bytes downloaded so far
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 @type int
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 @param total total bytes to be downloaded
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 @type int
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 if total:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 self.downloadProgress.setMaximum(total)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self.downloadProgress.setValue(done)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
247 def addEntry(self, short, filename, url, documentationDir, locales):
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 Public method to add an entry to the list.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 @param short data for the description field
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 @type str
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 @param filename data for the filename field
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 @type str
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
255 @param url download URL for the dictionary entry
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
256 @type str
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
257 @param documentationDir name of the directory containing the
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
258 dictionary documentation
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
259 @type str
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
260 @param locales list of locales
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
261 @type list of str
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 """
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
263 itm = QListWidgetItem(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
264 self.tr("{0} ({1})").format(short, " ".join(locales)),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
265 self.dictionariesList)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
266 itm.setCheckState(Qt.Unchecked)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
267
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
268 itm.setData(ManageDictionariesDialog.FilenameRole, filename)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
269 itm.setData(ManageDictionariesDialog.UrlRole, url)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
270 itm.setData(ManageDictionariesDialog.DocumentationDirRole,
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
271 documentationDir)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
272 itm.setData(ManageDictionariesDialog.LocalesRole, locales)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
273
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
274 def __checkInstalledDictionaries(self):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
275 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
276 Private method to check all installed dictionaries.
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
277
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
278 Note: A dictionary is assumed to be installed, if at least one of its
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
279 binary dictionaries (*.bdic) is found in the selected dictionaries
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
280 location.
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
281 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
282 if self.locationComboBox.currentText():
5873
331a5ece2c32 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5872
diff changeset
283 installedLocales = {
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
284 os.path.splitext(os.path.basename(dic))[0]
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
285 for dic in glob.glob(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
286 os.path.join(self.locationComboBox.currentText(), "*.bdic")
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
287 )
5873
331a5ece2c32 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5872
diff changeset
288 }
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
289
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
290 for row in range(self.dictionariesList.count()):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
291 itm = self.dictionariesList.item(row)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
292 locales = set(itm.data(ManageDictionariesDialog.LocalesRole))
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
293 if locales.intersection(installedLocales):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
294 itm.setCheckState(Qt.Checked)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
295 else:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
296 itm.setCheckState(Qt.Unchecked)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
297 else:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
298 for row in range(self.dictionariesList.count()):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
299 itm = self.dictionariesList.item(row)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
300 itm.setCheckState(Qt.Unchecked)
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 def __installSelected(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 Private method to install the selected dictionaries.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
7946
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
306 if bool(self.locationComboBox.currentText()):
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
307 self.__dictionariesToDownload = [
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
308 itm.data(ManageDictionariesDialog.UrlRole)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
309 for itm in self.dictionariesList.selectedItems()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
310 ]
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
311
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
312 self.__refreshButton.setEnabled(False)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
313 self.__installButton.setEnabled(False)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
314 self.__uninstallButton.setEnabled(False)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
315 self.__cancelButton.setEnabled(True)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
316
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
317 self.__downloadCancelled = False
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
318
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
319 self.__downloadDictionary()
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 def __downloadDictionary(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 Private slot to download a dictionary.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 """
7946
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
325 if self.__dictionariesToDownload:
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
326 url = self.__dictionariesToDownload.pop(0)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
327 self.statusLabel.setText(url)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
328
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
329 self.__downloadCancelled = False
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
330
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
331 request = QNetworkRequest(QUrl(url))
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
332 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
333 QNetworkRequest.AlwaysNetwork)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
334 reply = WebBrowserWindow.networkManager().get(request)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
335 reply.finished.connect(
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
336 lambda: self.__installDictionary(reply))
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
337 reply.downloadProgress.connect(self.__downloadProgress)
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
338 self.__replies.append(reply)
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
339 else:
7946
6901746220fc Removed code depending upon the automatic online check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
340 self.__installationFinished()
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
341
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
342 self.__installationFinished()
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
344 def __installDictionary(self, reply):
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 Private slot to install the downloaded dictionary.
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
347
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
348 @param reply reference to the network reply
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
349 @type QNetworkReply
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
351 if reply in self.__replies:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
352 self.__replies.remove(reply)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
353 reply.deleteLater()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
354
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
355 if reply.error() != QNetworkReply.NoError:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
356 if not self.__downloadCancelled:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
357 E5MessageBox.warning(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
358 self,
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
359 self.tr("Error downloading dictionary file"),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
360 self.tr(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
361 """<p>Could not download the requested dictionary"""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
362 """ file from {0}.</p><p>Error: {1}</p>"""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
363 ).format(reply.url(), reply.errorString())
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
364 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
365 self.downloadProgress.setValue(0)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
366 return
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
368 archiveData = reply.readAll()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
369 archiveFile = io.BytesIO(bytes(archiveData))
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
370 archive = zipfile.ZipFile(archiveFile, "r")
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
371 if archive.testzip() is not None:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
372 E5MessageBox.critical(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
373 self,
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
374 self.tr("Error downloading dictionary"),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
375 self.tr(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
376 """<p>The downloaded dictionary archive is invalid."""
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
377 """ Skipping it.</p>""")
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
378 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
379 else:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
380 installDir = self.locationComboBox.currentText()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
381 archive.extractall(installDir)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
382
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
383 if self.__dictionariesToDownload:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
384 self.__downloadDictionary()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
385 else:
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 self.__installationFinished()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 def __installationFinished(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 Private method called after all selected dictionaries have been
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 installed.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 """
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
393 self.__refreshButton.setEnabled(True)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
394 self.__cancelButton.setEnabled(False)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
395
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
396 self.dictionariesList.clearSelection()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
397 self.downloadProgress.setValue(0)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
398
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
399 self.__checkInstalledDictionaries()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
400
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
401 def __uninstallSelected(self):
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
402 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
403 Private method to uninstall the selected dictionaries.
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
404 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
405 installLocation = self.locationComboBox.currentText()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
406 if not installLocation:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
407 return
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
408
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
409 itemsToDelete = [
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
410 itm
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
411 for itm in self.dictionariesList.selectedItems()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
412 if itm.checkState() == Qt.Checked
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
413 ]
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
414 for itm in itemsToDelete:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
415 documentationDir = itm.data(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
416 ManageDictionariesDialog.DocumentationDirRole)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
417 shutil.rmtree(os.path.join(installLocation, documentationDir),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
418 True)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
419
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
420 locales = itm.data(ManageDictionariesDialog.LocalesRole)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
421 for locale in locales:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
422 bdic = os.path.join(installLocation, locale + ".bdic")
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
423 try:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
424 os.remove(bdic)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
425 except OSError:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
426 # ignore silently
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
427 pass
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
428
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
429 self.dictionariesList.clearSelection()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
430
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
431 self.__checkInstalledDictionaries()

eric ide

mercurial