|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the histedit extension project helper. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QMenu |
|
11 |
|
12 from E5Gui.E5Action import E5Action |
|
13 from E5Gui import E5MessageBox |
|
14 |
|
15 from ..HgExtensionProjectHelper import HgExtensionProjectHelper |
|
16 |
|
17 import UI.PixmapCache |
|
18 |
|
19 |
|
20 class HisteditProjectHelper(HgExtensionProjectHelper): |
|
21 """ |
|
22 Class implementing the histedit extension project helper. |
|
23 """ |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super().__init__() |
|
29 |
|
30 def initActions(self): |
|
31 """ |
|
32 Public method to generate the action objects. |
|
33 """ |
|
34 self.hgHisteditStartAct = E5Action( |
|
35 self.tr('Start'), |
|
36 UI.PixmapCache.getIcon("vcsEditHistory"), |
|
37 self.tr('Start'), |
|
38 0, 0, self, 'mercurial_histedit_start') |
|
39 self.hgHisteditStartAct.setStatusTip(self.tr( |
|
40 'Start a new changeset history editing session' |
|
41 )) |
|
42 self.hgHisteditStartAct.setWhatsThis(self.tr( |
|
43 """<b>Start</b>""" |
|
44 """<p>This starts a new history editing session. A dialog""" |
|
45 """ will be presented to modify the edit plan.</p>""" |
|
46 )) |
|
47 self.hgHisteditStartAct.triggered.connect(self.__hgHisteditStart) |
|
48 self.actions.append(self.hgHisteditStartAct) |
|
49 |
|
50 self.hgHisteditContinueAct = E5Action( |
|
51 self.tr('Continue'), |
|
52 self.tr('Continue'), |
|
53 0, 0, self, 'mercurial_histedit_continue') |
|
54 self.hgHisteditContinueAct.setStatusTip(self.tr( |
|
55 'Continue an interrupted changeset history editing session' |
|
56 )) |
|
57 self.hgHisteditContinueAct.setWhatsThis(self.tr( |
|
58 """<b>Continue</b>""" |
|
59 """<p>This continues an interrupted history editing session.</p>""" |
|
60 )) |
|
61 self.hgHisteditContinueAct.triggered.connect(self.__hgHisteditContinue) |
|
62 self.actions.append(self.hgHisteditContinueAct) |
|
63 |
|
64 self.hgHisteditAbortAct = E5Action( |
|
65 self.tr('Abort'), |
|
66 self.tr('Abort'), |
|
67 0, 0, self, 'mercurial_histedit_abort') |
|
68 self.hgHisteditAbortAct.setStatusTip(self.tr( |
|
69 'Abort an interrupted changeset history editing session' |
|
70 )) |
|
71 self.hgHisteditAbortAct.setWhatsThis(self.tr( |
|
72 """<b>Abort</b>""" |
|
73 """<p>This aborts an interrupted history editing session.</p>""" |
|
74 )) |
|
75 self.hgHisteditAbortAct.triggered.connect(self.__hgHisteditAbort) |
|
76 self.actions.append(self.hgHisteditAbortAct) |
|
77 |
|
78 self.hgHisteditEditPlanAct = E5Action( |
|
79 self.tr('Edit Plan'), |
|
80 self.tr('Edit Plan'), |
|
81 0, 0, self, 'mercurial_histedit_edit_plan') |
|
82 self.hgHisteditEditPlanAct.setStatusTip(self.tr( |
|
83 'Edit the remaining actions list' |
|
84 )) |
|
85 self.hgHisteditEditPlanAct.setWhatsThis(self.tr( |
|
86 """<b>Edit Plan</b>""" |
|
87 """<p>This opens an editor to edit the remaining actions list""" |
|
88 """ of an interrupted history editing session.</p>""" |
|
89 )) |
|
90 self.hgHisteditEditPlanAct.triggered.connect(self.__hgHisteditEditPlan) |
|
91 self.actions.append(self.hgHisteditEditPlanAct) |
|
92 |
|
93 def initMenu(self, mainMenu): |
|
94 """ |
|
95 Public method to generate the extension menu. |
|
96 |
|
97 @param mainMenu reference to the main menu |
|
98 @type QMenu |
|
99 @return populated menu (QMenu) |
|
100 """ |
|
101 menu = QMenu(self.menuTitle(), mainMenu) |
|
102 menu.setIcon(UI.PixmapCache.getIcon("vcsEditHistory")) |
|
103 menu.setTearOffEnabled(True) |
|
104 |
|
105 menu.addAction(self.hgHisteditStartAct) |
|
106 menu.addSeparator() |
|
107 menu.addAction(self.hgHisteditContinueAct) |
|
108 menu.addAction(self.hgHisteditAbortAct) |
|
109 menu.addSeparator() |
|
110 menu.addAction(self.hgHisteditEditPlanAct) |
|
111 |
|
112 return menu |
|
113 |
|
114 def menuTitle(self): |
|
115 """ |
|
116 Public method to get the menu title. |
|
117 |
|
118 @return title of the menu |
|
119 @rtype str |
|
120 """ |
|
121 return self.tr("Edit History") |
|
122 |
|
123 def __hgHisteditStart(self): |
|
124 """ |
|
125 Private slot used to start a history editing session. |
|
126 """ |
|
127 shouldReopen = ( |
|
128 self.vcs.getExtensionObject("histedit").hgHisteditStart() |
|
129 ) |
|
130 if shouldReopen: |
|
131 res = E5MessageBox.yesNo( |
|
132 None, |
|
133 self.tr("Start History Editing"), |
|
134 self.tr("""The project should be reread. Do this now?"""), |
|
135 yesDefault=True) |
|
136 if res: |
|
137 self.project.reopenProject() |
|
138 |
|
139 def __hgHisteditContinue(self): |
|
140 """ |
|
141 Private slot used to continue an interrupted history editing session. |
|
142 """ |
|
143 shouldReopen = ( |
|
144 self.vcs.getExtensionObject("histedit").hgHisteditContinue() |
|
145 ) |
|
146 if shouldReopen: |
|
147 res = E5MessageBox.yesNo( |
|
148 None, |
|
149 self.tr("Continue History Editing"), |
|
150 self.tr("""The project should be reread. Do this now?"""), |
|
151 yesDefault=True) |
|
152 if res: |
|
153 self.project.reopenProject() |
|
154 |
|
155 def __hgHisteditAbort(self): |
|
156 """ |
|
157 Private slot used to abort an interrupted history editing session. |
|
158 """ |
|
159 shouldReopen = ( |
|
160 self.vcs.getExtensionObject("histedit").hgHisteditAbort() |
|
161 ) |
|
162 if shouldReopen: |
|
163 res = E5MessageBox.yesNo( |
|
164 None, |
|
165 self.tr("Abort History Editing"), |
|
166 self.tr("""The project should be reread. Do this now?"""), |
|
167 yesDefault=True) |
|
168 if res: |
|
169 self.project.reopenProject() |
|
170 |
|
171 def __hgHisteditEditPlan(self): |
|
172 """ |
|
173 Private slot used to edit the remaining actions list of an interrupted |
|
174 history editing session. |
|
175 """ |
|
176 shouldReopen = ( |
|
177 self.vcs.getExtensionObject("histedit").hgHisteditEditPlan() |
|
178 ) |
|
179 if shouldReopen: |
|
180 res = E5MessageBox.yesNo( |
|
181 None, |
|
182 self.tr("Edit Plan"), |
|
183 self.tr("""The project should be reread. Do this now?"""), |
|
184 yesDefault=True) |
|
185 if res: |
|
186 self.project.reopenProject() |