PluginProjectWeb.py

changeset 6
a1600fa29542
parent 5
31bc1ef6f624
child 7
e6fbd4a7484d
equal deleted inserted replaced
5:31bc1ef6f624 6:a1600fa29542
113 113
114 def deactivate(self): 114 def deactivate(self):
115 """ 115 """
116 Public method to deactivate this plugin. 116 Public method to deactivate this plugin.
117 """ 117 """
118 self.__e5project.unregisterProjectType("Django") 118 self.__e5project.unregisterProjectType("Web")
119 119
120 self.__ui.showMenu.disconnect(self.__populateMenu) 120 self.__ui.showMenu.disconnect(self.__populateMenu)
121 121
122 e5App().getObject("ViewManager").editorOpenedEd.disconnect( 122 e5App().getObject("ViewManager").editorOpenedEd.disconnect(
123 self.__editorOpened) 123 self.__editorOpened)
124 e5App().getObject("ViewManager").editorClosedEd.disconnect( 124 e5App().getObject("ViewManager").editorClosedEd.disconnect(
125 self.__editorClosed) 125 self.__editorClosed)
126 126
127 for editor, acts in self.__editors.items(): 127 for editor, acts in self.__editors.items():
128 ## editor.showMenu.disconnect(self.__editorShowMenu) 128 editor.showMenu.disconnect(self.__editorShowMenu)
129 menu = editor.getMenu("Tools") 129 menu = editor.getMenu("Tools")
130 if menu is not None: 130 if menu is not None:
131 for act in acts: 131 for act in acts:
132 menu.removeAction(act) 132 menu.removeAction(act)
133 133
190 """ 190 """
191 Private slot to prepare the menu before it is shown. 191 Private slot to prepare the menu before it is shown.
192 """ 192 """
193 editor = e5App().getObject("ViewManager").activeWindow() 193 editor = e5App().getObject("ViewManager").activeWindow()
194 selectionAvailable = bool(editor and editor.selectedText() != "") 194 selectionAvailable = bool(editor and editor.selectedText() != "")
195 isHtml = editor.getLanguage().lower().startswith("html") 195 isHtml = bool(editor and
196 editor.getLanguage().lower().startswith("html"))
196 197
197 self.__html5ToCss3Act.setEnabled( 198 self.__html5ToCss3Act.setEnabled(
198 selectionAvailable and BeautifulSoupAvailable and isHtml) 199 selectionAvailable and BeautifulSoupAvailable and isHtml)
199 self.__html5ToJsAct.setEnabled( 200 self.__html5ToJsAct.setEnabled(
200 selectionAvailable and BeautifulSoupAvailable and isHtml) 201 selectionAvailable and BeautifulSoupAvailable and isHtml)
209 @param menu reference to the menu to be populated (QMenu) 210 @param menu reference to the menu to be populated (QMenu)
210 """ 211 """
211 if name != "Tools": 212 if name != "Tools":
212 return 213 return
213 214
214 ## editor = e5App().getObject("ViewManager").activeWindow()
215 ##
216 if not menu.isEmpty(): 215 if not menu.isEmpty():
217 menu.addSeparator() 216 menu.addSeparator()
218 217
219 act = menu.addMenu(self.__menu) 218 menu.addMenu(self.__menu)
220 # TODO: check this
221 ## act.setEnabled(editor is not None and editor.selectedText() != '')
222 219
223 def __editorOpened(self, editor): 220 def __editorOpened(self, editor):
224 """ 221 """
225 Private slot called, when a new editor was opened. 222 Private slot called, when a new editor was opened.
226 223
232 if not menu.isEmpty(): 229 if not menu.isEmpty():
233 act = menu.addSeparator() 230 act = menu.addSeparator()
234 self.__editors[editor].append(act) 231 self.__editors[editor].append(act)
235 act = menu.addMenu(self.__menu) 232 act = menu.addMenu(self.__menu)
236 self.__editors[editor].append(act) 233 self.__editors[editor].append(act)
237 ## editor.showMenu.connect(self.__editorShowMenu) 234 editor.showMenu.connect(self.__editorShowMenu)
238 235
239 def __editorClosed(self, editor): 236 def __editorClosed(self, editor):
240 """ 237 """
241 Private slot called, when an editor was closed. 238 Private slot called, when an editor was closed.
242 239
245 try: 242 try:
246 del self.__editors[editor] 243 del self.__editors[editor]
247 except KeyError: 244 except KeyError:
248 pass 245 pass
249 246
250 ## def __editorShowMenu(self, menuName, menu, editor): 247 def __editorShowMenu(self, menuName, menu, editor):
251 ## """ 248 """
252 ## Private slot called, when the the editor context menu or a submenu is 249 Private slot called, when the the editor context menu or a submenu is
253 ## about to be shown. 250 about to be shown.
254 ## 251
255 ## @param menuName name of the menu to be shown (string) 252 @param menuName name of the menu to be shown (string)
256 ## @param menu reference to the menu (QMenu) 253 @param menu reference to the menu (QMenu)
257 ## @param editor reference to the editor 254 @param editor reference to the editor
258 ## """ 255 """
259 ## if menuName == "Tools": 256 if menuName == "Tools":
260 ## # TODO: check this 257 if self.__menu.menuAction() not in menu.actions():
261 ## self.__menu.setEnabled(editor.selectedText() != '') 258 # Re-add our menu
262 ## 259 self.__editors[editor] = []
260 if not menu.isEmpty():
261 act = menu.addSeparator()
262 self.__editors[editor].append(act)
263 act = menu.addMenu(self.__menu)
264 self.__editors[editor].append(act)
265
263 def __htm5ToCss3(self): 266 def __htm5ToCss3(self):
264 """ 267 """
265 Private slot handling the HTML5 to CSS3 conversion. 268 Private slot handling the HTML5 to CSS3 conversion.
266 """ 269 """
267 from ProjectWeb.Html5ToCss3Converter import Html5ToCss3Converter 270 from ProjectWeb.Html5ToCss3Converter import Html5ToCss3Converter

eric ide

mercurial