|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the gpg extension project helper. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QMenu |
|
11 |
|
12 from E5Gui.E5Action import E5Action |
|
13 |
|
14 from ..HgExtensionProjectHelper import HgExtensionProjectHelper |
|
15 |
|
16 import UI.PixmapCache |
|
17 |
|
18 |
|
19 class GpgProjectHelper(HgExtensionProjectHelper): |
|
20 """ |
|
21 Class implementing the gpg extension project helper. |
|
22 """ |
|
23 def __init__(self): |
|
24 """ |
|
25 Constructor |
|
26 """ |
|
27 super().__init__() |
|
28 |
|
29 def initActions(self): |
|
30 """ |
|
31 Public method to generate the action objects. |
|
32 """ |
|
33 self.hgGpgListAct = E5Action( |
|
34 self.tr('List Signed Changesets'), |
|
35 UI.PixmapCache.getIcon("changesetSignList"), |
|
36 self.tr('List Signed Changesets...'), |
|
37 0, 0, self, 'mercurial_gpg_list') |
|
38 self.hgGpgListAct.setStatusTip(self.tr( |
|
39 'List signed changesets' |
|
40 )) |
|
41 self.hgGpgListAct.setWhatsThis(self.tr( |
|
42 """<b>List Signed Changesets</b>""" |
|
43 """<p>This opens a dialog listing all signed changesets.</p>""" |
|
44 )) |
|
45 self.hgGpgListAct.triggered.connect(self.__hgGpgSignatures) |
|
46 self.actions.append(self.hgGpgListAct) |
|
47 |
|
48 self.hgGpgVerifyAct = E5Action( |
|
49 self.tr('Verify Signatures'), |
|
50 UI.PixmapCache.getIcon("changesetSignVerify"), |
|
51 self.tr('Verify Signatures'), |
|
52 0, 0, self, 'mercurial_gpg_verify') |
|
53 self.hgGpgVerifyAct.setStatusTip(self.tr( |
|
54 'Verify all signatures there may be for a particular revision' |
|
55 )) |
|
56 self.hgGpgVerifyAct.setWhatsThis(self.tr( |
|
57 """<b>Verify Signatures</b>""" |
|
58 """<p>This verifies all signatures there may be for a particular""" |
|
59 """ revision.</p>""" |
|
60 )) |
|
61 self.hgGpgVerifyAct.triggered.connect(self.__hgGpgVerifySignatures) |
|
62 self.actions.append(self.hgGpgVerifyAct) |
|
63 |
|
64 self.hgGpgSignAct = E5Action( |
|
65 self.tr('Sign Revision'), |
|
66 UI.PixmapCache.getIcon("changesetSign"), |
|
67 self.tr('Sign Revision'), |
|
68 0, 0, self, 'mercurial_gpg_sign') |
|
69 self.hgGpgSignAct.setStatusTip(self.tr( |
|
70 'Add a signature for a selected revision' |
|
71 )) |
|
72 self.hgGpgSignAct.setWhatsThis(self.tr( |
|
73 """<b>Sign Revision</b>""" |
|
74 """<p>This adds a signature for a selected revision.</p>""" |
|
75 )) |
|
76 self.hgGpgSignAct.triggered.connect(self.__hgGpgSign) |
|
77 self.actions.append(self.hgGpgSignAct) |
|
78 |
|
79 def initMenu(self, mainMenu): |
|
80 """ |
|
81 Public method to generate the extension menu. |
|
82 |
|
83 @param mainMenu reference to the main menu (QMenu) |
|
84 @return populated menu (QMenu) |
|
85 """ |
|
86 menu = QMenu(self.menuTitle(), mainMenu) |
|
87 menu.setIcon(UI.PixmapCache.getIcon("changesetSign")) |
|
88 menu.setTearOffEnabled(True) |
|
89 |
|
90 menu.addAction(self.hgGpgListAct) |
|
91 menu.addAction(self.hgGpgVerifyAct) |
|
92 menu.addAction(self.hgGpgSignAct) |
|
93 |
|
94 return menu |
|
95 |
|
96 def menuTitle(self): |
|
97 """ |
|
98 Public method to get the menu title. |
|
99 |
|
100 @return title of the menu (string) |
|
101 """ |
|
102 return self.tr("GPG") |
|
103 |
|
104 def __hgGpgSignatures(self): |
|
105 """ |
|
106 Private slot used to list all signed changesets. |
|
107 """ |
|
108 self.vcs.getExtensionObject("gpg").hgGpgSignatures() |
|
109 |
|
110 def __hgGpgVerifySignatures(self): |
|
111 """ |
|
112 Private slot used to verify the signatures of a revision. |
|
113 """ |
|
114 self.vcs.getExtensionObject("gpg").hgGpgVerifySignatures() |
|
115 |
|
116 def __hgGpgSign(self): |
|
117 """ |
|
118 Private slot used to sign a revision. |
|
119 """ |
|
120 self.vcs.getExtensionObject("gpg").hgGpgSign() |