Mon, 23 Dec 2013 19:02:04 +0100
Added support for the editor Tools context menu (as of eric5 5.4.0).
--- a/ChangeLog Mon Dec 23 15:59:23 2013 +0100 +++ b/ChangeLog Mon Dec 23 19:02:04 2013 +0100 @@ -1,5 +1,8 @@ ChangeLog --------- +Version 0.3.0: +- added support for the editor Tools context menu (as of eric5 5.4.0) + Version 0.2.0: - added Spanish translations provided by Jaime Seuma
--- a/PluginSplitMergeCamelCase.py Mon Dec 23 15:59:23 2013 +0100 +++ b/PluginSplitMergeCamelCase.py Mon Dec 23 19:02:04 2013 +0100 @@ -20,7 +20,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "0.2.0" +version = "0.3.0" className = "SplitMergeCamelCasePlugin" packageName = "SplitMergeCamelCase" shortDescription = "Split, merge or convert camel case text" @@ -53,6 +53,8 @@ self.__loadTranslator() self.__initMenu() + + self.__editors = {} def activate(self): """ @@ -65,6 +67,14 @@ self.__ui.showMenu.connect(self.__populateMenu) + e5App().getObject("ViewManager").editorOpenedEd.connect( + self.__editorOpened) + e5App().getObject("ViewManager").editorClosedEd.connect( + self.__editorClosed) + + for editor in e5App().getObject("ViewManager").getOpenEditors(): + self.__editorOpened(editor) + return None, True def deactivate(self): @@ -72,6 +82,18 @@ Public method to deactivate this plugin. """ self.__ui.showMenu.disconnect(self.__populateMenu) + + e5App().getObject("ViewManager").editorOpenedEd.disconnect( + self.__editorOpened) + e5App().getObject("ViewManager").editorClosedEd.disconnect( + self.__editorClosed) + + for editor, act in self.__editors.items(): + editor.showMenu.disconnect(self.__editorShowMenu) + menu = editor.getMenu("Tools") + if menu is not None: + menu.removeAction(act) + self.__editors = {} def __loadTranslator(self): """ @@ -130,6 +152,41 @@ act = menu.addMenu(self.__menu) act.setEnabled(editor.hasSelectedText()) + def __editorOpened(self, editor): + """ + Private slot called, when a new editor was opened. + + @param editor reference to the new editor (QScintilla.Editor) + """ + menu = editor.getMenu("Tools") + if menu is not None: + act = menu.addMenu(self.__menu) + editor.showMenu.connect(self.__editorShowMenu) + self.__editors[editor] = act + + def __editorClosed(self, editor): + """ + Private slot called, when an editor was closed. + + @param editor reference to the editor (QScintilla.Editor) + """ + try: + del self.__editors[editor] + except KeyError: + pass + + def __editorShowMenu(self, menuName, menu, editor): + """ + Private slot called, when the the editor context menu or a submenu is + about to be shown. + + @param menuName name of the menu to be shown (string) + @param menu reference to the menu (QMenu) + @param editor reference to the editor + """ + if menuName == "Tools": + self.__menu.setEnabled(editor.hasSelectedText()) + def __applyChange(self, newText, editor): """ Private method to change the selected text.
--- a/SplitMergeCamelCase/Documentation/source/Plugin_Tools_SplitMergeCamelCase.PluginSplitMergeCamelCase.html Mon Dec 23 15:59:23 2013 +0100 +++ b/SplitMergeCamelCase/Documentation/source/Plugin_Tools_SplitMergeCamelCase.PluginSplitMergeCamelCase.html Mon Dec 23 19:02:04 2013 +0100 @@ -66,6 +66,15 @@ <td><a href="#SplitMergeCamelCasePlugin.__camelCaseToUnderscore">__camelCaseToUnderscore</a></td> <td>Private slot to convert camel case text to underscore separated text.</td> </tr><tr> +<td><a href="#SplitMergeCamelCasePlugin.__editorClosed">__editorClosed</a></td> +<td>Private slot called, when an editor was closed.</td> +</tr><tr> +<td><a href="#SplitMergeCamelCasePlugin.__editorOpened">__editorOpened</a></td> +<td>Private slot called, when a new editor was opened.</td> +</tr><tr> +<td><a href="#SplitMergeCamelCasePlugin.__editorShowMenu">__editorShowMenu</a></td> +<td>Private slot called, when the the editor context menu or a submenu is about to be shown.</td> +</tr><tr> <td><a href="#SplitMergeCamelCasePlugin.__initMenu">__initMenu</a></td> <td>Private method to initialize the camel case handling menu.</td> </tr><tr> @@ -127,7 +136,44 @@ <b>__camelCaseToUnderscore</b>(<i></i>) <p> Private slot to convert camel case text to underscore separated text. -</p><a NAME="SplitMergeCamelCasePlugin.__initMenu" ID="SplitMergeCamelCasePlugin.__initMenu"></a> +</p><a NAME="SplitMergeCamelCasePlugin.__editorClosed" ID="SplitMergeCamelCasePlugin.__editorClosed"></a> +<h4>SplitMergeCamelCasePlugin.__editorClosed</h4> +<b>__editorClosed</b>(<i>editor</i>) +<p> + Private slot called, when an editor was closed. +</p><dl> +<dt><i>editor</i></dt> +<dd> +reference to the editor (QScintilla.Editor) +</dd> +</dl><a NAME="SplitMergeCamelCasePlugin.__editorOpened" ID="SplitMergeCamelCasePlugin.__editorOpened"></a> +<h4>SplitMergeCamelCasePlugin.__editorOpened</h4> +<b>__editorOpened</b>(<i>editor</i>) +<p> + Private slot called, when a new editor was opened. +</p><dl> +<dt><i>editor</i></dt> +<dd> +reference to the new editor (QScintilla.Editor) +</dd> +</dl><a NAME="SplitMergeCamelCasePlugin.__editorShowMenu" ID="SplitMergeCamelCasePlugin.__editorShowMenu"></a> +<h4>SplitMergeCamelCasePlugin.__editorShowMenu</h4> +<b>__editorShowMenu</b>(<i>menuName, menu, editor</i>) +<p> + Private slot called, when the the editor context menu or a submenu is + about to be shown. +</p><dl> +<dt><i>menuName</i></dt> +<dd> +name of the menu to be shown (string) +</dd><dt><i>menu</i></dt> +<dd> +reference to the menu (QMenu) +</dd><dt><i>editor</i></dt> +<dd> +reference to the editor +</dd> +</dl><a NAME="SplitMergeCamelCasePlugin.__initMenu" ID="SplitMergeCamelCasePlugin.__initMenu"></a> <h4>SplitMergeCamelCasePlugin.__initMenu</h4> <b>__initMenu</b>(<i></i>) <p>
--- a/SplitMergeCamelCase/i18n/splitmergecamelcase_de.ts Mon Dec 23 15:59:23 2013 +0100 +++ b/SplitMergeCamelCase/i18n/splitmergecamelcase_de.ts Mon Dec 23 19:02:04 2013 +0100 @@ -1,35 +1,34 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.0" language="de_DE"> +<!DOCTYPE TS><TS version="2.0" language="de_DE" sourcelanguage=""> <context> <name>SplitMergeCamelCasePlugin</name> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="101"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="123"/> <source>CamelCase Handling</source> <translation>Groß-/Kleinschreibungsbehandlung</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="102"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="124"/> <source>Split from CamelCase</source> <translation>An Großbuchstaben auftrennen</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="104"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="126"/> <source>Merge to CamelCase</source> <translation>An Großbuchstaben zusammenführen</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="106"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="128"/> <source>CamelCase to under_score</source> <translation>Groß-/Kleinschreibung zu Unterstrich</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="108"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="130"/> <source>under_score to CamelCase</source> <translation>Unterstrich zu Groß-/Kleinschreibung</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="110"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="132"/> <source>under_score to CamelCase (upper case first)</source> <translation>Unterstrich zu Groß-/Kleinschreibung (kleiner erster Buchstabe)</translation> </message>
--- a/SplitMergeCamelCase/i18n/splitmergecamelcase_en.ts Mon Dec 23 15:59:23 2013 +0100 +++ b/SplitMergeCamelCase/i18n/splitmergecamelcase_en.ts Mon Dec 23 19:02:04 2013 +0100 @@ -1,35 +1,34 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.0" language="en_US"> +<!DOCTYPE TS><TS version="2.0" language="en_US" sourcelanguage=""> <context> <name>SplitMergeCamelCasePlugin</name> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="101"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="123"/> <source>CamelCase Handling</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="102"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="124"/> <source>Split from CamelCase</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="104"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="126"/> <source>Merge to CamelCase</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="106"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="128"/> <source>CamelCase to under_score</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="108"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="130"/> <source>under_score to CamelCase</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="110"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="132"/> <source>under_score to CamelCase (upper case first)</source> <translation type="unfinished"></translation> </message>
--- a/SplitMergeCamelCase/i18n/splitmergecamelcase_es.ts Mon Dec 23 15:59:23 2013 +0100 +++ b/SplitMergeCamelCase/i18n/splitmergecamelcase_es.ts Mon Dec 23 19:02:04 2013 +0100 @@ -1,35 +1,34 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.0" language="es_ES"> +<!DOCTYPE TS><TS version="2.0" language="es_ES" sourcelanguage=""> <context> <name>SplitMergeCamelCasePlugin</name> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="101"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="123"/> <source>CamelCase Handling</source> <translation>Manejo de CamelCase</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="102"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="124"/> <source>Split from CamelCase</source> <translation>Dividir a partir de CamelCase</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="104"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="126"/> <source>Merge to CamelCase</source> <translation>Mezclar como CamelCase</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="106"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="128"/> <source>CamelCase to under_score</source> <translation>CamelCase a guión_bajo</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="108"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="130"/> <source>under_score to CamelCase</source> <translation>guión_bajo a CamelCase</translation> </message> <message> - <location filename="../../PluginSplitMergeCamelCase.py" line="110"/> + <location filename="../../PluginSplitMergeCamelCase.py" line="132"/> <source>under_score to CamelCase (upper case first)</source> <translation>guión_bajo a CamelCase (mayúscula primero)</translation> </message>