eric6/Project/SpellingPropertiesDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2008 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Spelling Properties dialog.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtWidgets import QDialog
13
14 from E5Gui.E5PathPicker import E5PathPickerModes
15
16 from .Ui_SpellingPropertiesDialog import Ui_SpellingPropertiesDialog
17
18 import Preferences
19
20
21 class SpellingPropertiesDialog(QDialog, Ui_SpellingPropertiesDialog):
22 """
23 Class implementing the Spelling Properties dialog.
24 """
25 def __init__(self, project, new, parent):
26 """
27 Constructor
28
29 @param project reference to the project object
30 @param new flag indicating the generation of a new project
31 @param parent parent widget of this dialog (QWidget)
32 """
33 super(SpellingPropertiesDialog, self).__init__(parent)
34 self.setupUi(self)
35
36 self.pwlPicker.setMode(E5PathPickerModes.SaveFileMode)
37 self.pwlPicker.setDefaultDirectory(project.ppath)
38 self.pwlPicker.setFilters(self.tr(
39 "Dictionary File (*.dic);;All Files (*)"))
40
41 self.pelPicker.setMode(E5PathPickerModes.SaveFileMode)
42 self.pelPicker.setDefaultDirectory(project.ppath)
43 self.pelPicker.setFilters(self.tr(
44 "Dictionary File (*.dic);;All Files (*)"))
45
46 self.project = project
47 self.parent = parent
48
49 from QScintilla.SpellChecker import SpellChecker
50 self.spellingComboBox.addItem(self.tr("<default>"))
51 self.spellingComboBox.addItems(
52 sorted(SpellChecker.getAvailableLanguages()))
53
54 if not new:
55 self.initDialog()
56
57 msh = self.minimumSizeHint()
58 self.resize(max(self.width(), msh.width()), msh.height())
59
60 def initDialog(self):
61 """
62 Public method to initialize the dialogs data.
63 """
64 index = self.spellingComboBox.findText(
65 self.project.pdata["SPELLLANGUAGE"])
66 if index == -1:
67 index = 0
68 self.spellingComboBox.setCurrentIndex(index)
69 if self.project.pdata["SPELLWORDS"]:
70 self.pwlPicker.setText(self.project.pdata["SPELLWORDS"])
71 if self.project.pdata["SPELLEXCLUDES"]:
72 self.pelPicker.setText(self.project.pdata["SPELLEXCLUDES"])
73
74 def storeData(self):
75 """
76 Public method to store the entered/modified data.
77 """
78 if self.spellingComboBox.currentIndex() == 0:
79 self.project.pdata["SPELLLANGUAGE"] = \
80 Preferences.getEditor("SpellCheckingDefaultLanguage")
81 else:
82 self.project.pdata["SPELLLANGUAGE"] = \
83 self.spellingComboBox.currentText()
84 self.project.pdata["SPELLWORDS"] = \
85 self.project.getRelativePath(self.pwlPicker.text())
86 self.project.pdata["SPELLEXCLUDES"] = \
87 self.project.getRelativePath(self.pelPicker.text())

eric ide

mercurial