Plugins/VcsPlugins/vcsMercurial/GpgExtension/ProjectHelper.py

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

eric ide

mercurial