19 # Start-Of-Header |
20 # Start-Of-Header |
20 name = "Generate Hash Tool Plug-in" |
21 name = "Generate Hash Tool 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.1.0" |
25 version = "3.2.0" |
25 className = "ToolGenerateHashPlugin" |
26 className = "ToolGenerateHashPlugin" |
26 packageName = "ToolGenerateHash" |
27 packageName = "ToolGenerateHash" |
27 shortDescription = "Generate a hash for a selectable file or directory" |
28 shortDescription = "Generate a hash for a selectable file or directory" |
28 longDescription = ( |
29 longDescription = ( |
29 """Plug-in to generate a hash for a selectable file or directory. The""" |
30 """Plug-in to generate a hash for a selectable file or directory. The""" |
220 """ |
221 """ |
221 Private slot called, when an editor was closed. |
222 Private slot called, when an editor was closed. |
222 |
223 |
223 @param editor reference to the editor (QScintilla.Editor) |
224 @param editor reference to the editor (QScintilla.Editor) |
224 """ |
225 """ |
225 try: |
226 with contextlib.suppress(KeyError): |
226 del self.__editors[editor] |
227 del self.__editors[editor] |
227 if not self.__editors: |
228 if not self.__editors: |
228 self.__fileMenu.setEnabled(False) |
229 self.__fileMenu.setEnabled(False) |
229 self.__dirMenu.setEnabled(False) |
230 self.__dirMenu.setEnabled(False) |
230 except KeyError: |
|
231 pass |
|
232 |
231 |
233 def __editorShowMenu(self, menuName, menu, editor): |
232 def __editorShowMenu(self, menuName, menu, editor): |
234 """ |
233 """ |
235 Private slot called, when the the editor context menu or a submenu is |
234 Private slot called, when the the editor context menu or a submenu is |
236 about to be shown. |
235 about to be shown. |
237 |
236 |
238 @param menuName name of the menu to be shown (string) |
237 @param menuName name of the menu to be shown (string) |
239 @param menu reference to the menu (QMenu) |
238 @param menu reference to the menu (QMenu) |
240 @param editor reference to the editor |
239 @param editor reference to the editor |
241 """ |
240 """ |
242 if menuName == "Tools": |
241 if ( |
243 if self.__fileMenu.menuAction() not in menu.actions(): |
242 menuName == "Tools" and |
244 # Re-add our menu |
243 self.__fileMenu.menuAction() not in menu.actions() |
245 self.__editors[editor] = [] |
244 ): |
246 if not menu.isEmpty(): |
245 # Re-add our menu |
247 act = menu.addSeparator() |
246 self.__editors[editor] = [] |
248 self.__editors[editor].append(act) |
247 if not menu.isEmpty(): |
249 act = menu.addMenu(self.__fileMenu) |
248 act = menu.addSeparator() |
250 self.__editors[editor].append(act) |
249 self.__editors[editor].append(act) |
251 act = menu.addMenu(self.__dirMenu) |
250 act = menu.addMenu(self.__fileMenu) |
252 self.__editors[editor].append(act) |
251 self.__editors[editor].append(act) |
253 |
252 act = menu.addMenu(self.__dirMenu) |
254 self.__fileMenu.setEnabled(True) |
253 self.__editors[editor].append(act) |
255 self.__dirMenu.setEnabled(True) |
254 |
|
255 self.__fileMenu.setEnabled(True) |
|
256 self.__dirMenu.setEnabled(True) |
256 |
257 |
257 def __insertHash(self, hashStr): |
258 def __insertHash(self, hashStr): |
258 """ |
259 """ |
259 Private method to insert the generated hash string. |
260 Private method to insert the generated hash string. |
260 |
261 |