Preferences/ConfigurationPages/WebBrowserSpellCheckingPage.py

changeset 5870
82e04c70f969
parent 5868
c1a98c164cd3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5869:70709a460358 5870:82e04c70f969
59 QLibraryInfo.location(QLibraryInfo.DataPath) + 59 QLibraryInfo.location(QLibraryInfo.DataPath) +
60 "/qtwebengine_dictionaries"), 60 "/qtwebengine_dictionaries"),
61 } 61 }
62 self.spellCheckDictionaryDirectoriesEdit.setPlainText( 62 self.spellCheckDictionaryDirectoriesEdit.setPlainText(
63 "\n".join(self.__dictionaryDirectories)) 63 "\n".join(self.__dictionaryDirectories))
64 # try to create these directories, if they don't exist
65 for directory in self.__dictionaryDirectories:
66 if not os.path.exists(directory):
67 try:
68 os.makedirs(directory)
69 except os.error:
70 # ignore it
71 pass
64 72
65 self.__writeableDirectories = [] 73 self.__writeableDirectories = []
66 for directory in self.__dictionaryDirectories: 74 for directory in self.__dictionaryDirectories:
67 if os.access(directory, os.W_OK): 75 if os.access(directory, os.W_OK):
68 self.__writeableDirectories.append(directory) 76 self.__writeableDirectories.append(directory)
69 self.installButton.setEnabled(bool(self.__writeableDirectories)) 77 self.manageDictionariesButton.setEnabled(
78 bool(self.__writeableDirectories))
70 79
71 self.__populateDictionariesList() 80 self.__populateDictionariesList()
72 81
73 def __populateDictionariesList(self): 82 def __populateDictionariesList(self):
74 """ 83 """
107 116
108 if self.spellCheckLanguagesList.count(): 117 if self.spellCheckLanguagesList.count():
109 self.noLanguagesLabel.hide() 118 self.noLanguagesLabel.hide()
110 self.spellCheckLanguagesList.show() 119 self.spellCheckLanguagesList.show()
111 else: 120 else:
121 # no dictionaries available, disable spell checking
112 self.noLanguagesLabel.show() 122 self.noLanguagesLabel.show()
113 self.spellCheckLanguagesList.hide() 123 self.spellCheckLanguagesList.hide()
124 self.spellCheckEnabledCheckBox.setChecked(False)
114 125
115 def save(self): 126 def save(self):
116 """ 127 """
117 Public slot to save the Help Viewers configuration. 128 Public slot to save the Help Viewers configuration.
118 """ 129 """
156 lang = QLocale.languageToString(loc.language()) 167 lang = QLocale.languageToString(loc.language())
157 languageString = "{0}/{1} [{2}]".format(lang, country, language) 168 languageString = "{0}/{1} [{2}]".format(lang, country, language)
158 return languageString 169 return languageString
159 170
160 @pyqtSlot() 171 @pyqtSlot()
161 def on_installButton_clicked(self): 172 def on_manageDictionariesButton_clicked(self):
162 """ 173 """
163 Private slot to install spell checking dictionaries. 174 Private slot to manage spell checking dictionaries.
164 """ 175 """
165 from WebBrowser.SpellCheck.InstallDictionariesDialog import \ 176 from WebBrowser.SpellCheck.ManageDictionariesDialog import \
166 InstallDictionariesDialog 177 ManageDictionariesDialog
167 dlg = InstallDictionariesDialog(self.__writeableDirectories, self) 178 dlg = ManageDictionariesDialog(self.__writeableDirectories, self)
168 dlg.exec_() 179 dlg.exec_()
169 # TODO: Implement this dialog
170 180
171 self.__populateDictionariesList() 181 self.__populateDictionariesList()
172 182
173 183
174 def create(dlg): 184 def create(dlg):

eric ide

mercurial