PluginToolGenerateHash.py

changeset 24
31a6f2b29967
parent 23
014dd5f63240
child 25
681c98f73cbc
equal deleted inserted replaced
23:014dd5f63240 24:31a6f2b29967
21 # Start-Of-Header 21 # Start-Of-Header
22 name = "Generate Hash Tool Plug-in" 22 name = "Generate Hash Tool Plug-in"
23 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 23 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
24 autoactivate = True 24 autoactivate = True
25 deactivateable = True 25 deactivateable = True
26 version = "2.0.0" 26 version = "2.0.1"
27 className = "ToolGenerateHashPlugin" 27 className = "ToolGenerateHashPlugin"
28 packageName = "ToolGenerateHash" 28 packageName = "ToolGenerateHash"
29 shortDescription = "Generate a hash for a selectable file or directory" 29 shortDescription = "Generate a hash for a selectable file or directory"
30 longDescription = \ 30 longDescription = \
31 """Plug-in to generate a hash for a selectable file or directory. The"""\ 31 """Plug-in to generate a hash for a selectable file or directory. The"""\
189 self.__editors[editor].append(act) 189 self.__editors[editor].append(act)
190 act = menu.addMenu(self.__fileMenu) 190 act = menu.addMenu(self.__fileMenu)
191 self.__editors[editor].append(act) 191 self.__editors[editor].append(act)
192 act = menu.addMenu(self.__dirMenu) 192 act = menu.addMenu(self.__dirMenu)
193 self.__editors[editor].append(act) 193 self.__editors[editor].append(act)
194 editor.showMenu.connect(self.__editorShowMenu)
194 195
195 self.__fileMenu.setEnabled(True) 196 self.__fileMenu.setEnabled(True)
196 self.__dirMenu.setEnabled(True) 197 self.__dirMenu.setEnabled(True)
197 198
198 def __editorClosed(self, editor): 199 def __editorClosed(self, editor):
206 if not self.__editors: 207 if not self.__editors:
207 self.__fileMenu.setEnabled(False) 208 self.__fileMenu.setEnabled(False)
208 self.__dirMenu.setEnabled(False) 209 self.__dirMenu.setEnabled(False)
209 except KeyError: 210 except KeyError:
210 pass 211 pass
212
213 def __editorShowMenu(self, menuName, menu, editor):
214 """
215 Private slot called, when the the editor context menu or a submenu is
216 about to be shown.
217
218 @param menuName name of the menu to be shown (string)
219 @param menu reference to the menu (QMenu)
220 @param editor reference to the editor
221 """
222 if menuName == "Tools":
223 if self.__fileMenu.menuAction() not in menu.actions():
224 # Re-add our menu
225 self.__editors[editor] = []
226 if not menu.isEmpty():
227 act = menu.addSeparator()
228 self.__editors[editor].append(act)
229 act = menu.addMenu(self.__fileMenu)
230 self.__editors[editor].append(act)
231 act = menu.addMenu(self.__dirMenu)
232 self.__editors[editor].append(act)
233
234 self.__fileMenu.setEnabled(True)
235 self.__dirMenu.setEnabled(True)
211 236
212 def __insertHash(self, hashStr): 237 def __insertHash(self, hashStr):
213 """ 238 """
214 Private method to insert the generated hash string. 239 Private method to insert the generated hash string.
215 240

eric ide

mercurial