|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the closehead 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 CloseheadProjectHelper(HgExtensionProjectHelper): |
|
22 """ |
|
23 Class implementing the closehead extension project helper. |
|
24 """ |
|
25 def __init__(self): |
|
26 """ |
|
27 Constructor |
|
28 """ |
|
29 super(CloseheadProjectHelper, self).__init__() |
|
30 |
|
31 def initActions(self): |
|
32 """ |
|
33 Public method to generate the action objects. |
|
34 """ |
|
35 self.hgCloseheadAct = E5Action( |
|
36 self.tr('Close Heads'), |
|
37 UI.PixmapCache.getIcon("closehead"), |
|
38 self.tr('Close Heads'), |
|
39 0, 0, self, 'mercurial_closehead') |
|
40 self.hgCloseheadAct.setStatusTip(self.tr( |
|
41 'Close arbitrary heads without checking them out first' |
|
42 )) |
|
43 self.hgCloseheadAct.setWhatsThis(self.tr( |
|
44 """<b>Close Heads</b>""" |
|
45 """<p>This closes arbitrary heads without the need to check them""" |
|
46 """ out first.</p>""" |
|
47 )) |
|
48 self.hgCloseheadAct.triggered.connect(self.__hgClosehead) |
|
49 self.actions.append(self.hgCloseheadAct) |
|
50 |
|
51 def initMenu(self, mainMenu): |
|
52 """ |
|
53 Public method to generate the extension menu. |
|
54 |
|
55 @param mainMenu reference to the main menu |
|
56 @type QMenu |
|
57 @return populated menu (QMenu) |
|
58 """ |
|
59 menu = QMenu(self.menuTitle(), mainMenu) |
|
60 menu.setIcon(UI.PixmapCache.getIcon("closehead")) |
|
61 menu.setTearOffEnabled(True) |
|
62 |
|
63 menu.addAction(self.hgCloseheadAct) |
|
64 |
|
65 return menu |
|
66 |
|
67 def menuTitle(self): |
|
68 """ |
|
69 Public method to get the menu title. |
|
70 |
|
71 @return title of the menu |
|
72 @rtype str |
|
73 """ |
|
74 return self.tr("Close Heads") |
|
75 |
|
76 def __hgClosehead(self): |
|
77 """ |
|
78 Private slot used to close arbitrary heads. |
|
79 """ |
|
80 self.vcs.getExtensionObject("closehead")\ |
|
81 .hgCloseheads(self.project.getProjectPath()) |