17 # Start-Of-Header |
18 # Start-Of-Header |
18 name = "PySide to PyQt (and vice versa) Plug-in" |
19 name = "PySide to PyQt (and vice versa) Plug-in" |
19 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
20 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
20 autoactivate = True |
21 autoactivate = True |
21 deactivateable = True |
22 deactivateable = True |
22 version = "3.0.0" |
23 version = "3.1.0" |
23 className = "PySide2PyQtPlugin" |
24 className = "PySide2PyQtPlugin" |
24 packageName = "PySide2PyQt" |
25 packageName = "PySide2PyQt" |
25 shortDescription = "Convert PySide file to PyQt and vice versa" |
26 shortDescription = "Convert PySide file to PyQt and vice versa" |
26 longDescription = ( |
27 longDescription = ( |
27 """This plug-in implements a tool to convert a PySide2 file to PyQt5""" |
28 """This plug-in implements a tool to convert a PySide2 file to PyQt5""" |
182 """ |
183 """ |
183 Private slot called, when an editor was closed. |
184 Private slot called, when an editor was closed. |
184 |
185 |
185 @param editor reference to the editor (QScintilla.Editor) |
186 @param editor reference to the editor (QScintilla.Editor) |
186 """ |
187 """ |
187 try: |
188 with contextlib.suppress(KeyError): |
188 del self.__editors[editor] |
189 del self.__editors[editor] |
189 if not self.__editors: |
190 if not self.__editors: |
190 self.__menu.setEnabled(False) |
191 self.__menu.setEnabled(False) |
191 except KeyError: |
|
192 pass |
|
193 |
192 |
194 def __editorShowMenu(self, menuName, menu, editor): |
193 def __editorShowMenu(self, menuName, menu, editor): |
195 """ |
194 """ |
196 Private slot called, when the the editor context menu or a submenu is |
195 Private slot called, when the the editor context menu or a submenu is |
197 about to be shown. |
196 about to be shown. |
198 |
197 |
199 @param menuName name of the menu to be shown (string) |
198 @param menuName name of the menu to be shown (string) |
200 @param menu reference to the menu (QMenu) |
199 @param menu reference to the menu (QMenu) |
201 @param editor reference to the editor |
200 @param editor reference to the editor |
202 """ |
201 """ |
203 if menuName == "Tools": |
202 if ( |
204 if self.__menu.menuAction() not in menu.actions(): |
203 menuName == "Tools" and |
205 # Re-add our menu |
204 self.__menu.menuAction() not in menu.actions() |
206 self.__editors[editor] = [] |
205 ): |
207 if not menu.isEmpty(): |
206 # Re-add our menu |
208 act = menu.addSeparator() |
207 self.__editors[editor] = [] |
209 self.__editors[editor].append(act) |
208 if not menu.isEmpty(): |
210 act = menu.addMenu(self.__menu) |
209 act = menu.addSeparator() |
211 self.__editors[editor].append(act) |
210 self.__editors[editor].append(act) |
|
211 act = menu.addMenu(self.__menu) |
|
212 self.__editors[editor].append(act) |
212 |
213 |
213 def __pyside2Pyqt(self, pyside, pyqt): |
214 def __pyside2Pyqt(self, pyside, pyqt): |
214 """ |
215 """ |
215 Private slot to convert the code of the current editor from PySide |
216 Private slot to convert the code of the current editor from PySide |
216 to PyQt. |
217 to PyQt. |