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