Commits

Yuya Nishihara committed 3b36159

fileview: provide setMode(mode) to switch view from manifest dialog

Comments (0)

Files changed (1)

tortoisehg/hgqt/fileview.py

             self.sci.setAnnotationEnabled(mode == AnnMode)
             self.displayFile(self._filename, self._status)
 
+    def setMode(self, mode):
+        """Switch view to DiffMode/FileMode/AnnMode if available for the current
+        content; otherwise it will be switched later"""
+        actionmap = dict((a._mode, a) for a in self.modeToggleGroup.actions())
+        try:
+            action = actionmap[mode]
+        except KeyError:
+            raise ValueError('invalid mode: %r' % mode)
+
+        if action.isEnabled():
+            if not action.isChecked():
+                action.trigger()  # implies _setModeByAction()
+        else:
+            self._lostMode = mode
+
     @pyqtSlot(QAction)
     def setParent(self, action):
         if action.text() == '1':
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.