eric6/WebBrowser/SpellCheck/ManageDictionariesDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 7946
6901746220fc
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e 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 )
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
20 from PyQt5.QtNetwork import (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 QNetworkConfigurationManager, QNetworkRequest, QNetworkReply
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
22 )
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 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
25
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
26 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
27
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 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
29
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import Preferences
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
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
33 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
34 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 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
36 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 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
38 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
39 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
40 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
41
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 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
43 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Constructor
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @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
47 @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
48 @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
49 @type QWidget
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
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
51 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
52 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
53
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
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.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
67
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 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
69 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
70
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 if Preferences.getUI("DynamicOnlineCheck"):
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
72 self.__networkConfigurationManager = QNetworkConfigurationManager(
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
73 self)
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__onlineStateChanged(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__networkConfigurationManager.isOnline())
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__networkConfigurationManager.onlineStateChanged.connect(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__onlineStateChanged)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 else:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__networkConfigurationManager = None
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__onlineStateChanged(True)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__replies = []
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 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
84 self.__dictionariesToDownload = []
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__populateList()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @pyqtSlot(bool)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 def __onlineStateChanged(self, online):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 Private slot handling online state changes.
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 @param online flag indicating the online status
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 @type bool
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 self.__refreshButton.setEnabled(online)
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
97
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 if online:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 msg = self.tr("Network Status: online")
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 else:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 msg = self.tr("Network Status: offline")
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.statusLabel.setText(msg)
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
103
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.on_dictionariesList_itemSelectionChanged()
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def __isOnline(self):
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Private method to check the online status.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @return flag indicating the online status
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @rtype bool
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 if self.__networkConfigurationManager is not None:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 return self.__networkConfigurationManager.isOnline()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 else:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 return True
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @pyqtSlot(QAbstractButton)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 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
120 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 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
122
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 @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
124 @type QAbstractButton
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 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
127 self.__populateList()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 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
129 self.__downloadCancel()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 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
131 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
132 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
133 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
134
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 @pyqtSlot()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 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
137 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 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
139 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 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
141 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
142 len(self.dictionariesList.selectedItems()) > 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
143 self.__isOnline()
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
144 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
145
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
146 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
147 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
148 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
149 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
150 if itm.checkState() == Qt.Checked
5873
331a5ece2c32 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5872
diff changeset
151 ])
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
152 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
153
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
154 @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
155 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
156 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
157 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
158 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
159
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
160 @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
161 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
162 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
163
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
164 @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
165 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
166 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
167 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
168
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 @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
170 @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
171 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
172 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
173
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 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
175 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 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
177 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 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
179 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
180
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
181 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
182
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 if self.__isOnline():
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.__refreshButton.setEnabled(False)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 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
186 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
187 self.__cancelButton.setEnabled(True)
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 self.statusLabel.setText(url)
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 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
192
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 request = QNetworkRequest(QUrl(url))
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 QNetworkRequest.AlwaysNetwork)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 reply = WebBrowserWindow.networkManager().get(request)
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
197 reply.finished.connect(
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
198 lambda: self.__listFileDownloaded(reply))
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 reply.downloadProgress.connect(self.__downloadProgress)
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 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
201 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
202 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
203 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
204 self.tr("Error populating list of 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
205 self.tr(
5872
c9a08656feac Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5870
diff changeset
206 """<p>Could not download the dictionaries list"""
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
207 """ 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
208 ).format(url, self.tr("Computer is offline.")))
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
210 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
211 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 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
213 downloaded from the Internet.
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
214
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
215 @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
216 @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
217 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 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
220 self.__onlineStateChanged(self.__isOnline())
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
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
222 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
223
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 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
225 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
226 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
227
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 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
229 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
230 E5MessageBox.warning(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self,
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 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
233 self.tr(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """<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
235 """ 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
236 ).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
237 reply.errorString())
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 )
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 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
240 return
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 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
243
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 # extract the dictionaries
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
245 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
246 SpellCheckDictionariesReader
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
247 )
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 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
249 reader.readXML()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 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
251 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
252 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
253 E5MessageBox.warning(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 self,
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 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
256 self.tr(
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 """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
258 """ 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
259 """ 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
260 )
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 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
262
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 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
264 # 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
265 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
266 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
267 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
268 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
269 """<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
270 """ 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
271 """ 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
272 )
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
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 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
276
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 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
278 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 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
280 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 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
282 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
283 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
284 self.__dictionariesToDownload = []
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 reply.abort()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 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
288 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 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
290
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 @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
292 @type int
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 @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
294 @type int
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 if total:
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 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
298 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
299
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
300 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
301 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 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
303
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 @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
305 @type str
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @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
307 @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
308 @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
309 @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
310 @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
311 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
312 @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
313 @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
314 @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
315 """
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
316 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
317 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
318 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
319 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
320
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
321 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
322 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
323 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
324 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
325 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
326
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
327 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
328 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
329 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
330
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
331 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
332 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
333 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
334 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
335 if self.locationComboBox.currentText():
5873
331a5ece2c32 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5872
diff changeset
336 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
337 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
338 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
339 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
340 )
5873
331a5ece2c32 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5872
diff changeset
341 }
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
342
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 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
356 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 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
358 """
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
359 if self.__isOnline() and bool(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
360 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
361 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
362 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
363 ]
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.__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
366 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
367 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
368 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
369
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 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
371
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 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
373
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 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
375 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 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
377 """
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
378 if self.__isOnline():
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 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
380 url = self.__dictionariesToDownload.pop(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
381 self.statusLabel.setText(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
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 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
384
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 request = QNetworkRequest(QUrl(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
386 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
387 QNetworkRequest.AlwaysNetwork)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
388 reply = WebBrowserWindow.networkManager().get(request)
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
389 reply.finished.connect(
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
390 lambda: self.__installDictionary(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
391 reply.downloadProgress.connect(self.__downloadProgress)
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
392 self.__replies.append(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
393 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
394 self.__installationFinished()
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 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
396 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
397 self,
5872
c9a08656feac Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5870
diff changeset
398 self.tr("Error downloading dictionary file"),
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
399 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
400 """<p>Could not download the requested 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
401 """ 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
402 ).format(url, self.tr("Computer is offline.")))
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
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 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
405
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
406 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
407 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 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
409
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
410 @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
411 @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
412 """
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
413 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
414 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
415 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
416
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 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
418 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
419 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
420 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
421 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
422 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
423 """<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
424 """ 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
425 ).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
426 )
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 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
428 return
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429
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
430 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
431 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
432 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
433 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
434 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
435 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
436 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
437 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
438 """<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
439 """ 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
440 )
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
441 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
442 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
443 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
444
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
445 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
446 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
447 else:
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 self.__installationFinished()
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 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
451 """
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 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
453 installed.
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 """
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
455 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
456 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
457 self.__onlineStateChanged(self.__isOnline())
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
458
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
459 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
460 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
461
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
462 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
463
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
464 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
465 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
466 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
467 """
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
468 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
469 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
470 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
471
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
472 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
473 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
474 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
475 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
476 ]
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
477 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
478 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
479 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
480 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
481 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
482
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
483 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
484 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
485 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
486 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
487 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
488 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
489 # 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
490 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
491
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
492 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
493
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
494 self.__checkInstalledDictionaries()

eric ide

mercurial