Sat, 09 Jul 2016 13:20:35 +0200
Updated Russian translations provided by Alexander Barkoff.
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
2 | |
18
586a57c396b2
Updated copyright for 2016.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
17
diff
changeset
|
3 | # Copyright (c) 2014 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
4 | # |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
5 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
6 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
7 | Module implementing the Web project plugin. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
8 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
9 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
10 | from __future__ import unicode_literals |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
11 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
12 | import os |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
13 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
14 | from PyQt5.QtCore import QObject, QTranslator |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
15 | from PyQt5.QtWidgets import QMenu |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
16 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
17 | from E5Gui.E5Application import e5App |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
18 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
19 | import Preferences |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
20 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
21 | try: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
22 | from bs4 import BeautifulSoup # __IGNORE_EXCEPTION__ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
23 | BeautifulSoupAvailable = True |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
24 | except ImportError: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
25 | BeautifulSoup = None |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
26 | BeautifulSoupAvailable = False |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
27 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
28 | # Start-Of-Header |
17
ea6168970971
Corrected the name header variable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
29 | name = "Generic Web Project Plug-in" |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
30 | author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
31 | autoactivate = True |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
32 | deactivateable = True |
19
bf06f53824d2
Updated Russian translations provided by Alexander Barkoff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
18
diff
changeset
|
33 | version = "1.1.2" |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
34 | className = "ProjectWebPlugin" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
35 | packageName = "ProjectWeb" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
36 | shortDescription = "Support for Web projects and web related tools." |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
37 | longDescription = ( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
38 | """This plug-in provides support for ordinary web projects and some web""" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
39 | """ related tools.\n\nIt requires BeautifulSoup4 for some of its""" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
40 | """ functionality.""" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
41 | ) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
42 | needsRestart = False |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
43 | pyqtApi = 2 |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
44 | python2Compatible = True |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
45 | # End-Of-Header |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
46 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
47 | error = "" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
48 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
49 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
50 | class ProjectWebPlugin(QObject): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
51 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
52 | Class implementing the Web project plugin. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
53 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
54 | def __init__(self, ui): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
55 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
56 | Constructor |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
57 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
58 | @param ui reference to the user interface object (UI.UserInterface) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
59 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
60 | super(ProjectWebPlugin, self).__init__(ui) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
61 | self.__ui = ui |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
62 | self.__initialize() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
63 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
64 | self.__translator = None |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
65 | self.__loadTranslator() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
66 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
67 | self.__initMenu() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
68 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
69 | def __initialize(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
70 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
71 | Private slot to (re)initialize the plugin. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
72 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
73 | self.__e5project = e5App().getObject("Project") |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
74 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
75 | self.__editors = {} |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
76 | self.__mainActions = [] |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
77 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
78 | def activate(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
79 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
80 | Public method to activate this plugin. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
81 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
82 | @return tuple of None and activation status (boolean) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
83 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
84 | global error |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
85 | error = "" # clear previous error |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
86 | |
8
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
87 | # it is not registered for a specific programming language |
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
88 | self.__e5project.registerProjectType( |
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
89 | "Web", self.tr("Web"), |
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
90 | self.fileTypesCallback) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
91 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
92 | from Project.ProjectBrowser import SourcesBrowserFlag, \ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
93 | FormsBrowserFlag, OthersBrowserFlag |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
94 | Preferences.setProjectBrowserFlagsDefault( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
95 | "Web", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
96 | SourcesBrowserFlag | FormsBrowserFlag | OthersBrowserFlag, |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
97 | ) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
98 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
99 | self.__ui.showMenu.connect(self.__populateMenu) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
100 | |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
101 | menu = self.__ui.getMenu("plugin_tools") |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
102 | if menu is not None: |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
103 | if not menu.isEmpty(): |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
104 | act = menu.addSeparator() |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
105 | self.__mainActions.append(act) |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
106 | act = menu.addMenu(self.__menu) |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
107 | self.__mainActions.append(act) |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
108 | |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
109 | e5App().getObject("ViewManager").editorOpenedEd.connect( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
110 | self.__editorOpened) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
111 | e5App().getObject("ViewManager").editorClosedEd.connect( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
112 | self.__editorClosed) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
113 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
114 | for editor in e5App().getObject("ViewManager").getOpenEditors(): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
115 | self.__editorOpened(editor) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
116 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
117 | return None, True |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
118 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
119 | def deactivate(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
120 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
121 | Public method to deactivate this plugin. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
122 | """ |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
123 | self.__e5project.unregisterProjectType("Web") |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
124 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
125 | self.__ui.showMenu.disconnect(self.__populateMenu) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
126 | |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
127 | menu = self.__ui.getMenu("plugin_tools") |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
128 | if menu is not None: |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
129 | for act in self.__mainActions: |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
130 | menu.removeAction(act) |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
131 | self.__mainActions = [] |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
132 | |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
133 | e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
134 | self.__editorOpened) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
135 | e5App().getObject("ViewManager").editorClosedEd.disconnect( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
136 | self.__editorClosed) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
137 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
138 | for editor, acts in self.__editors.items(): |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
139 | editor.showMenu.disconnect(self.__editorShowMenu) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
140 | menu = editor.getMenu("Tools") |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
141 | if menu is not None: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
142 | for act in acts: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
143 | menu.removeAction(act) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
144 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
145 | self.__initialize() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
146 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
147 | def __loadTranslator(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
148 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
149 | Private method to load the translation file. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
150 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
151 | if self.__ui is not None: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
152 | loc = self.__ui.getLocale() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
153 | if loc and loc != "C": |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
154 | locale_dir = os.path.join( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
155 | os.path.dirname(__file__), "ProjectWeb", "i18n") |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
156 | translation = "web_%s" % loc |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
157 | translator = QTranslator(None) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
158 | loaded = translator.load(translation, locale_dir) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
159 | if loaded: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
160 | self.__translator = translator |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
161 | e5App().installTranslator(self.__translator) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
162 | else: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
163 | print("Warning: translation file '{0}' could not be" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
164 | " loaded.".format(translation)) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
165 | print("Using default.") |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
166 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
167 | def fileTypesCallback(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
168 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
169 | Public method to get the filetype associations of the Web project type. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
170 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
171 | @return dictionary with file type associations |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
172 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
173 | if self.__e5project.getProjectType() == "Web": |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
174 | fileTypes = { |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
175 | "*.html": "FORMS", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
176 | "*.htm": "FORMS", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
177 | "*.js": "SOURCES", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
178 | } |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
179 | else: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
180 | fileTypes = {} |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
181 | return fileTypes |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
182 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
183 | def __initMenu(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
184 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
185 | Private method to initialize the web tools menu. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
186 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
187 | self.__menu = QMenu(self.tr("Web")) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
188 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
189 | self.__html5ToCss3Act = self.__menu.addAction(self.tr( |
7
e6fbd4a7484d
Some small corrections, added source docu, translations and the other supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
190 | "HTML5 to CSS3"), self.__html5ToCss3) |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
191 | self.__html5ToJsAct = self.__menu.addAction(self.tr( |
7
e6fbd4a7484d
Some small corrections, added source docu, translations and the other supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
192 | "HTML5 to JavaScript"), self.__html5ToJs) |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
193 | self.__menu.addSeparator() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
194 | self.__html5PrettifyAct = self.__menu.addAction(self.tr( |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
195 | "Prettify HTML"), self.__html5Prettify) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
196 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
197 | self.__menu.aboutToShow.connect(self.__menuAboutToShow) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
198 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
199 | def __menuAboutToShow(self): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
200 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
201 | Private slot to prepare the menu before it is shown. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
202 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
203 | editor = e5App().getObject("ViewManager").activeWindow() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
204 | selectionAvailable = bool(editor and editor.selectedText() != "") |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
205 | isHtml = bool(editor and |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
206 | editor.getLanguage().lower().startswith("html")) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
207 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
208 | self.__html5ToCss3Act.setEnabled( |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
209 | selectionAvailable and BeautifulSoupAvailable and isHtml) |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
210 | self.__html5ToJsAct.setEnabled( |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
211 | selectionAvailable and BeautifulSoupAvailable and isHtml) |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
212 | self.__html5PrettifyAct.setEnabled( |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
213 | BeautifulSoupAvailable and isHtml) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
214 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
215 | def __populateMenu(self, name, menu): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
216 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
217 | Private slot to populate the tools menu with our entries. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
218 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
219 | @param name name of the menu (string) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
220 | @param menu reference to the menu to be populated (QMenu) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
221 | """ |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
222 | if name not in ["Tools", "PluginTools"]: |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
223 | return |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
224 | |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
225 | if name == "Tools": |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
226 | if not menu.isEmpty(): |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
227 | menu.addSeparator() |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
228 | menu.addMenu(self.__menu) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
229 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
230 | def __editorOpened(self, editor): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
231 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
232 | Private slot called, when a new editor was opened. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
233 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
234 | @param editor reference to the new editor (QScintilla.Editor) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
235 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
236 | menu = editor.getMenu("Tools") |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
237 | if menu is not None: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
238 | self.__editors[editor] = [] |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
239 | if not menu.isEmpty(): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
240 | act = menu.addSeparator() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
241 | self.__editors[editor].append(act) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
242 | act = menu.addMenu(self.__menu) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
243 | self.__editors[editor].append(act) |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
244 | editor.showMenu.connect(self.__editorShowMenu) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
245 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
246 | def __editorClosed(self, editor): |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
247 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
248 | Private slot called, when an editor was closed. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
249 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
250 | @param editor reference to the editor (QScintilla.Editor) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
251 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
252 | try: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
253 | del self.__editors[editor] |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
254 | except KeyError: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
255 | pass |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
256 | |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
257 | def __editorShowMenu(self, menuName, menu, editor): |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
258 | """ |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
259 | Private slot called, when the the editor context menu or a submenu is |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
260 | about to be shown. |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
261 | |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
262 | @param menuName name of the menu to be shown (string) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
263 | @param menu reference to the menu (QMenu) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
264 | @param editor reference to the editor |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
265 | """ |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
266 | if menuName == "Tools": |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
267 | if self.__menu.menuAction() not in menu.actions(): |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
268 | # Re-add our menu |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
269 | self.__editors[editor] = [] |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
270 | if not menu.isEmpty(): |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
271 | act = menu.addSeparator() |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
272 | self.__editors[editor].append(act) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
273 | act = menu.addMenu(self.__menu) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
274 | self.__editors[editor].append(act) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
275 | |
7
e6fbd4a7484d
Some small corrections, added source docu, translations and the other supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
276 | def __html5ToCss3(self): |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
277 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
278 | Private slot handling the HTML5 to CSS3 conversion. |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
279 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
280 | from ProjectWeb.Html5ToCss3Converter import Html5ToCss3Converter |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
281 | vm = e5App().getObject("ViewManager") |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
282 | editor = vm.activeWindow() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
283 | html = editor.selectedText() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
284 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
285 | converter = Html5ToCss3Converter(html) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
286 | css3 = converter.getCss3() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
287 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
288 | if css3: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
289 | vm.newEditor() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
290 | newEditor = vm.activeWindow() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
291 | newEditor.setText(css3) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
292 | newEditor.setLanguage("dummy.css") |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
293 | |
7
e6fbd4a7484d
Some small corrections, added source docu, translations and the other supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
294 | def __html5ToJs(self): |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
295 | """ |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
296 | Private slot handling the HTML5 to JavaScript conversion. |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
297 | """ |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
298 | from ProjectWeb.Html5ToJsConverter import Html5ToJsConverter |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
299 | vm = e5App().getObject("ViewManager") |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
300 | editor = vm.activeWindow() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
301 | html = editor.selectedText() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
302 | |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
303 | converter = Html5ToJsConverter(html) |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
304 | js = converter.getJavaScript() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
305 | |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
306 | if js: |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
307 | vm.newEditor() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
308 | newEditor = vm.activeWindow() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
309 | newEditor.setText(js) |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
310 | newEditor.setLanguage("dummy.js") |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
311 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
312 | def __html5Prettify(self): |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
313 | """ |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
314 | Private slot handling the Prettify HTML action. |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
315 | """ |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
316 | from ProjectWeb.Html5Prettifier import Html5Prettifier |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
317 | editor = e5App().getObject("ViewManager").activeWindow() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
318 | html = editor.text() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
319 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
320 | prettifier = Html5Prettifier(html) |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
321 | newHtml = prettifier.getPrettifiedHtml() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
322 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
323 | if newHtml and newHtml != html: |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
324 | cursorLine, cursorIndex = editor.getCursorPosition() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
325 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
326 | editor.beginUndoAction() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
327 | editor.selectAll() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
328 | editor.replaceSelectedText(newHtml) |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
329 | editor.endUndoAction() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
330 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
331 | editor.setCursorPosition(cursorLine, cursorIndex) |