PluginProjectWeb.py

changeset 35
a3f1dcf94fe4
parent 34
a6d8718f37b5
child 38
6a12561fc0b5
equal deleted inserted replaced
34:a6d8718f37b5 35:a3f1dcf94fe4
5 5
6 """ 6 """
7 Module implementing the Web project plugin. 7 Module implementing the Web project plugin.
8 """ 8 """
9 9
10 import contextlib
10 import os 11 import os
11 12
12 from PyQt5.QtCore import QObject, QTranslator 13 from PyQt5.QtCore import QObject, QTranslator
13 from PyQt5.QtWidgets import QMenu 14 from PyQt5.QtWidgets import QMenu
14 15
26 # Start-Of-Header 27 # Start-Of-Header
27 name = "Generic Web Project Plug-in" 28 name = "Generic Web Project Plug-in"
28 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 29 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
29 autoactivate = True 30 autoactivate = True
30 deactivateable = True 31 deactivateable = True
31 version = "2.1.0" 32 version = "2.2.0"
32 className = "ProjectWebPlugin" 33 className = "ProjectWebPlugin"
33 packageName = "ProjectWeb" 34 packageName = "ProjectWeb"
34 shortDescription = "Support for Web projects and web related tools." 35 shortDescription = "Support for Web projects and web related tools."
35 longDescription = ( 36 longDescription = (
36 """This plug-in provides support for ordinary web projects and some web""" 37 """This plug-in provides support for ordinary web projects and some web"""
52 """ 53 """
53 Constructor 54 Constructor
54 55
55 @param ui reference to the user interface object (UI.UserInterface) 56 @param ui reference to the user interface object (UI.UserInterface)
56 """ 57 """
57 super(ProjectWebPlugin, self).__init__(ui) 58 super().__init__(ui)
58 self.__ui = ui 59 self.__ui = ui
59 self.__initialize() 60 self.__initialize()
60 61
61 self.__translator = None 62 self.__translator = None
62 self.__loadTranslator() 63 self.__loadTranslator()
244 """ 245 """
245 Private slot called, when an editor was closed. 246 Private slot called, when an editor was closed.
246 247
247 @param editor reference to the editor (QScintilla.Editor) 248 @param editor reference to the editor (QScintilla.Editor)
248 """ 249 """
249 try: 250 with contextlib.suppress(KeyError):
250 del self.__editors[editor] 251 del self.__editors[editor]
251 except KeyError:
252 pass
253 252
254 def __editorShowMenu(self, menuName, menu, editor): 253 def __editorShowMenu(self, menuName, menu, editor):
255 """ 254 """
256 Private slot called, when the the editor context menu or a submenu is 255 Private slot called, when the the editor context menu or a submenu is
257 about to be shown. 256 about to be shown.
258 257
259 @param menuName name of the menu to be shown (string) 258 @param menuName name of the menu to be shown (string)
260 @param menu reference to the menu (QMenu) 259 @param menu reference to the menu (QMenu)
261 @param editor reference to the editor 260 @param editor reference to the editor
262 """ 261 """
263 if menuName == "Tools": 262 if (
264 if self.__menu.menuAction() not in menu.actions(): 263 menuName == "Tools" and
265 # Re-add our menu 264 self.__menu.menuAction() not in menu.actions()
266 self.__editors[editor] = [] 265 ):
267 if not menu.isEmpty(): 266 # Re-add our menu
268 act = menu.addSeparator() 267 self.__editors[editor] = []
269 self.__editors[editor].append(act) 268 if not menu.isEmpty():
270 act = menu.addMenu(self.__menu) 269 act = menu.addSeparator()
271 self.__editors[editor].append(act) 270 self.__editors[editor].append(act)
271 act = menu.addMenu(self.__menu)
272 self.__editors[editor].append(act)
272 273
273 def __html5ToCss3(self): 274 def __html5ToCss3(self):
274 """ 275 """
275 Private slot handling the HTML5 to CSS3 conversion. 276 Private slot handling the HTML5 to CSS3 conversion.
276 """ 277 """

eric ide

mercurial