288 |
290 |
289 def __initActionsMenu(self): |
291 def __initActionsMenu(self): |
290 """ |
292 """ |
291 Private method to initialize the actions menu. |
293 Private method to initialize the actions menu. |
292 """ |
294 """ |
|
295 # create the "View" submenu |
|
296 self.__viewMenu = QMenu(self.tr("View")) |
|
297 self.__viewMenu.addAction( |
|
298 self.tr("Select Branches"), lambda: self.__selectBranches(stateFilter=None) |
|
299 ).setToolTip( |
|
300 self.tr( |
|
301 "Select the branches to be shown from a list of all branches and" |
|
302 " refresh the display" |
|
303 ) |
|
304 ) |
|
305 self.__viewMenu.addAction( |
|
306 self.tr("Select Branches (active branches only)"), |
|
307 lambda: self.__selectBranches(stateFilter=[""]), |
|
308 ).setToolTip( |
|
309 self.tr( |
|
310 "Select the branches to be shown from a list of active branches and" |
|
311 " refresh the display" |
|
312 ) |
|
313 ) |
|
314 self.__viewMenu.addAction( |
|
315 self.tr("Select Branches (inactive branches only)"), |
|
316 lambda: self.__selectBranches(stateFilter=["I"]), |
|
317 ).setToolTip( |
|
318 self.tr( |
|
319 "Select the branches to be shown from a list of inactive branches and" |
|
320 " refresh the display" |
|
321 ) |
|
322 ) |
|
323 self.__viewMenu.addAction( |
|
324 self.tr("Select Branches (closed branches only)"), |
|
325 lambda: self.__selectBranches(stateFilter=["C"]), |
|
326 ).setToolTip( |
|
327 self.tr( |
|
328 "Select the branches to be shown from a list of closed branches and" |
|
329 " refresh the display" |
|
330 ) |
|
331 ) |
|
332 |
|
333 # create the main actions menu |
293 self.__actionsMenu = QMenu() |
334 self.__actionsMenu = QMenu() |
294 self.__actionsMenu.setTearOffEnabled(True) |
335 self.__actionsMenu.setTearOffEnabled(True) |
295 self.__actionsMenu.setToolTipsVisible(True) |
336 self.__actionsMenu.setToolTipsVisible(True) |
|
337 |
|
338 self.__actionsMenu.addMenu(self.__viewMenu) |
|
339 self.__actionsMenu.addSeparator() |
296 |
340 |
297 self.__graftAct = self.__actionsMenu.addAction( |
341 self.__graftAct = self.__actionsMenu.addAction( |
298 EricPixmapCache.getIcon("vcsGraft"), |
342 EricPixmapCache.getIcon("vcsGraft"), |
299 self.tr("Copy Changesets"), |
343 self.tr("Copy Changesets"), |
300 self.__graftActTriggered, |
344 self.__graftActTriggered, |
1084 os.path.dirname(__file__), |
1128 os.path.dirname(__file__), |
1085 "templates", |
1129 "templates", |
1086 "logBrowserBookmarkPhase.tmpl", |
1130 "logBrowserBookmarkPhase.tmpl", |
1087 ) |
1131 ) |
1088 ) |
1132 ) |
|
1133 for branch in self.__branchesFilterList: |
|
1134 args.extend(["--branch", branch]) |
1089 if self.commandMode == "incoming": |
1135 if self.commandMode == "incoming": |
1090 if self.__bundle: |
1136 if self.__bundle: |
1091 args.append(self.__bundle) |
1137 args.append(self.__bundle) |
1092 elif not self.vcs.hasSubrepositories(): |
1138 elif not self.vcs.hasSubrepositories(): |
1093 project = ericApp().getObject("Project") |
1139 project = ericApp().getObject("Project") |
2897 if ":" in link and self.__filename is not None: |
2943 if ":" in link and self.__filename is not None: |
2898 scheme, path = link.split(":", 1) |
2944 scheme, path = link.split(":", 1) |
2899 if scheme == "sbsdiff" and "_" in path: |
2945 if scheme == "sbsdiff" and "_" in path: |
2900 rev1, rev2 = path.split("_", 1) |
2946 rev1, rev2 = path.split("_", 1) |
2901 self.vcs.vcsSbsDiff(self.__filename, revisions=(rev1, rev2)) |
2947 self.vcs.vcsSbsDiff(self.__filename, revisions=(rev1, rev2)) |
|
2948 |
|
2949 def __selectBranches(self, stateFilter=None): |
|
2950 """ |
|
2951 Private slot to select the branches to be shown. |
|
2952 |
|
2953 @param stateFilter list of state filters ("", "C" or "I") to be presented for |
|
2954 selection (None or empty list means all) (defaults to None) |
|
2955 @type list of str (optional) |
|
2956 """ |
|
2957 from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
|
2958 |
|
2959 states = { |
|
2960 "C": self.tr("closed"), |
|
2961 "I": self.tr("inactive"), |
|
2962 } |
|
2963 |
|
2964 if not stateFilter: |
|
2965 stateFilter = ["", "C", "I"] |
|
2966 |
|
2967 rawBranchesList = self.vcs.hgGetBranchesList(withState=True, withDefault=True) |
|
2968 branchesList = sorted( |
|
2969 ( |
|
2970 b[0] if b[1] == "" else self.tr("{0} ({1})").format(b[0], states[b[1]]), |
|
2971 b[0], |
|
2972 ) |
|
2973 for b in rawBranchesList |
|
2974 if b[1] in stateFilter |
|
2975 ) |
|
2976 dlg = EricListSelectionDialog( |
|
2977 branchesList, |
|
2978 title=self.tr("Select Branches"), |
|
2979 message=self.tr("Select the branches to be shown (none for 'All'):"), |
|
2980 checkBoxSelection=True, |
|
2981 emptySelectionOk=True, |
|
2982 showSelectAll=True, |
|
2983 parent=self, |
|
2984 ) |
|
2985 dlg.setSelection(self.__branchesFilterList) |
|
2986 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
2987 self.__branchesFilterList = [b[1] for b in dlg.getSelection()] |
|
2988 self.on_refreshButton_clicked() |