Plugins/VcsPlugins/vcsMercurial/GpgExtension/ProjectHelper.py

Wed, 02 Jan 2013 10:31:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 02 Jan 2013 10:31:48 +0100
changeset 2302
f29e9405c851
parent 1509
c0b5e693b0eb
child 2525
8b507a9a2d40
child 3023
34ce20603bf7
child 3163
9f50365a0870
permissions
-rw-r--r--

Updated copyright for 2013.

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

eric ide

mercurial