eric6/Plugins/PluginTabnanny.py

changeset 7256
4ef3b78ebb4e
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7255:d595f6f9cbf8 7256:4ef3b78ebb4e
27 deactivateable = True 27 deactivateable = True
28 version = UI.Info.VersionOnly 28 version = UI.Info.VersionOnly
29 className = "TabnannyPlugin" 29 className = "TabnannyPlugin"
30 packageName = "__core__" 30 packageName = "__core__"
31 shortDescription = "Show the Tabnanny dialog." 31 shortDescription = "Show the Tabnanny dialog."
32 longDescription = """This plugin implements the Tabnanny dialog.""" \ 32 longDescription = (
33 """ Tabnanny is used to check Python source files for correct""" \ 33 """This plugin implements the Tabnanny dialog."""
34 """ Tabnanny is used to check Python source files for correct"""
34 """ indentations.""" 35 """ indentations."""
36 )
35 pyqtApi = 2 37 pyqtApi = 2
36 # End-Of-Header 38 # End-Of-Header
37 39
38 error = "" 40 error = ""
39 41
235 """ for bad indentations using tabnanny.</p>""" 237 """ for bad indentations using tabnanny.</p>"""
236 )) 238 ))
237 self.__editorAct.triggered.connect(self.__editorTabnanny) 239 self.__editorAct.triggered.connect(self.__editorTabnanny)
238 240
239 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) 241 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu)
240 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ 242 e5App().getObject("ProjectBrowser").getProjectBrowser(
241 .showMenu.connect(self.__projectBrowserShowMenu) 243 "sources").showMenu.connect(self.__projectBrowserShowMenu)
242 e5App().getObject("ViewManager").editorOpenedEd.connect( 244 e5App().getObject("ViewManager").editorOpenedEd.connect(
243 self.__editorOpened) 245 self.__editorOpened)
244 e5App().getObject("ViewManager").editorClosedEd.connect( 246 e5App().getObject("ViewManager").editorClosedEd.connect(
245 self.__editorClosed) 247 self.__editorClosed)
246 248
253 """ 255 """
254 Public method to deactivate this plugin. 256 Public method to deactivate this plugin.
255 """ 257 """
256 e5App().getObject("Project").showMenu.disconnect( 258 e5App().getObject("Project").showMenu.disconnect(
257 self.__projectShowMenu) 259 self.__projectShowMenu)
258 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ 260 e5App().getObject("ProjectBrowser").getProjectBrowser(
259 .showMenu.disconnect(self.__projectBrowserShowMenu) 261 "sources").showMenu.disconnect(self.__projectBrowserShowMenu)
260 e5App().getObject("ViewManager").editorOpenedEd.disconnect( 262 e5App().getObject("ViewManager").editorOpenedEd.disconnect(
261 self.__editorOpened) 263 self.__editorOpened)
262 e5App().getObject("ViewManager").editorClosedEd.disconnect( 264 e5App().getObject("ViewManager").editorClosedEd.disconnect(
263 self.__editorClosed) 265 self.__editorClosed)
264 266
298 submenu is about to be shown. 300 submenu is about to be shown.
299 301
300 @param menuName name of the menu to be shown (string) 302 @param menuName name of the menu to be shown (string)
301 @param menu reference to the menu (QMenu) 303 @param menu reference to the menu (QMenu)
302 """ 304 """
303 if menuName == "Checks" and \ 305 if (
304 e5App().getObject("Project").getProjectLanguage() in \ 306 menuName == "Checks" and
305 ["Python3", "Python2", "Python", "MicroPython"]: 307 e5App().getObject("Project").getProjectLanguage() in
308 ["Python3", "Python2", "Python", "MicroPython"]
309 ):
306 self.__projectBrowserMenu = menu 310 self.__projectBrowserMenu = menu
307 if self.__projectBrowserAct is None: 311 if self.__projectBrowserAct is None:
308 self.__projectBrowserAct = E5Action( 312 self.__projectBrowserAct = E5Action(
309 self.tr('Check Indentations'), 313 self.tr('Check Indentations'),
310 self.tr('&Indentations...'), 0, 0, 314 self.tr('&Indentations...'), 0, 0,
402 Private slot to handle the tabnanny context menu action of the editors. 406 Private slot to handle the tabnanny context menu action of the editors.
403 """ 407 """
404 editor = e5App().getObject("ViewManager").activeWindow() 408 editor = e5App().getObject("ViewManager").activeWindow()
405 if editor is not None: 409 if editor is not None:
406 if editor.checkDirty() and editor.getFileName() is not None: 410 if editor.checkDirty() and editor.getFileName() is not None:
407 from CheckerPlugins.Tabnanny.TabnannyDialog import \ 411 from CheckerPlugins.Tabnanny.TabnannyDialog import (
408 TabnannyDialog 412 TabnannyDialog
413 )
409 self.__editorTabnannyDialog = TabnannyDialog(self) 414 self.__editorTabnannyDialog = TabnannyDialog(self)
410 self.__editorTabnannyDialog.show() 415 self.__editorTabnannyDialog.show()
411 self.__editorTabnannyDialog.start(editor.getFileName()) 416 self.__editorTabnannyDialog.start(editor.getFileName())

eric ide

mercurial