|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Plugins.UiExtensionPlugins.Translator.TranslatorWidget</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Plugins.UiExtensionPlugins.Translator.TranslatorWidget</h1> |
|
23 <p> |
|
24 Module implementing the translator widget. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>None</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#TranslatorWidget">TranslatorWidget</a></td> |
|
34 <td>Class implementing the translator widget.</td> |
|
35 </tr> |
|
36 </table> |
|
37 <h3>Functions</h3> |
|
38 <table> |
|
39 <tr><td>None</td></tr> |
|
40 </table> |
|
41 <hr /><hr /> |
|
42 <a NAME="TranslatorWidget" ID="TranslatorWidget"></a> |
|
43 <h2>TranslatorWidget</h2> |
|
44 <p> |
|
45 Class implementing the translator widget. |
|
46 </p> |
|
47 <h3>Derived from</h3> |
|
48 QWidget, Ui_TranslatorWidget |
|
49 <h3>Class Attributes</h3> |
|
50 <table> |
|
51 <tr><td>None</td></tr> |
|
52 </table> |
|
53 <h3>Class Methods</h3> |
|
54 <table> |
|
55 <tr><td>None</td></tr> |
|
56 </table> |
|
57 <h3>Methods</h3> |
|
58 <table> |
|
59 <tr> |
|
60 <td><a href="#TranslatorWidget.__init__">TranslatorWidget</a></td> |
|
61 <td>Constructor</td> |
|
62 </tr><tr> |
|
63 <td><a href="#TranslatorWidget.__availableTranslationsLoaded">__availableTranslationsLoaded</a></td> |
|
64 <td>Private slot to handle the availability of translations.</td> |
|
65 </tr><tr> |
|
66 <td><a href="#TranslatorWidget.__engineComboBoxCurrentIndexChanged">__engineComboBoxCurrentIndexChanged</a></td> |
|
67 <td>Private slot to handle the selection of a translation service.</td> |
|
68 </tr><tr> |
|
69 <td><a href="#TranslatorWidget.__ensureTranslationEngineReady">__ensureTranslationEngineReady</a></td> |
|
70 <td>Private slot to ensure, that the currently selected translation engine is ready.</td> |
|
71 </tr><tr> |
|
72 <td><a href="#TranslatorWidget.__mediaPlayerStateChanged">__mediaPlayerStateChanged</a></td> |
|
73 <td>Private slot handling changes of the media player state.</td> |
|
74 </tr><tr> |
|
75 <td><a href="#TranslatorWidget.__originalLanguage">__originalLanguage</a></td> |
|
76 <td>Private method to return the code of the selected original language.</td> |
|
77 </tr><tr> |
|
78 <td><a href="#TranslatorWidget.__pronounce">__pronounce</a></td> |
|
79 <td>Private method to pronounce the given text.</td> |
|
80 </tr><tr> |
|
81 <td><a href="#TranslatorWidget.__translate">__translate</a></td> |
|
82 <td>Private method to translate the given text.</td> |
|
83 </tr><tr> |
|
84 <td><a href="#TranslatorWidget.__translationLanguage">__translationLanguage</a></td> |
|
85 <td>Private method to return the code of the selected translation language.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#TranslatorWidget.__updateClearButton">__updateClearButton</a></td> |
|
88 <td>Private slot to set the state of the clear button.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#TranslatorWidget.__updateEngines">__updateEngines</a></td> |
|
91 <td>Private slot to update the engines combo box.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#TranslatorWidget.__updateLanguages">__updateLanguages</a></td> |
|
94 <td>Private slot to update the language combo boxes.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#TranslatorWidget.__updatePronounceButtons">__updatePronounceButtons</a></td> |
|
97 <td>Private slot to set the state of the pronounce buttons.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#TranslatorWidget.__updateTranslateButton">__updateTranslateButton</a></td> |
|
100 <td>Private slot to set the state of the translate button.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#TranslatorWidget.on_clearButton_clicked">on_clearButton_clicked</a></td> |
|
103 <td>Private slot to clear the text fields.</td> |
|
104 </tr><tr> |
|
105 <td><a href="#TranslatorWidget.on_origEdit_textChanged">on_origEdit_textChanged</a></td> |
|
106 <td>Private slot to handle changes of the original text.</td> |
|
107 </tr><tr> |
|
108 <td><a href="#TranslatorWidget.on_origLanguageComboBox_currentIndexChanged">on_origLanguageComboBox_currentIndexChanged</a></td> |
|
109 <td>Private slot to handle the selection of the original language.</td> |
|
110 </tr><tr> |
|
111 <td><a href="#TranslatorWidget.on_preferencesButton_clicked">on_preferencesButton_clicked</a></td> |
|
112 <td>Private slot to open the Translator configuration page.</td> |
|
113 </tr><tr> |
|
114 <td><a href="#TranslatorWidget.on_pronounceOrigButton_clicked">on_pronounceOrigButton_clicked</a></td> |
|
115 <td>Private slot to pronounce the original text.</td> |
|
116 </tr><tr> |
|
117 <td><a href="#TranslatorWidget.on_pronounceTransButton_clicked">on_pronounceTransButton_clicked</a></td> |
|
118 <td>Private slot to pronounce the translated text.</td> |
|
119 </tr><tr> |
|
120 <td><a href="#TranslatorWidget.on_swapButton_clicked">on_swapButton_clicked</a></td> |
|
121 <td>Private slot to swap the languages.</td> |
|
122 </tr><tr> |
|
123 <td><a href="#TranslatorWidget.on_transEdit_textChanged">on_transEdit_textChanged</a></td> |
|
124 <td>Private slot to handle changes of the translation text.</td> |
|
125 </tr><tr> |
|
126 <td><a href="#TranslatorWidget.on_transLanguageComboBox_currentIndexChanged">on_transLanguageComboBox_currentIndexChanged</a></td> |
|
127 <td>Private slot to handle the selection of the translation language.</td> |
|
128 </tr><tr> |
|
129 <td><a href="#TranslatorWidget.on_translateButton_clicked">on_translateButton_clicked</a></td> |
|
130 <td>Private slot to translate the entered text.</td> |
|
131 </tr> |
|
132 </table> |
|
133 <h3>Static Methods</h3> |
|
134 <table> |
|
135 <tr><td>None</td></tr> |
|
136 </table> |
|
137 <a NAME="TranslatorWidget.__init__" ID="TranslatorWidget.__init__"></a> |
|
138 <h4>TranslatorWidget (Constructor)</h4> |
|
139 <b>TranslatorWidget</b>(<i>plugin, translator, parent=None</i>) |
|
140 <p> |
|
141 Constructor |
|
142 </p><dl> |
|
143 <dt><i>plugin</i></dt> |
|
144 <dd> |
|
145 reference to the plugin object (TranslatorPlugin) |
|
146 </dd><dt><i>translator</i></dt> |
|
147 <dd> |
|
148 reference to the translator object (Translator) |
|
149 </dd><dt><i>parent</i></dt> |
|
150 <dd> |
|
151 reference to the parent widget (QWidget) |
|
152 </dd> |
|
153 </dl><a NAME="TranslatorWidget.__availableTranslationsLoaded" ID="TranslatorWidget.__availableTranslationsLoaded"></a> |
|
154 <h4>TranslatorWidget.__availableTranslationsLoaded</h4> |
|
155 <b>__availableTranslationsLoaded</b>(<i></i>) |
|
156 <p> |
|
157 Private slot to handle the availability of translations. |
|
158 </p><a NAME="TranslatorWidget.__engineComboBoxCurrentIndexChanged" ID="TranslatorWidget.__engineComboBoxCurrentIndexChanged"></a> |
|
159 <h4>TranslatorWidget.__engineComboBoxCurrentIndexChanged</h4> |
|
160 <b>__engineComboBoxCurrentIndexChanged</b>(<i>index</i>) |
|
161 <p> |
|
162 Private slot to handle the selection of a translation service. |
|
163 </p><dl> |
|
164 <dt><i>index</i> (int)</dt> |
|
165 <dd> |
|
166 current index |
|
167 </dd> |
|
168 </dl><a NAME="TranslatorWidget.__ensureTranslationEngineReady" ID="TranslatorWidget.__ensureTranslationEngineReady"></a> |
|
169 <h4>TranslatorWidget.__ensureTranslationEngineReady</h4> |
|
170 <b>__ensureTranslationEngineReady</b>(<i></i>) |
|
171 <p> |
|
172 Private slot to ensure, that the currently selected translation engine |
|
173 is ready. |
|
174 </p><a NAME="TranslatorWidget.__mediaPlayerStateChanged" ID="TranslatorWidget.__mediaPlayerStateChanged"></a> |
|
175 <h4>TranslatorWidget.__mediaPlayerStateChanged</h4> |
|
176 <b>__mediaPlayerStateChanged</b>(<i>state</i>) |
|
177 <p> |
|
178 Private slot handling changes of the media player state. |
|
179 </p><dl> |
|
180 <dt><i>state</i></dt> |
|
181 <dd> |
|
182 media player state (QAudio.State) |
|
183 </dd> |
|
184 </dl><a NAME="TranslatorWidget.__originalLanguage" ID="TranslatorWidget.__originalLanguage"></a> |
|
185 <h4>TranslatorWidget.__originalLanguage</h4> |
|
186 <b>__originalLanguage</b>(<i></i>) |
|
187 <p> |
|
188 Private method to return the code of the selected original language. |
|
189 </p><dl> |
|
190 <dt>Returns:</dt> |
|
191 <dd> |
|
192 code of the original language (string) |
|
193 </dd> |
|
194 </dl><a NAME="TranslatorWidget.__pronounce" ID="TranslatorWidget.__pronounce"></a> |
|
195 <h4>TranslatorWidget.__pronounce</h4> |
|
196 <b>__pronounce</b>(<i>text, language</i>) |
|
197 <p> |
|
198 Private method to pronounce the given text. |
|
199 </p><dl> |
|
200 <dt><i>text</i></dt> |
|
201 <dd> |
|
202 text to be pronounced (string) |
|
203 </dd><dt><i>language</i></dt> |
|
204 <dd> |
|
205 language code of the text (string) |
|
206 </dd> |
|
207 </dl><a NAME="TranslatorWidget.__translate" ID="TranslatorWidget.__translate"></a> |
|
208 <h4>TranslatorWidget.__translate</h4> |
|
209 <b>__translate</b>(<i>text, originalLanguage, translationLanguage</i>) |
|
210 <p> |
|
211 Private method to translate the given text. |
|
212 </p><dl> |
|
213 <dt><i>text</i></dt> |
|
214 <dd> |
|
215 text to be translated (string) |
|
216 </dd><dt><i>originalLanguage</i></dt> |
|
217 <dd> |
|
218 language code of the original (string) |
|
219 </dd><dt><i>translationLanguage</i></dt> |
|
220 <dd> |
|
221 language code of the translation (string) |
|
222 </dd> |
|
223 </dl><dl> |
|
224 <dt>Returns:</dt> |
|
225 <dd> |
|
226 tuple of translated text (string) and flag indicating |
|
227 success (boolean) |
|
228 </dd> |
|
229 </dl><a NAME="TranslatorWidget.__translationLanguage" ID="TranslatorWidget.__translationLanguage"></a> |
|
230 <h4>TranslatorWidget.__translationLanguage</h4> |
|
231 <b>__translationLanguage</b>(<i></i>) |
|
232 <p> |
|
233 Private method to return the code of the selected translation language. |
|
234 </p><dl> |
|
235 <dt>Returns:</dt> |
|
236 <dd> |
|
237 code of the translation language (string) |
|
238 </dd> |
|
239 </dl><a NAME="TranslatorWidget.__updateClearButton" ID="TranslatorWidget.__updateClearButton"></a> |
|
240 <h4>TranslatorWidget.__updateClearButton</h4> |
|
241 <b>__updateClearButton</b>(<i></i>) |
|
242 <p> |
|
243 Private slot to set the state of the clear button. |
|
244 </p><a NAME="TranslatorWidget.__updateEngines" ID="TranslatorWidget.__updateEngines"></a> |
|
245 <h4>TranslatorWidget.__updateEngines</h4> |
|
246 <b>__updateEngines</b>(<i></i>) |
|
247 <p> |
|
248 Private slot to update the engines combo box. |
|
249 </p><a NAME="TranslatorWidget.__updateLanguages" ID="TranslatorWidget.__updateLanguages"></a> |
|
250 <h4>TranslatorWidget.__updateLanguages</h4> |
|
251 <b>__updateLanguages</b>(<i></i>) |
|
252 <p> |
|
253 Private slot to update the language combo boxes. |
|
254 </p><a NAME="TranslatorWidget.__updatePronounceButtons" ID="TranslatorWidget.__updatePronounceButtons"></a> |
|
255 <h4>TranslatorWidget.__updatePronounceButtons</h4> |
|
256 <b>__updatePronounceButtons</b>(<i></i>) |
|
257 <p> |
|
258 Private slot to set the state of the pronounce buttons. |
|
259 </p><a NAME="TranslatorWidget.__updateTranslateButton" ID="TranslatorWidget.__updateTranslateButton"></a> |
|
260 <h4>TranslatorWidget.__updateTranslateButton</h4> |
|
261 <b>__updateTranslateButton</b>(<i></i>) |
|
262 <p> |
|
263 Private slot to set the state of the translate button. |
|
264 </p><a NAME="TranslatorWidget.on_clearButton_clicked" ID="TranslatorWidget.on_clearButton_clicked"></a> |
|
265 <h4>TranslatorWidget.on_clearButton_clicked</h4> |
|
266 <b>on_clearButton_clicked</b>(<i></i>) |
|
267 <p> |
|
268 Private slot to clear the text fields. |
|
269 </p><a NAME="TranslatorWidget.on_origEdit_textChanged" ID="TranslatorWidget.on_origEdit_textChanged"></a> |
|
270 <h4>TranslatorWidget.on_origEdit_textChanged</h4> |
|
271 <b>on_origEdit_textChanged</b>(<i></i>) |
|
272 <p> |
|
273 Private slot to handle changes of the original text. |
|
274 </p><a NAME="TranslatorWidget.on_origLanguageComboBox_currentIndexChanged" ID="TranslatorWidget.on_origLanguageComboBox_currentIndexChanged"></a> |
|
275 <h4>TranslatorWidget.on_origLanguageComboBox_currentIndexChanged</h4> |
|
276 <b>on_origLanguageComboBox_currentIndexChanged</b>(<i>index</i>) |
|
277 <p> |
|
278 Private slot to handle the selection of the original language. |
|
279 </p><dl> |
|
280 <dt><i>index</i></dt> |
|
281 <dd> |
|
282 current index (integer) |
|
283 </dd> |
|
284 </dl><a NAME="TranslatorWidget.on_preferencesButton_clicked" ID="TranslatorWidget.on_preferencesButton_clicked"></a> |
|
285 <h4>TranslatorWidget.on_preferencesButton_clicked</h4> |
|
286 <b>on_preferencesButton_clicked</b>(<i></i>) |
|
287 <p> |
|
288 Private slot to open the Translator configuration page. |
|
289 </p><a NAME="TranslatorWidget.on_pronounceOrigButton_clicked" ID="TranslatorWidget.on_pronounceOrigButton_clicked"></a> |
|
290 <h4>TranslatorWidget.on_pronounceOrigButton_clicked</h4> |
|
291 <b>on_pronounceOrigButton_clicked</b>(<i></i>) |
|
292 <p> |
|
293 Private slot to pronounce the original text. |
|
294 </p><a NAME="TranslatorWidget.on_pronounceTransButton_clicked" ID="TranslatorWidget.on_pronounceTransButton_clicked"></a> |
|
295 <h4>TranslatorWidget.on_pronounceTransButton_clicked</h4> |
|
296 <b>on_pronounceTransButton_clicked</b>(<i></i>) |
|
297 <p> |
|
298 Private slot to pronounce the translated text. |
|
299 </p><a NAME="TranslatorWidget.on_swapButton_clicked" ID="TranslatorWidget.on_swapButton_clicked"></a> |
|
300 <h4>TranslatorWidget.on_swapButton_clicked</h4> |
|
301 <b>on_swapButton_clicked</b>(<i></i>) |
|
302 <p> |
|
303 Private slot to swap the languages. |
|
304 </p><a NAME="TranslatorWidget.on_transEdit_textChanged" ID="TranslatorWidget.on_transEdit_textChanged"></a> |
|
305 <h4>TranslatorWidget.on_transEdit_textChanged</h4> |
|
306 <b>on_transEdit_textChanged</b>(<i></i>) |
|
307 <p> |
|
308 Private slot to handle changes of the translation text. |
|
309 </p><a NAME="TranslatorWidget.on_transLanguageComboBox_currentIndexChanged" ID="TranslatorWidget.on_transLanguageComboBox_currentIndexChanged"></a> |
|
310 <h4>TranslatorWidget.on_transLanguageComboBox_currentIndexChanged</h4> |
|
311 <b>on_transLanguageComboBox_currentIndexChanged</b>(<i>index</i>) |
|
312 <p> |
|
313 Private slot to handle the selection of the translation language. |
|
314 </p><dl> |
|
315 <dt><i>index</i></dt> |
|
316 <dd> |
|
317 current index (integer) |
|
318 </dd> |
|
319 </dl><a NAME="TranslatorWidget.on_translateButton_clicked" ID="TranslatorWidget.on_translateButton_clicked"></a> |
|
320 <h4>TranslatorWidget.on_translateButton_clicked</h4> |
|
321 <b>on_translateButton_clicked</b>(<i></i>) |
|
322 <p> |
|
323 Private slot to translate the entered text. |
|
324 </p> |
|
325 <div align="right"><a href="#top">Up</a></div> |
|
326 <hr /> |
|
327 </body></html> |