Tue, 23 Jun 2020 18:59:26 +0200
Removed support for Python2.
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 | |
29
38577502d613
Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
28
diff
changeset
|
3 | # Copyright (c) 2014 - 2020 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 | import os |
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 | 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
|
13 | 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
|
14 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
15 | 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
|
16 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
17 | import Preferences |
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 | try: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
20 | 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
|
21 | BeautifulSoupAvailable = True |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
22 | except ImportError: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
23 | BeautifulSoup = None |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
24 | BeautifulSoupAvailable = False |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
25 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
26 | # Start-Of-Header |
17
ea6168970971
Corrected the name header variable.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
27 | 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
|
28 | 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
|
29 | autoactivate = True |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
30 | deactivateable = True |
30
38092622e612
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
29
diff
changeset
|
31 | version = "2.0.0" |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
32 | className = "ProjectWebPlugin" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
33 | packageName = "ProjectWeb" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
34 | 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
|
35 | longDescription = ( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
36 | """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
|
37 | """ 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
|
38 | """ functionality.""" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
39 | ) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
40 | needsRestart = False |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
41 | pyqtApi = 2 |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
42 | # 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
|
43 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
44 | error = "" |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
45 | |
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 | 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
|
48 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
49 | 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
|
50 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
51 | 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
|
52 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
53 | Constructor |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
54 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
55 | @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
|
56 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
57 | 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
|
58 | 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
|
59 | self.__initialize() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
60 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
61 | 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
|
62 | self.__loadTranslator() |
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.__initMenu() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
65 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
66 | 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
|
67 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
68 | 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
|
69 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
70 | 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
|
71 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
72 | self.__editors = {} |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
73 | 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
|
74 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
75 | 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
|
76 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
77 | 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
|
78 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
79 | @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
|
80 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
81 | global error |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
82 | 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
|
83 | |
8
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
84 | # it is not registered for a specific programming language |
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
85 | self.__e5project.registerProjectType( |
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
86 | "Web", self.tr("Web"), |
ac63923ca45b
Prepared first development release.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
87 | 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
|
88 | |
30
38092622e612
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
29
diff
changeset
|
89 | from Project.ProjectBrowser import ( |
38092622e612
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
29
diff
changeset
|
90 | SourcesBrowserFlag, FormsBrowserFlag, OthersBrowserFlag |
38092622e612
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
29
diff
changeset
|
91 | ) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
92 | Preferences.setProjectBrowserFlagsDefault( |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
93 | "Web", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
94 | 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
|
95 | ) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
96 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
97 | 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
|
98 | |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
99 | 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
|
100 | 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
|
101 | if not menu.isEmpty(): |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
102 | act = menu.addSeparator() |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
103 | self.__mainActions.append(act) |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
104 | 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
|
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 | |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
107 | 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
|
108 | self.__editorOpened) |
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").editorClosedEd.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.__editorClosed) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
111 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
112 | 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
|
113 | 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
|
114 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
115 | 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
|
116 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
117 | 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
|
118 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
119 | 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
|
120 | """ |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
121 | 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
|
122 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
123 | 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
|
124 | |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | menu.removeAction(act) |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
129 | self.__mainActions = [] |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
130 | |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
131 | 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
|
132 | self.__editorOpened) |
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").editorClosedEd.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.__editorClosed) |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
135 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | 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
|
141 | 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
|
142 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
143 | self.__initialize() |
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 | 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
|
146 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
147 | 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
|
148 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
149 | 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
|
150 | 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
|
151 | 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
|
152 | 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
|
153 | os.path.dirname(__file__), "ProjectWeb", "i18n") |
22
0da9392cdde8
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
21
diff
changeset
|
154 | translation = "web_{0}".format(loc) |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
155 | 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
|
156 | 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
|
157 | if loaded: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
158 | 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
|
159 | 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
|
160 | else: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
161 | 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
|
162 | " 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
|
163 | 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
|
164 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
165 | 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
|
166 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
167 | 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
|
168 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
169 | @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
|
170 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
171 | if self.__e5project.getProjectType() == "Web": |
30
38092622e612
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
29
diff
changeset
|
172 | return { |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
173 | "*.html": "FORMS", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
174 | "*.htm": "FORMS", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
175 | "*.js": "SOURCES", |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
176 | } |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
177 | else: |
30
38092622e612
Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
29
diff
changeset
|
178 | return {} |
1
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
179 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
180 | 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
|
181 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
182 | 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
|
183 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
184 | 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
|
185 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
186 | 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
|
187 | "HTML5 to CSS3"), self.__html5ToCss3) |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
188 | 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
|
189 | "HTML5 to JavaScript"), self.__html5ToJs) |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
190 | self.__menu.addSeparator() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
191 | self.__html5PrettifyAct = self.__menu.addAction(self.tr( |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
192 | "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
|
193 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
194 | 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
|
195 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
196 | 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
|
197 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
198 | 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
|
199 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
200 | 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
|
201 | 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
|
202 | isHtml = bool(editor and |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
203 | 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
|
204 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
205 | self.__html5ToCss3Act.setEnabled( |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
206 | selectionAvailable and BeautifulSoupAvailable and isHtml) |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
207 | self.__html5ToJsAct.setEnabled( |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
208 | selectionAvailable and BeautifulSoupAvailable and isHtml) |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
209 | self.__html5PrettifyAct.setEnabled( |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
210 | 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
|
211 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
212 | 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
|
213 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
214 | 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
|
215 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
216 | @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
|
217 | @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
|
218 | """ |
12
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
219 | 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
|
220 | return |
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 == "Tools": |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
223 | if not menu.isEmpty(): |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
224 | menu.addSeparator() |
231a6fbd6f0f
Adaptation for the new plug-in tools menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
225 | 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
|
226 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
227 | 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
|
228 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
229 | 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
|
230 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
231 | @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
|
232 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
233 | 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
|
234 | 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
|
235 | 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
|
236 | 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
|
237 | 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
|
238 | 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
|
239 | 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
|
240 | self.__editors[editor].append(act) |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
241 | 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
|
242 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
243 | 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
|
244 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
245 | 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
|
246 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
247 | @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
|
248 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
249 | try: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
250 | 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
|
251 | except KeyError: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
252 | pass |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
253 | |
6
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
254 | def __editorShowMenu(self, menuName, menu, editor): |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
255 | """ |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
256 | 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
|
257 | about to be shown. |
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 | @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
|
260 | @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
|
261 | @param editor reference to the editor |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
262 | """ |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
263 | if menuName == "Tools": |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
264 | 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
|
265 | # Re-add our menu |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
266 | self.__editors[editor] = [] |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
267 | if not menu.isEmpty(): |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
268 | act = menu.addSeparator() |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
269 | self.__editors[editor].append(act) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
270 | act = menu.addMenu(self.__menu) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
271 | self.__editors[editor].append(act) |
a1600fa29542
A few fixes and code style corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5
diff
changeset
|
272 | |
7
e6fbd4a7484d
Some small corrections, added source docu, translations and the other supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
273 | 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
|
274 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
275 | 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
|
276 | """ |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
277 | 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
|
278 | 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
|
279 | 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
|
280 | 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
|
281 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
282 | 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
|
283 | 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
|
284 | |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
285 | if css3: |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
286 | vm.newEditor() |
e3a92a671aa5
Added the 'Web' project type and the HTML5 to CSS3 converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
287 | 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
|
288 | 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
|
289 | newEditor.setLanguage("dummy.css") |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
290 | |
7
e6fbd4a7484d
Some small corrections, added source docu, translations and the other supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
291 | def __html5ToJs(self): |
3
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
292 | """ |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
293 | 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
|
294 | """ |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
295 | from ProjectWeb.Html5ToJsConverter import Html5ToJsConverter |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
296 | vm = e5App().getObject("ViewManager") |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
297 | editor = vm.activeWindow() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
298 | html = editor.selectedText() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
299 | |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
300 | converter = Html5ToJsConverter(html) |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
301 | js = converter.getJavaScript() |
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 | if js: |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
304 | vm.newEditor() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
305 | newEditor = vm.activeWindow() |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
306 | newEditor.setText(js) |
e478a359e1fb
Added the HTML5 to JavaScript converter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1
diff
changeset
|
307 | newEditor.setLanguage("dummy.js") |
5
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
308 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
309 | def __html5Prettify(self): |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
310 | """ |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
311 | Private slot handling the Prettify HTML action. |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
312 | """ |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
313 | from ProjectWeb.Html5Prettifier import Html5Prettifier |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
314 | editor = e5App().getObject("ViewManager").activeWindow() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
315 | html = editor.text() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
316 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
317 | prettifier = Html5Prettifier(html) |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
318 | newHtml = prettifier.getPrettifiedHtml() |
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 | if newHtml and newHtml != html: |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
321 | cursorLine, cursorIndex = editor.getCursorPosition() |
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 | editor.beginUndoAction() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
324 | editor.selectAll() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
325 | editor.replaceSelectedText(newHtml) |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
326 | editor.endUndoAction() |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
327 | |
31bc1ef6f624
Added the HTML prettifier.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
328 | editor.setCursorPosition(cursorLine, cursorIndex) |
22
0da9392cdde8
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
21
diff
changeset
|
329 | |
0da9392cdde8
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
21
diff
changeset
|
330 | # |
0da9392cdde8
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
21
diff
changeset
|
331 | # eflag: noqa = M801 |