15 |
15 |
16 from VCS.ProjectBrowserHelper import VcsProjectBrowserHelper |
16 from VCS.ProjectBrowserHelper import VcsProjectBrowserHelper |
17 |
17 |
18 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
18 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
19 import UI.PixmapCache |
19 import UI.PixmapCache |
|
20 |
20 |
21 |
21 class HgProjectBrowserHelper(VcsProjectBrowserHelper): |
22 class HgProjectBrowserHelper(VcsProjectBrowserHelper): |
22 """ |
23 """ |
23 Class implementing the VCS project browser helper for Mercurial. |
24 Class implementing the VCS project browser helper for Mercurial. |
24 """ |
25 """ |
25 def __init__(self, vcsObject, browserObject, projectObject, isTranslationsBrowser, |
26 def __init__(self, vcsObject, browserObject, projectObject, isTranslationsBrowser, |
26 parent = None, name = None): |
27 parent=None, name=None): |
27 """ |
28 """ |
28 Constructor |
29 Constructor |
29 |
30 |
30 @param vcsObject reference to the vcs object |
31 @param vcsObject reference to the vcs object |
31 @param browserObject reference to the project browser object |
32 @param browserObject reference to the project browser object |
38 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, projectObject, |
39 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, projectObject, |
39 isTranslationsBrowser, parent, name) |
40 isTranslationsBrowser, parent, name) |
40 |
41 |
41 def showContextMenu(self, menu, standardItems): |
42 def showContextMenu(self, menu, standardItems): |
42 """ |
43 """ |
43 Slot called before the context menu is shown. |
44 Slot called before the context menu is shown. |
44 |
45 |
45 It enables/disables the VCS menu entries depending on the overall |
46 It enables/disables the VCS menu entries depending on the overall |
46 VCS status and the file status. |
47 VCS status and the file status. |
47 |
48 |
48 @param menu reference to the menu to be shown |
49 @param menu reference to the menu to be shown |
49 @param standardItems array of standard items that need activation/deactivation |
50 @param standardItems array of standard items that need activation/deactivation |
50 depending on the overall VCS status |
51 depending on the overall VCS status |
66 for act in standardItems: |
67 for act in standardItems: |
67 act.setEnabled(True) |
68 act.setEnabled(True) |
68 |
69 |
69 def showContextMenuMulti(self, menu, standardItems): |
70 def showContextMenuMulti(self, menu, standardItems): |
70 """ |
71 """ |
71 Slot called before the context menu (multiple selections) is shown. |
72 Slot called before the context menu (multiple selections) is shown. |
72 |
73 |
73 It enables/disables the VCS menu entries depending on the overall |
74 It enables/disables the VCS menu entries depending on the overall |
74 VCS status and the files status. |
75 VCS status and the files status. |
75 |
76 |
76 @param menu reference to the menu to be shown |
77 @param menu reference to the menu to be shown |
77 @param standardItems array of standard items that need activation/deactivation |
78 @param standardItems array of standard items that need activation/deactivation |
78 depending on the overall VCS status |
79 depending on the overall VCS status |
104 for act in standardItems: |
105 for act in standardItems: |
105 act.setEnabled(True) |
106 act.setEnabled(True) |
106 |
107 |
107 def showContextMenuDir(self, menu, standardItems): |
108 def showContextMenuDir(self, menu, standardItems): |
108 """ |
109 """ |
109 Slot called before the context menu is shown. |
110 Slot called before the context menu is shown. |
110 |
111 |
111 It enables/disables the VCS menu entries depending on the overall |
112 It enables/disables the VCS menu entries depending on the overall |
112 VCS status and the directory status. |
113 VCS status and the directory status. |
113 |
114 |
114 @param menu reference to the menu to be shown |
115 @param menu reference to the menu to be shown |
115 @param standardItems array of standard items that need activation/deactivation |
116 @param standardItems array of standard items that need activation/deactivation |
116 depending on the overall VCS status |
117 depending on the overall VCS status |
130 for act in standardItems: |
131 for act in standardItems: |
131 act.setEnabled(True) |
132 act.setEnabled(True) |
132 |
133 |
133 def showContextMenuDirMulti(self, menu, standardItems): |
134 def showContextMenuDirMulti(self, menu, standardItems): |
134 """ |
135 """ |
135 Slot called before the context menu is shown. |
136 Slot called before the context menu is shown. |
136 |
137 |
137 It enables/disables the VCS menu entries depending on the overall |
138 It enables/disables the VCS menu entries depending on the overall |
138 VCS status and the directory status. |
139 VCS status and the directory status. |
139 |
140 |
140 @param menu reference to the menu to be shown |
141 @param menu reference to the menu to be shown |
141 @param standardItems array of standard items that need activation/deactivation |
142 @param standardItems array of standard items that need activation/deactivation |
142 depending on the overall VCS status |
143 depending on the overall VCS status |
183 |
184 |
184 menu = QMenu(self.trUtf8("Version Control")) |
185 menu = QMenu(self.trUtf8("Version Control")) |
185 |
186 |
186 act = menu.addAction( |
187 act = menu.addAction( |
187 UI.PixmapCache.getIcon( |
188 UI.PixmapCache.getIcon( |
188 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
189 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
189 self.vcs.vcsName(), self._VCSInfoDisplay) |
190 self.vcs.vcsName(), self._VCSInfoDisplay) |
190 font = act.font() |
191 font = act.font() |
191 font.setBold(True) |
192 font.setBold(True) |
192 act.setFont(font) |
193 act.setFont(font) |
193 menu.addSeparator() |
194 menu.addSeparator() |
194 |
195 |
195 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
196 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
196 self.trUtf8('Commit changes to repository...'), |
197 self.trUtf8('Commit changes to repository...'), |
197 self._VCSCommit) |
198 self._VCSCommit) |
198 self.vcsMenuActions.append(act) |
199 self.vcsMenuActions.append(act) |
199 menu.addSeparator() |
200 menu.addSeparator() |
200 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
201 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
201 self.trUtf8('Add to repository'), |
202 self.trUtf8('Add to repository'), |
202 self._VCSAdd) |
203 self._VCSAdd) |
203 self.vcsAddMenuActions.append(act) |
204 self.vcsAddMenuActions.append(act) |
204 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
205 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
205 self.trUtf8('Remove from repository (and disk)'), |
206 self.trUtf8('Remove from repository (and disk)'), |
206 self._VCSRemove) |
207 self._VCSRemove) |
207 self.vcsMenuActions.append(act) |
208 self.vcsMenuActions.append(act) |
208 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
209 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
209 self.trUtf8('Remove from repository only'), |
210 self.trUtf8('Remove from repository only'), |
210 self.__HgForget) |
211 self.__HgForget) |
211 self.vcsMenuActions.append(act) |
212 self.vcsMenuActions.append(act) |
212 menu.addSeparator() |
213 menu.addSeparator() |
213 act = menu.addAction(self.trUtf8('Copy in repository'), self.__HgCopy) |
214 act = menu.addAction(self.trUtf8('Copy in repository'), self.__HgCopy) |
214 self.vcsMenuActions.append(act) |
215 self.vcsMenuActions.append(act) |
231 menu.addSeparator() |
232 menu.addSeparator() |
232 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
233 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
233 self.trUtf8('Show difference'), self._VCSDiff) |
234 self.trUtf8('Show difference'), self._VCSDiff) |
234 self.vcsMenuActions.append(act) |
235 self.vcsMenuActions.append(act) |
235 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
236 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
236 self.trUtf8('Show difference (extended)'), |
237 self.trUtf8('Show difference (extended)'), |
237 self.__HgExtendedDiff) |
238 self.__HgExtendedDiff) |
238 self.vcsMenuActions.append(act) |
239 self.vcsMenuActions.append(act) |
239 self.annotateAct = menu.addAction(self.trUtf8('Show annotated file'), |
240 self.annotateAct = menu.addAction(self.trUtf8('Show annotated file'), |
240 self.__HgAnnotate) |
241 self.__HgAnnotate) |
241 self.vcsMenuActions.append(self.annotateAct) |
242 self.vcsMenuActions.append(self.annotateAct) |
242 menu.addSeparator() |
243 menu.addSeparator() |
243 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
244 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
244 self.trUtf8('Revert changes'), self._VCSRevert) |
245 self.trUtf8('Revert changes'), self._VCSRevert) |
260 mainMenu.addMenu(menu) |
261 mainMenu.addMenu(menu) |
261 self.menu = menu |
262 self.menu = menu |
262 |
263 |
263 def _addVCSMenuMulti(self, mainMenu): |
264 def _addVCSMenuMulti(self, mainMenu): |
264 """ |
265 """ |
265 Protected method used to add the VCS menu for multi selection to all |
266 Protected method used to add the VCS menu for multi selection to all |
266 project browsers. |
267 project browsers. |
267 |
268 |
268 @param mainMenu reference to the menu to be amended |
269 @param mainMenu reference to the menu to be amended |
269 """ |
270 """ |
270 self.vcsMultiMenuActions = [] |
271 self.vcsMultiMenuActions = [] |
272 |
273 |
273 menu = QMenu(self.trUtf8("Version Control")) |
274 menu = QMenu(self.trUtf8("Version Control")) |
274 |
275 |
275 act = menu.addAction( |
276 act = menu.addAction( |
276 UI.PixmapCache.getIcon( |
277 UI.PixmapCache.getIcon( |
277 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
278 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
278 self.vcs.vcsName(), self._VCSInfoDisplay) |
279 self.vcs.vcsName(), self._VCSInfoDisplay) |
279 font = act.font() |
280 font = act.font() |
280 font.setBold(True) |
281 font.setBold(True) |
281 act.setFont(font) |
282 act.setFont(font) |
282 menu.addSeparator() |
283 menu.addSeparator() |
283 |
284 |
284 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
285 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
285 self.trUtf8('Commit changes to repository...'), |
286 self.trUtf8('Commit changes to repository...'), |
286 self._VCSCommit) |
287 self._VCSCommit) |
287 self.vcsMultiMenuActions.append(act) |
288 self.vcsMultiMenuActions.append(act) |
288 menu.addSeparator() |
289 menu.addSeparator() |
289 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
290 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
290 self.trUtf8('Add to repository'), self._VCSAdd) |
291 self.trUtf8('Add to repository'), self._VCSAdd) |
291 self.vcsAddMultiMenuActions.append(act) |
292 self.vcsAddMultiMenuActions.append(act) |
292 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
293 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
293 self.trUtf8('Remove from repository (and disk)'), |
294 self.trUtf8('Remove from repository (and disk)'), |
294 self._VCSRemove) |
295 self._VCSRemove) |
295 self.vcsMultiMenuActions.append(act) |
296 self.vcsMultiMenuActions.append(act) |
296 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
297 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
297 self.trUtf8('Remove from repository only'), |
298 self.trUtf8('Remove from repository only'), |
298 self.__HgForget) |
299 self.__HgForget) |
299 self.vcsMultiMenuActions.append(act) |
300 self.vcsMultiMenuActions.append(act) |
300 menu.addSeparator() |
301 menu.addSeparator() |
301 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
302 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
302 self.trUtf8('Show status'), self._VCSStatus) |
303 self.trUtf8('Show status'), self._VCSStatus) |
304 menu.addSeparator() |
305 menu.addSeparator() |
305 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
306 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
306 self.trUtf8('Show difference'), self._VCSDiff) |
307 self.trUtf8('Show difference'), self._VCSDiff) |
307 self.vcsMultiMenuActions.append(act) |
308 self.vcsMultiMenuActions.append(act) |
308 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
309 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
309 self.trUtf8('Show difference (extended)'), |
310 self.trUtf8('Show difference (extended)'), |
310 self.__HgExtendedDiff) |
311 self.__HgExtendedDiff) |
311 self.vcsMultiMenuActions.append(act) |
312 self.vcsMultiMenuActions.append(act) |
312 menu.addSeparator() |
313 menu.addSeparator() |
313 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
314 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
314 self.trUtf8('Revert changes'), self._VCSRevert) |
315 self.trUtf8('Revert changes'), self._VCSRevert) |
338 """ |
339 """ |
339 menu = QMenu(self.trUtf8("Version Control")) |
340 menu = QMenu(self.trUtf8("Version Control")) |
340 |
341 |
341 act = menu.addAction( |
342 act = menu.addAction( |
342 UI.PixmapCache.getIcon( |
343 UI.PixmapCache.getIcon( |
343 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
344 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
344 self.vcs.vcsName(), self._VCSInfoDisplay) |
345 self.vcs.vcsName(), self._VCSInfoDisplay) |
345 font = act.font() |
346 font = act.font() |
346 font.setBold(True) |
347 font.setBold(True) |
347 act.setFont(font) |
348 act.setFont(font) |
348 menu.addSeparator() |
349 menu.addSeparator() |
375 |
376 |
376 menu = QMenu(self.trUtf8("Version Control")) |
377 menu = QMenu(self.trUtf8("Version Control")) |
377 |
378 |
378 act = menu.addAction( |
379 act = menu.addAction( |
379 UI.PixmapCache.getIcon( |
380 UI.PixmapCache.getIcon( |
380 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
381 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
381 self.vcs.vcsName(), self._VCSInfoDisplay) |
382 self.vcs.vcsName(), self._VCSInfoDisplay) |
382 font = act.font() |
383 font = act.font() |
383 font.setBold(True) |
384 font.setBold(True) |
384 act.setFont(font) |
385 act.setFont(font) |
385 menu.addSeparator() |
386 menu.addSeparator() |
386 |
387 |
387 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
388 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
388 self.trUtf8('Commit changes to repository...'), |
389 self.trUtf8('Commit changes to repository...'), |
389 self._VCSCommit) |
390 self._VCSCommit) |
390 self.vcsDirMenuActions.append(act) |
391 self.vcsDirMenuActions.append(act) |
391 menu.addSeparator() |
392 menu.addSeparator() |
392 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
393 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
393 self.trUtf8('Add to repository'), self._VCSAdd) |
394 self.trUtf8('Add to repository'), self._VCSAdd) |
394 self.vcsAddDirMenuActions.append(act) |
395 self.vcsAddDirMenuActions.append(act) |
395 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
396 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
396 self.trUtf8('Remove from repository (and disk)'), |
397 self.trUtf8('Remove from repository (and disk)'), |
397 self._VCSRemove) |
398 self._VCSRemove) |
398 self.vcsDirMenuActions.append(act) |
399 self.vcsDirMenuActions.append(act) |
399 menu.addSeparator() |
400 menu.addSeparator() |
400 act = menu.addAction(self.trUtf8('Copy in repository'), self.__HgCopy) |
401 act = menu.addAction(self.trUtf8('Copy in repository'), self.__HgCopy) |
401 self.vcsDirMenuActions.append(act) |
402 self.vcsDirMenuActions.append(act) |
418 menu.addSeparator() |
419 menu.addSeparator() |
419 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
420 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
420 self.trUtf8('Show difference'), self._VCSDiff) |
421 self.trUtf8('Show difference'), self._VCSDiff) |
421 self.vcsDirMenuActions.append(act) |
422 self.vcsDirMenuActions.append(act) |
422 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
423 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
423 self.trUtf8('Show difference (extended)'), |
424 self.trUtf8('Show difference (extended)'), |
424 self.__HgExtendedDiff) |
425 self.__HgExtendedDiff) |
425 self.vcsDirMenuActions.append(act) |
426 self.vcsDirMenuActions.append(act) |
426 menu.addSeparator() |
427 menu.addSeparator() |
427 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
428 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
428 self.trUtf8('Revert changes'), self._VCSRevert) |
429 self.trUtf8('Revert changes'), self._VCSRevert) |
458 |
459 |
459 menu = QMenu(self.trUtf8("Version Control")) |
460 menu = QMenu(self.trUtf8("Version Control")) |
460 |
461 |
461 act = menu.addAction( |
462 act = menu.addAction( |
462 UI.PixmapCache.getIcon( |
463 UI.PixmapCache.getIcon( |
463 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
464 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")), |
464 self.vcs.vcsName(), self._VCSInfoDisplay) |
465 self.vcs.vcsName(), self._VCSInfoDisplay) |
465 font = act.font() |
466 font = act.font() |
466 font.setBold(True) |
467 font.setBold(True) |
467 act.setFont(font) |
468 act.setFont(font) |
468 menu.addSeparator() |
469 menu.addSeparator() |
469 |
470 |
470 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
471 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
471 self.trUtf8('Commit changes to repository...'), |
472 self.trUtf8('Commit changes to repository...'), |
472 self._VCSCommit) |
473 self._VCSCommit) |
473 self.vcsDirMultiMenuActions.append(act) |
474 self.vcsDirMultiMenuActions.append(act) |
474 menu.addSeparator() |
475 menu.addSeparator() |
475 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
476 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
476 self.trUtf8('Add to repository'), self._VCSAdd) |
477 self.trUtf8('Add to repository'), self._VCSAdd) |
477 self.vcsAddDirMultiMenuActions.append(act) |
478 self.vcsAddDirMultiMenuActions.append(act) |
478 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
479 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
479 self.trUtf8('Remove from repository (and disk)'), |
480 self.trUtf8('Remove from repository (and disk)'), |
480 self._VCSRemove) |
481 self._VCSRemove) |
481 self.vcsDirMultiMenuActions.append(act) |
482 self.vcsDirMultiMenuActions.append(act) |
482 menu.addSeparator() |
483 menu.addSeparator() |
483 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
484 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
484 self.trUtf8('Show status'), self._VCSStatus) |
485 self.trUtf8('Show status'), self._VCSStatus) |
486 menu.addSeparator() |
487 menu.addSeparator() |
487 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
488 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
488 self.trUtf8('Show difference'), self._VCSDiff) |
489 self.trUtf8('Show difference'), self._VCSDiff) |
489 self.vcsDirMultiMenuActions.append(act) |
490 self.vcsDirMultiMenuActions.append(act) |
490 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
491 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
491 self.trUtf8('Show difference (extended)'), |
492 self.trUtf8('Show difference (extended)'), |
492 self.__HgExtendedDiff) |
493 self.__HgExtendedDiff) |
493 self.vcsDirMultiMenuActions.append(act) |
494 self.vcsDirMultiMenuActions.append(act) |
494 menu.addSeparator() |
495 menu.addSeparator() |
495 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
496 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
496 self.trUtf8('Revert changes'), self._VCSRevert) |
497 self.trUtf8('Revert changes'), self._VCSRevert) |