19 # Start-Of-Header |
20 # Start-Of-Header |
20 name = "Print Remover Plug-in" |
21 name = "Print Remover Plug-in" |
21 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
22 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
22 autoactivate = True |
23 autoactivate = True |
23 deactivateable = True |
24 deactivateable = True |
24 version = "3.0.0" |
25 version = "3.1.0" |
25 className = "PrintRemoverPlugin" |
26 className = "PrintRemoverPlugin" |
26 packageName = "PrintRemover" |
27 packageName = "PrintRemover" |
27 shortDescription = "Remove print() like debug statements." |
28 shortDescription = "Remove print() like debug statements." |
28 longDescription = ( |
29 longDescription = ( |
29 """This plug-in implements a tool to remove lines starting with""" |
30 """This plug-in implements a tool to remove lines starting with""" |
62 @return dictionary containing the relevant data |
63 @return dictionary containing the relevant data |
63 """ |
64 """ |
64 try: |
65 try: |
65 usesDarkPalette = e5App().usesDarkPalette() |
66 usesDarkPalette = e5App().usesDarkPalette() |
66 except AttributeError: |
67 except AttributeError: |
|
68 # for eric6 < 20.4 |
67 from PyQt5.QtGui import QPalette |
69 from PyQt5.QtGui import QPalette |
68 palette = e5App().palette() |
70 palette = e5App().palette() |
69 lightness = palette.color(QPalette.Window).lightness() |
71 lightness = palette.color(QPalette.Window).lightness() |
70 usesDarkPalette = lightness <= 128 |
72 usesDarkPalette = lightness <= 128 |
71 if usesDarkPalette: |
73 iconSuffix = "dark" if usesDarkPalette else "light" |
72 iconSuffix = "dark" |
|
73 else: |
|
74 iconSuffix = "light" |
|
75 |
74 |
76 return { |
75 return { |
77 "printRemoverPage": [ |
76 "printRemoverPage": [ |
78 QCoreApplication.translate("PrintRemoverPlugin", |
77 QCoreApplication.translate("PrintRemoverPlugin", |
79 "Print Remover"), |
78 "Print Remover"), |
100 """ |
99 """ |
101 Constructor |
100 Constructor |
102 |
101 |
103 @param ui reference to the user interface object (UI.UserInterface) |
102 @param ui reference to the user interface object (UI.UserInterface) |
104 """ |
103 """ |
105 QObject.__init__(self, ui) |
104 super().__init__(ui) |
106 self.__ui = ui |
105 self.__ui = ui |
107 |
106 |
108 self.__defaults = { |
107 self.__defaults = { |
109 "StartswithStrings": [ |
108 "StartswithStrings": [ |
110 "print(", "print ", "console.log"], |
109 "print(", "print ", "console.log"], |
270 """ |
269 """ |
271 Private slot called, when an editor was closed. |
270 Private slot called, when an editor was closed. |
272 |
271 |
273 @param editor reference to the editor (QScintilla.Editor) |
272 @param editor reference to the editor (QScintilla.Editor) |
274 """ |
273 """ |
275 try: |
274 with contextlib.suppress(KeyError): |
276 del self.__editors[editor] |
275 del self.__editors[editor] |
277 if not self.__editors: |
276 if not self.__editors: |
278 self.__menu.setEnabled(False) |
277 self.__menu.setEnabled(False) |
279 except KeyError: |
|
280 pass |
|
281 |
278 |
282 def __editorShowMenu(self, menuName, menu, editor): |
279 def __editorShowMenu(self, menuName, menu, editor): |
283 """ |
280 """ |
284 Private slot called, when the the editor context menu or a submenu is |
281 Private slot called, when the the editor context menu or a submenu is |
285 about to be shown. |
282 about to be shown. |
286 |
283 |
287 @param menuName name of the menu to be shown (string) |
284 @param menuName name of the menu to be shown (string) |
288 @param menu reference to the menu (QMenu) |
285 @param menu reference to the menu (QMenu) |
289 @param editor reference to the editor |
286 @param editor reference to the editor |
290 """ |
287 """ |
291 if menuName == "Tools": |
288 if ( |
292 if self.__menu.menuAction() not in menu.actions(): |
289 menuName == "Tools" and |
293 # Re-add our menu |
290 self.__menu.menuAction() not in menu.actions() |
294 self.__editors[editor] = [] |
291 ): |
295 if not menu.isEmpty(): |
292 # Re-add our menu |
296 act = menu.addSeparator() |
293 self.__editors[editor] = [] |
297 self.__editors[editor].append(act) |
294 if not menu.isEmpty(): |
298 act = menu.addMenu(self.__menu) |
295 act = menu.addSeparator() |
299 self.__editors[editor].append(act) |
296 self.__editors[editor].append(act) |
|
297 act = menu.addMenu(self.__menu) |
|
298 self.__editors[editor].append(act) |
300 |
299 |
301 def __showMenu(self): |
300 def __showMenu(self): |
302 """ |
301 """ |
303 Private slot to build the menu hierarchy. |
302 Private slot to build the menu hierarchy. |
304 """ |
303 """ |