eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/ProjectHelper.py

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

eric ide

mercurial