167 """ |
167 """ |
168 Public method to activate this plugin. |
168 Public method to activate this plugin. |
169 |
169 |
170 @return tuple of None and activation status (boolean) |
170 @return tuple of None and activation status (boolean) |
171 """ |
171 """ |
172 menu = e5App().getObject("Project").getMenu("Checks") |
172 menu = ericApp().getObject("Project").getMenu("Checks") |
173 if menu: |
173 if menu: |
174 self.__projectAct = E5Action( |
174 self.__projectAct = EricAction( |
175 self.tr('Check Syntax'), |
175 self.tr('Check Syntax'), |
176 self.tr('&Syntax...'), 0, 0, |
176 self.tr('&Syntax...'), 0, 0, |
177 self, 'project_check_syntax') |
177 self, 'project_check_syntax') |
178 self.__projectAct.setStatusTip( |
178 self.__projectAct.setStatusTip( |
179 self.tr('Check syntax.')) |
179 self.tr('Check syntax.')) |
180 self.__projectAct.setWhatsThis(self.tr( |
180 self.__projectAct.setWhatsThis(self.tr( |
181 """<b>Check Syntax...</b>""" |
181 """<b>Check Syntax...</b>""" |
182 """<p>This checks Python files for syntax errors.</p>""" |
182 """<p>This checks Python files for syntax errors.</p>""" |
183 )) |
183 )) |
184 self.__projectAct.triggered.connect(self.__projectSyntaxCheck) |
184 self.__projectAct.triggered.connect(self.__projectSyntaxCheck) |
185 e5App().getObject("Project").addE5Actions([self.__projectAct]) |
185 ericApp().getObject("Project").addEricActions([self.__projectAct]) |
186 menu.addAction(self.__projectAct) |
186 menu.addAction(self.__projectAct) |
187 |
187 |
188 self.__editorAct = E5Action( |
188 self.__editorAct = EricAction( |
189 self.tr('Check Syntax'), |
189 self.tr('Check Syntax'), |
190 self.tr('&Syntax...'), 0, 0, |
190 self.tr('&Syntax...'), 0, 0, |
191 self, "") |
191 self, "") |
192 self.__editorAct.setWhatsThis(self.tr( |
192 self.__editorAct.setWhatsThis(self.tr( |
193 """<b>Check Syntax...</b>""" |
193 """<b>Check Syntax...</b>""" |
194 """<p>This checks Python files for syntax errors.</p>""" |
194 """<p>This checks Python files for syntax errors.</p>""" |
195 )) |
195 )) |
196 self.__editorAct.triggered.connect(self.__editorSyntaxCheck) |
196 self.__editorAct.triggered.connect(self.__editorSyntaxCheck) |
197 |
197 |
198 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) |
198 ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu) |
199 e5App().getObject("ProjectBrowser").getProjectBrowser( |
199 ericApp().getObject("ProjectBrowser").getProjectBrowser( |
200 "sources").showMenu.connect(self.__projectBrowserShowMenu) |
200 "sources").showMenu.connect(self.__projectBrowserShowMenu) |
201 e5App().getObject("ViewManager").editorOpenedEd.connect( |
201 ericApp().getObject("ViewManager").editorOpenedEd.connect( |
202 self.__editorOpened) |
202 self.__editorOpened) |
203 e5App().getObject("ViewManager").editorClosedEd.connect( |
203 ericApp().getObject("ViewManager").editorClosedEd.connect( |
204 self.__editorClosed) |
204 self.__editorClosed) |
205 |
205 |
206 for editor in e5App().getObject("ViewManager").getOpenEditors(): |
206 for editor in ericApp().getObject("ViewManager").getOpenEditors(): |
207 self.__editorOpened(editor) |
207 self.__editorOpened(editor) |
208 |
208 |
209 return None, True |
209 return None, True |
210 |
210 |
211 def deactivate(self): |
211 def deactivate(self): |
212 """ |
212 """ |
213 Public method to deactivate this plugin. |
213 Public method to deactivate this plugin. |
214 """ |
214 """ |
215 e5App().getObject("Project").showMenu.disconnect( |
215 ericApp().getObject("Project").showMenu.disconnect( |
216 self.__projectShowMenu) |
216 self.__projectShowMenu) |
217 e5App().getObject("ProjectBrowser").getProjectBrowser( |
217 ericApp().getObject("ProjectBrowser").getProjectBrowser( |
218 "sources").showMenu.disconnect(self.__projectBrowserShowMenu) |
218 "sources").showMenu.disconnect(self.__projectBrowserShowMenu) |
219 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
219 ericApp().getObject("ViewManager").editorOpenedEd.disconnect( |
220 self.__editorOpened) |
220 self.__editorOpened) |
221 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
221 ericApp().getObject("ViewManager").editorClosedEd.disconnect( |
222 self.__editorClosed) |
222 self.__editorClosed) |
223 |
223 |
224 menu = e5App().getObject("Project").getMenu("Checks") |
224 menu = ericApp().getObject("Project").getMenu("Checks") |
225 if menu: |
225 if menu: |
226 menu.removeAction(self.__projectAct) |
226 menu.removeAction(self.__projectAct) |
227 |
227 |
228 if self.__projectBrowserMenu and self.__projectBrowserAct: |
228 if self.__projectBrowserMenu and self.__projectBrowserAct: |
229 self.__projectBrowserMenu.removeAction( |
229 self.__projectBrowserMenu.removeAction( |
245 @param menuName name of the menu to be shown (string) |
245 @param menuName name of the menu to be shown (string) |
246 @param menu reference to the menu (QMenu) |
246 @param menu reference to the menu (QMenu) |
247 """ |
247 """ |
248 if menuName == "Checks" and self.__projectAct is not None: |
248 if menuName == "Checks" and self.__projectAct is not None: |
249 self.__projectAct.setEnabled( |
249 self.__projectAct.setEnabled( |
250 e5App().getObject("Project").getProjectLanguage() in |
250 ericApp().getObject("Project").getProjectLanguage() in |
251 self.syntaxCheckService.getLanguages()) |
251 self.syntaxCheckService.getLanguages()) |
252 |
252 |
253 def __projectBrowserShowMenu(self, menuName, menu): |
253 def __projectBrowserShowMenu(self, menuName, menu): |
254 """ |
254 """ |
255 Private slot called, when the the project browser menu or a submenu is |
255 Private slot called, when the the project browser menu or a submenu is |
258 @param menuName name of the menu to be shown (string) |
258 @param menuName name of the menu to be shown (string) |
259 @param menu reference to the menu (QMenu) |
259 @param menu reference to the menu (QMenu) |
260 """ |
260 """ |
261 if ( |
261 if ( |
262 menuName == "Checks" and |
262 menuName == "Checks" and |
263 e5App().getObject("Project").getProjectLanguage() in |
263 ericApp().getObject("Project").getProjectLanguage() in |
264 self.syntaxCheckService.getLanguages() |
264 self.syntaxCheckService.getLanguages() |
265 ): |
265 ): |
266 self.__projectBrowserMenu = menu |
266 self.__projectBrowserMenu = menu |
267 if self.__projectBrowserAct is None: |
267 if self.__projectBrowserAct is None: |
268 self.__projectBrowserAct = E5Action( |
268 self.__projectBrowserAct = EricAction( |
269 self.tr('Check Syntax'), |
269 self.tr('Check Syntax'), |
270 self.tr('&Syntax...'), 0, 0, |
270 self.tr('&Syntax...'), 0, 0, |
271 self, "") |
271 self, "") |
272 self.__projectBrowserAct.setWhatsThis(self.tr( |
272 self.__projectBrowserAct.setWhatsThis(self.tr( |
273 """<b>Check Syntax...</b>""" |
273 """<b>Check Syntax...</b>""" |