1. TortoiseHg
  2. TortoiseHg
  3. thg

Commits

Angel Ezquerra  committed 3c994ff

annotate: group related context menu items into submenus

The number of context menu items can be great when the selected line is the
result of a merge. In addition, having "annotate" and "view" menu items side by
side is confusing. This revision groups related menu items into submenus for
better clarity.

  • Participants
  • Parent commits fa40f31
  • Branches default

Comments (0)

Files changed (1)

File tortoisehg/hgqt/fileview.py

View file
             self.editSelected(*data)
         menu.addSeparator()
         origrev = fctx.rev()
-        for name, func in [(_('A&nnotate Originating Revision (%d)') % origrev, annorig),
-                           (_('&View Originating Revision (%d)') % origrev, editorig)]:
+        anngotomenu = QMenu(_('Annotate'), self)
+        annviewmenu = QMenu(_('View File at'), self)
+        for name, func, smenu in [(_('&Originating Revision'), annorig, anngotomenu),
+                           (_('&Originating Revision'), editorig, annviewmenu)]:
             def add(name, func):
-                action = menu.addAction(name)
+                action = smenu.addAction(name)
                 action.triggered.connect(func)
             add(name, func)
         for pfctx in fctx.parents():
                 setSource(*data)
             def editparent(data):
                 self.editSelected(*data)
-            for name, func in [(_('Annotate &Parent Revision (%d)') % pdata[1],
-                                  annparent),
-                               (_('View Parent &Revision (%d)') % pdata[1],
-                                  editparent)]:
+            for name, func, smenu in [(_('&Parent Revision (%d)') % pdata[1],
+                                  annparent, anngotomenu),
+                               (_('&Parent Revision (%d)') % pdata[1],
+                                  editparent, annviewmenu)]:
                 def add(name, func):
-                    action = menu.addAction(name)
+                    action = smenu.addAction(name)
                     action.data = pdata
                     action.run = lambda: func(action.data)
                     action.triggered.connect(action.run)
                 add(name, func)
+        menu.addMenu(anngotomenu)
+        menu.addMenu(annviewmenu)
         menu.exec_(point)
 
     def resizeEvent(self, event):