18 # Start-Of-Header |
18 # Start-Of-Header |
19 name = "Camel Case Handling Plug-in" |
19 name = "Camel Case Handling Plug-in" |
20 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
20 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
21 autoactivate = True |
21 autoactivate = True |
22 deactivateable = True |
22 deactivateable = True |
23 version = "2.0.2" |
23 version = "2.1.0" |
24 className = "SplitMergeCamelCasePlugin" |
24 className = "SplitMergeCamelCasePlugin" |
25 packageName = "SplitMergeCamelCase" |
25 packageName = "SplitMergeCamelCase" |
26 shortDescription = "Split, merge or convert camel case text" |
26 shortDescription = "Split, merge or convert camel case text" |
27 longDescription = \ |
27 longDescription = \ |
28 """This plug-in implements a tool to split, merge or convert""" \ |
28 """This plug-in implements a tool to split, merge or convert""" \ |
65 """ |
66 """ |
66 global error |
67 global error |
67 error = "" # clear previous error |
68 error = "" # clear previous error |
68 |
69 |
69 self.__ui.showMenu.connect(self.__populateMenu) |
70 self.__ui.showMenu.connect(self.__populateMenu) |
|
71 |
|
72 menu = self.__ui.getMenu("plugin_tools") |
|
73 if menu is not None: |
|
74 if not menu.isEmpty(): |
|
75 act = menu.addSeparator() |
|
76 self.__mainActions.append(act) |
|
77 act = menu.addMenu(self.__menu) |
|
78 self.__mainActions.append(act) |
70 |
79 |
71 e5App().getObject("ViewManager").editorOpenedEd.connect( |
80 e5App().getObject("ViewManager").editorOpenedEd.connect( |
72 self.__editorOpened) |
81 self.__editorOpened) |
73 e5App().getObject("ViewManager").editorClosedEd.connect( |
82 e5App().getObject("ViewManager").editorClosedEd.connect( |
74 self.__editorClosed) |
83 self.__editorClosed) |
82 """ |
91 """ |
83 Public method to deactivate this plugin. |
92 Public method to deactivate this plugin. |
84 """ |
93 """ |
85 self.__ui.showMenu.disconnect(self.__populateMenu) |
94 self.__ui.showMenu.disconnect(self.__populateMenu) |
86 |
95 |
|
96 menu = self.__ui.getMenu("plugin_tools") |
|
97 if menu is not None: |
|
98 for act in self.__mainActions: |
|
99 menu.removeAction(act) |
|
100 self.__mainActions = [] |
|
101 |
87 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
102 e5App().getObject("ViewManager").editorOpenedEd.disconnect( |
88 self.__editorOpened) |
103 self.__editorOpened) |
89 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
104 e5App().getObject("ViewManager").editorClosedEd.disconnect( |
90 self.__editorClosed) |
105 self.__editorClosed) |
91 |
106 |
139 Private slot to populate the tools menu with our entries. |
154 Private slot to populate the tools menu with our entries. |
140 |
155 |
141 @param name name of the menu (string) |
156 @param name name of the menu (string) |
142 @param menu reference to the menu to be populated (QMenu) |
157 @param menu reference to the menu to be populated (QMenu) |
143 """ |
158 """ |
144 if name != "Tools": |
159 if name not in ["Tools", "PluginTools"]: |
145 return |
160 return |
146 |
161 |
147 editor = e5App().getObject("ViewManager").activeWindow() |
162 editor = e5App().getObject("ViewManager").activeWindow() |
148 |
163 |
149 if not menu.isEmpty(): |
164 if name == "Tools": |
150 menu.addSeparator() |
165 if not menu.isEmpty(): |
151 |
166 menu.addSeparator() |
152 act = menu.addMenu(self.__menu) |
167 act = menu.addMenu(self.__menu) |
153 act.setEnabled(editor is not None and editor.selectedText() != '') |
168 act.setEnabled(editor is not None and editor.hasSelectedText()) |
|
169 elif name == "PluginTools" and self.__mainActions: |
|
170 self.__menu.setEnabled(editor is not None and |
|
171 editor.hasSelectedText()) |
154 |
172 |
155 def __editorOpened(self, editor): |
173 def __editorOpened(self, editor): |
156 """ |
174 """ |
157 Private slot called, when a new editor was opened. |
175 Private slot called, when a new editor was opened. |
158 |
176 |
196 act = menu.addSeparator() |
214 act = menu.addSeparator() |
197 self.__editors[editor].append(act) |
215 self.__editors[editor].append(act) |
198 act = menu.addMenu(self.__menu) |
216 act = menu.addMenu(self.__menu) |
199 self.__editors[editor].append(act) |
217 self.__editors[editor].append(act) |
200 |
218 |
201 self.__menu.setEnabled(editor.selectedText() != '') |
219 self.__menu.setEnabled(editor.hasSelectedText()) |
202 |
220 |
203 def __applyChange(self, newText, editor): |
221 def __applyChange(self, newText, editor): |
204 """ |
222 """ |
205 Private method to change the selected text. |
223 Private method to change the selected text. |
206 |
224 |