176 self.__menu = QMenu(self.tr("Web")) |
176 self.__menu = QMenu(self.tr("Web")) |
177 |
177 |
178 # TODO: add our actions here |
178 # TODO: add our actions here |
179 self.__html5ToCss3Act = self.__menu.addAction(self.tr( |
179 self.__html5ToCss3Act = self.__menu.addAction(self.tr( |
180 "HTML5 to CSS3"), self.__htm5ToCss3) |
180 "HTML5 to CSS3"), self.__htm5ToCss3) |
|
181 self.__html5ToJsAct = self.__menu.addAction(self.tr( |
|
182 "HTML5 to JavaScript"), self.__htm5ToJs) |
181 |
183 |
182 self.__menu.aboutToShow.connect(self.__menuAboutToShow) |
184 self.__menu.aboutToShow.connect(self.__menuAboutToShow) |
183 |
185 |
184 def __menuAboutToShow(self): |
186 def __menuAboutToShow(self): |
185 """ |
187 """ |
187 """ |
189 """ |
188 editor = e5App().getObject("ViewManager").activeWindow() |
190 editor = e5App().getObject("ViewManager").activeWindow() |
189 selectionAvailable = bool(editor and editor.selectedText() != "") |
191 selectionAvailable = bool(editor and editor.selectedText() != "") |
190 |
192 |
191 self.__html5ToCss3Act.setEnabled( |
193 self.__html5ToCss3Act.setEnabled( |
|
194 selectionAvailable and BeautifulSoupAvailable) |
|
195 self.__html5ToJsAct.setEnabled( |
192 selectionAvailable and BeautifulSoupAvailable) |
196 selectionAvailable and BeautifulSoupAvailable) |
193 |
197 |
194 def __populateMenu(self, name, menu): |
198 def __populateMenu(self, name, menu): |
195 """ |
199 """ |
196 Private slot to populate the tools menu with our entries. |
200 Private slot to populate the tools menu with our entries. |
252 ## |
256 ## |
253 def __htm5ToCss3(self): |
257 def __htm5ToCss3(self): |
254 """ |
258 """ |
255 Private slot handling the HTML5 to CSS3 conversion. |
259 Private slot handling the HTML5 to CSS3 conversion. |
256 """ |
260 """ |
257 # TODO: implement this |
|
258 from ProjectWeb.Html5ToCss3Converter import Html5ToCss3Converter |
261 from ProjectWeb.Html5ToCss3Converter import Html5ToCss3Converter |
259 vm = e5App().getObject("ViewManager") |
262 vm = e5App().getObject("ViewManager") |
260 editor = vm.activeWindow() |
263 editor = vm.activeWindow() |
261 html = editor.selectedText() |
264 html = editor.selectedText() |
262 |
265 |
267 if css3: |
270 if css3: |
268 vm.newEditor() |
271 vm.newEditor() |
269 newEditor = vm.activeWindow() |
272 newEditor = vm.activeWindow() |
270 newEditor.setText(css3) |
273 newEditor.setText(css3) |
271 newEditor.setLanguage("dummy.css") |
274 newEditor.setLanguage("dummy.css") |
|
275 |
|
276 def __htm5ToJs(self): |
|
277 """ |
|
278 Private slot handling the HTML5 to JavaScript conversion. |
|
279 """ |
|
280 from ProjectWeb.Html5ToJsConverter import Html5ToJsConverter |
|
281 vm = e5App().getObject("ViewManager") |
|
282 editor = vm.activeWindow() |
|
283 html = editor.selectedText() |
|
284 |
|
285 converter = Html5ToJsConverter(html) |
|
286 |
|
287 js = converter.getJavaScript() |
|
288 |
|
289 if js: |
|
290 vm.newEditor() |
|
291 newEditor = vm.activeWindow() |
|
292 newEditor.setText(js) |
|
293 newEditor.setLanguage("dummy.js") |