32 @param parent reference to the parent widget |
33 @param parent reference to the parent widget |
33 @type QWidget |
34 @type QWidget |
34 """ |
35 """ |
35 super().__init__(parent) |
36 super().__init__(parent) |
36 self.setupUi(self) |
37 self.setupUi(self) |
37 |
38 |
38 self.__lexer = lexer |
39 self.__lexer = lexer |
39 self.__style = style |
40 self.__style = style |
40 self.__substyle = substyle |
41 self.__substyle = substyle |
41 |
42 |
42 self.header.setText(self.tr("<h3>{0} - {1}</h3>").format( |
43 self.header.setText( |
43 self.__lexer.language(), self.__lexer.description(self.__style))) |
44 self.tr("<h3>{0} - {1}</h3>").format( |
|
45 self.__lexer.language(), self.__lexer.description(self.__style) |
|
46 ) |
|
47 ) |
44 if self.__substyle >= 0: |
48 if self.__substyle >= 0: |
45 # it's an edit operation |
49 # it's an edit operation |
46 self.descriptionEdit.setText( |
50 self.descriptionEdit.setText( |
47 self.__lexer.description(self.__style, self.__substyle)) |
51 self.__lexer.description(self.__style, self.__substyle) |
|
52 ) |
48 self.wordsEdit.setPlainText( |
53 self.wordsEdit.setPlainText( |
49 self.__lexer.words(self.__style, self.__substyle)) |
54 self.__lexer.words(self.__style, self.__substyle) |
50 |
55 ) |
|
56 |
51 def __updateOk(self): |
57 def __updateOk(self): |
52 """ |
58 """ |
53 Private slot to update the state of the OK button. |
59 Private slot to update the state of the OK button. |
54 """ |
60 """ |
55 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
61 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
56 bool(self.descriptionEdit.text().strip()) and |
62 bool(self.descriptionEdit.text().strip()) |
57 bool(self.wordsEdit.toPlainText().strip()) |
63 and bool(self.wordsEdit.toPlainText().strip()) |
58 ) |
64 ) |
59 |
65 |
60 @pyqtSlot(str) |
66 @pyqtSlot(str) |
61 def on_descriptionEdit_textChanged(self, txt): |
67 def on_descriptionEdit_textChanged(self, txt): |
62 """ |
68 """ |
63 Private slot handling changes of the description. |
69 Private slot handling changes of the description. |
64 |
70 |
65 @param txt text of the description |
71 @param txt text of the description |
66 @type str |
72 @type str |
67 """ |
73 """ |
68 self.__updateOk() |
74 self.__updateOk() |
69 |
75 |
70 @pyqtSlot() |
76 @pyqtSlot() |
71 def on_wordsEdit_textChanged(self): |
77 def on_wordsEdit_textChanged(self): |
72 """ |
78 """ |
73 Private slot handling changes of the word list. |
79 Private slot handling changes of the word list. |
74 """ |
80 """ |
75 self.__updateOk() |
81 self.__updateOk() |
76 |
82 |
77 @pyqtSlot() |
83 @pyqtSlot() |
78 def on_resetButton_clicked(self): |
84 def on_resetButton_clicked(self): |
79 """ |
85 """ |
80 Private slot to reset the dialog contents. |
86 Private slot to reset the dialog contents. |
81 """ |
87 """ |
82 ok = EricMessageBox.yesNo( |
88 ok = EricMessageBox.yesNo( |
83 self, |
89 self, |
84 self.tr("Reset Sub-Style Data"), |
90 self.tr("Reset Sub-Style Data"), |
85 self.tr("""Shall the entered sub-style data be reset?""")) |
91 self.tr("""Shall the entered sub-style data be reset?"""), |
|
92 ) |
86 if ok: |
93 if ok: |
87 if self.__substyle >= 0: |
94 if self.__substyle >= 0: |
88 self.descriptionEdit.setText( |
95 self.descriptionEdit.setText( |
89 self.__lexer.description(self.__style, self.__substyle)) |
96 self.__lexer.description(self.__style, self.__substyle) |
|
97 ) |
90 self.wordsEdit.setPlainText( |
98 self.wordsEdit.setPlainText( |
91 self.__lexer.words(self.__style, self.__substyle)) |
99 self.__lexer.words(self.__style, self.__substyle) |
|
100 ) |
92 else: |
101 else: |
93 self.descriptionEdit.clear() |
102 self.descriptionEdit.clear() |
94 self.wordsEdit.clear() |
103 self.wordsEdit.clear() |
95 |
104 |
96 @pyqtSlot() |
105 @pyqtSlot() |
97 def on_defaultButton_clicked(self): |
106 def on_defaultButton_clicked(self): |
98 """ |
107 """ |
99 Private slot to set the dialog contents to default values. |
108 Private slot to set the dialog contents to default values. |
100 """ |
109 """ |
101 filled = ( |
110 filled = bool(self.descriptionEdit.text().strip()) or bool( |
102 bool(self.descriptionEdit.text().strip()) or |
111 self.wordsEdit.toPlainText().strip() |
103 bool(self.wordsEdit.toPlainText().strip()) |
|
104 ) |
112 ) |
105 ok = ( |
113 ok = ( |
106 EricMessageBox.yesNo( |
114 EricMessageBox.yesNo( |
107 self, |
115 self, |
108 self.tr("Set Sub-Style Data to Default"), |
116 self.tr("Set Sub-Style Data to Default"), |
109 self.tr("""Shall the sub-style data be set to default""" |
117 self.tr( |
110 """ values?""")) |
118 """Shall the sub-style data be set to default""" """ values?""" |
111 if filled else |
119 ), |
112 True |
120 ) |
|
121 if filled |
|
122 else True |
113 ) |
123 ) |
114 if ok: |
124 if ok: |
115 if self.__substyle >= 0: |
125 if self.__substyle >= 0: |
116 self.descriptionEdit.setText(self.__lexer.defaultDescription( |
126 self.descriptionEdit.setText( |
117 self.__style, self.__substyle)) |
127 self.__lexer.defaultDescription(self.__style, self.__substyle) |
118 self.wordsEdit.setPlainText(self.__lexer.defaultWords( |
128 ) |
119 self.__style, self.__substyle)) |
129 self.wordsEdit.setPlainText( |
|
130 self.__lexer.defaultWords(self.__style, self.__substyle) |
|
131 ) |
120 else: |
132 else: |
121 self.descriptionEdit.clear() |
133 self.descriptionEdit.clear() |
122 self.wordsEdit.clear() |
134 self.wordsEdit.clear() |
123 |
135 |
124 def getData(self): |
136 def getData(self): |
125 """ |
137 """ |
126 Public method to get the entered data. |
138 Public method to get the entered data. |
127 |
139 |
128 @return tuple containing the sub-style description and words list. |
140 @return tuple containing the sub-style description and words list. |
129 @rtype tuple of (str, str) |
141 @rtype tuple of (str, str) |
130 """ |
142 """ |
131 return ( |
143 return ( |
132 self.descriptionEdit.text().strip(), |
144 self.descriptionEdit.text().strip(), |