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