Dictionary path bug fix & added warning whenever a selected dictionary isn't installed

This commit is contained in:
Michal Siedlaczek 2017-08-20 10:39:09 -07:00
parent e61e6b124e
commit cf229cb9c8
2 changed files with 11 additions and 4 deletions

View File

@ -79,7 +79,7 @@ class Language:
def get_dictionary_dir(): def get_dictionary_dir():
"""Return the path to the QtWebEngine's dictionaries directory.""" """Return the path to the QtWebEngine's dictionaries directory."""
return os.path.join(QLibraryInfo.location(QLibraryInfo.DataPath), return os.path.join(QLibraryInfo.location(QLibraryInfo.DataPath),
'/qtwebengine_dictionaries') 'qtwebengine_dictionaries')
def get_language_list_file(): def get_language_list_file():

View File

@ -140,9 +140,16 @@ class DictionaryLanguageSetter(DefaultProfileSetter):
if settings is not None: if settings is not None:
raise ValueError("'settings' may not be set with " raise ValueError("'settings' may not be set with "
"DictionaryLanguageSetter!") "DictionaryLanguageSetter!")
files = [lang.file[:-5] installed_langs = dict([(lang.code, lang.file)
for lang in get_installed_languages() if lang.code in value] for lang in get_installed_languages()])
super()._set(files, settings) lang_files = []
for lang_code in value:
if lang_code in installed_langs:
lang_files.append(installed_langs[lang_code][:-5])
else:
message.warning('Language {} is not installed.'
.format(lang_code))
super()._set(lang_files, settings)
def _init_stylesheet(profile): def _init_stylesheet(profile):