Commits

Anonymous committed 36cb719

resolve: add context-menu in resolve window (fixes #2200)

Comments (0)

Files changed (1)

tortoisehg/hgqt/resolve.py

         vbox.addStretch(1)
         self.ubuttons = (auto, manual, local, other, res)
 
+        self.utree.setContextMenuPolicy(Qt.CustomContextMenu)
+        self.utreecmenu = QMenu(self)
+        cmauto = self.utreecmenu.addAction(_('Mercurial Resolve'))
+        cmauto.triggered.connect(lambda: self.merge('internal:merge'))
+        cmmanual = self.utreecmenu.addAction(_('Tool Resolve'))
+        cmmanual.triggered.connect(self.merge)
+        cmlocal = self.utreecmenu.addAction(_('Take Local'))
+        cmlocal.triggered.connect(lambda: self.merge('internal:local'))
+        cmother = self.utreecmenu.addAction(_('Take Other'))
+        cmother.triggered.connect(lambda: self.merge('internal:other'))
+        cmres = self.utreecmenu.addAction(_('Mark as Resolved'))
+        cmres.triggered.connect(self.markresolved)
+        self.umenuitems = (cmauto, cmmanual, cmlocal, cmother, cmres)
+        self.utree.customContextMenuRequested.connect(self.utreeMenuRequested)
+
         res = qtlib.LabeledSeparator(_('Resolved conflicts'))
         self.layout().addWidget(res)
 
         self.rbuttons = (edit, vp0, ures)
         self.rmbuttons = (vp1, v3way)
 
+        self.rtree.setContextMenuPolicy(Qt.CustomContextMenu)
+        self.rtreecmenu = QMenu(self)
+        cmedit = self.rtreecmenu.addAction(_('Edit File'))
+        cmedit.triggered.connect(self.edit)
+        cmv3way = self.rtreecmenu.addAction(_('3-Way Diff'))
+        cmv3way.triggered.connect(self.v3way)
+        cmvp0 = self.rtreecmenu.addAction(_('Diff to Local'))
+        cmvp0.triggered.connect(self.vp0)
+        cmvp1 = self.rtreecmenu.addAction(_('Diff to Other'))
+        cmvp1.triggered.connect(self.vp1)
+        cmures = self.rtreecmenu.addAction(_('Mark as Unresolved'))
+        cmures.triggered.connect(self.markunresolved)
+        self.rmenuitems = (cmedit, cmvp0, cmures)
+        self.rmmenuitems = (cmvp1, cmv3way)
+        self.rtree.customContextMenuRequested.connect(self.rtreeMenuRequested)
+
         hbox = QHBoxLayout()
         hbox.setContentsMargins(*MARGINS)
         hbox.setSpacing(4)
             enable = self.utree.selectionModel().hasSelection()
             for b in self.ubuttons:
                 b.setEnabled(enable)
+            for c in self.umenuitems:
+                c.setEnabled(enable)
         smodel.selectionChanged.connect(uchanged)
         uchanged(None, None)
 
             enable = self.rtree.selectionModel().hasSelection()
             for b in self.rbuttons:
                 b.setEnabled(enable)
+            for c in self.rmenuitems:
+                c.setEnabled(enable)
             merge = len(self.repo.parents()) > 1
             for b in self.rmbuttons:
                 b.setEnabled(enable and merge)
+            for c in self.rmmenuitems:
+                c.setEnabled(enable and merge)
         smodel.selectionChanged.connect(rchanged)
         rchanged(None, None)
 
                 return
         super(ResolveDialog, self).reject()
 
+    @pyqtSlot(QPoint)
+    def utreeMenuRequested(self, point):
+        self.utreecmenu.exec_(self.utree.mapToGlobal(point), self.umenuitems[0])
+
+    @pyqtSlot(QPoint)
+    def rtreeMenuRequested(self, point):
+        self.rtreecmenu.exec_(self.rtree.mapToGlobal(point), self.rmenuitems[0])
+
 class PathsTree(QTreeView):
     def __init__(self, repo, parent):
         QTreeView.__init__(self, parent)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.