Commits

Yuya Nishihara committed 2cbfcd1

filedialogs: open workbench via qtrun

Now FileDialog no longer needs to keep repoviewer reference.

Comments (0)

Files changed (4)

tortoisehg/hgqt/filectxactions.py

             dlg.goto(rev)
 
     def _createnavdialog(self, dlgclass, repo, filename):
-        # dirty hack to pass workbench only if available
-        from tortoisehg.hgqt import workbench  # avoid cyclic dep
-        repoviewer = None
-        if self.parent() and isinstance(self.parent().window(),
-                                        workbench.Workbench):
-            repoviewer = self.parent().window()
-        return dlgclass(repo, filename, repoviewer=repoviewer)
+        return dlgclass(repo, filename)
 
     def _gennavdialogkey(self, dlgclass, repo, filename):
         return dlgclass, repo.wjoin(filename)

tortoisehg/hgqt/filedialogs.py

 class _AbstractFileDialog(QMainWindow):
     finished = pyqtSignal(int)
 
-    def __init__(self, repo, filename, repoviewer=None):
+    def __init__(self, repo, filename):
         QMainWindow.__init__(self)
         self.repo = repo
 
         self.setupUi(self)
-        self.setRepoViewer(repoviewer)
         self._show_rev = None
 
         assert not isinstance(filename, (unicode, QString))
         super(_AbstractFileDialog, self).closeEvent(event)
         self.finished.emit(0)  # mimic QDialog exit
 
-    def setRepoViewer(self, repoviewer=None):
-        self.repoviewer = repoviewer
-        if repoviewer:
-            repoviewer.finished.connect(self._clearRepoViewer)
-
-    @pyqtSlot()
-    def _clearRepoViewer(self):
-        self.setRepoViewer(None)
-
     def reload(self):
         'Reload toolbar action handler'
         self.repo.thginvalidate()
         """
         Callback called when a revision is double-clicked in the revisions table
         """
-        if self.repoviewer is None:
-            # prevent recursive import
-            from workbench import Workbench
-            self.repoviewer = Workbench()
-        self.repoviewer.show()
-        self.repoviewer.activateWindow()
-        self.repoviewer.raise_()
-        self.repoviewer.showRepo(hglib.tounicode(self.repo.root))
-        self.repoviewer.goto(self.repo.root, rev)
+        # TODO: implement by using signal-slot if possible
+        from tortoisehg.hgqt import run
+        run.qtrun.showRepoInWorkbench(hglib.tounicode(self.repo.root), rev)
 
 class FileLogDialog(_AbstractFileDialog):
     """
     A dialog showing a revision graph for a file.
     """
-    def __init__(self, repo, filename, repoviewer=None):
-        super(FileLogDialog, self).__init__(repo, filename, repoviewer)
+    def __init__(self, repo, filename):
+        super(FileLogDialog, self).__init__(repo, filename)
         self._readSettings()
         self.menu = None
         self.dualmenu = None
     """
     Qt4 dialog to display diffs between different mercurial revisions of a file.
     """
-    def __init__(self, repo, filename, repoviewer=None):
-        super(FileDiffDialog, self).__init__(repo, filename, repoviewer)
+    def __init__(self, repo, filename):
+        super(FileDiffDialog, self).__init__(repo, filename)
         self._readSettings()
         self.menu = None
 

tortoisehg/hgqt/grep.py

         dlg.setSearchCaseInsensitive(self.icase)
 
     def _createFileDialog(self, repo, path):
-        # dirty hack to pass workbench only if available
-        from tortoisehg.hgqt import workbench  # avoid cyclic dep
-        repoviewer = None
-        if isinstance(self.window(), workbench.Workbench):
-            repoviewer = self.window()
-        return filedialogs.FileLogDialog(repo, path, repoviewer=repoviewer)
+        return filedialogs.FileLogDialog(repo, path)
 
     def _genFileDialogKey(self, repo, path):
         return repo.wjoin(path)

tortoisehg/hgqt/wctxactions.py

             self._filedialogs.open(path)
 
     def _createFileDialog(self, path):
-        # dirty hack to pass workbench only if available
-        from tortoisehg.hgqt import workbench  # avoid cyclic dep
-        repoviewer = None
-        if self.parent() and isinstance(self.parent().window(),
-                                        workbench.Workbench):
-            repoviewer = self.parent().window()
-        return filedialogs.FileLogDialog(self.repo, path, repoviewer=repoviewer)
+        return filedialogs.FileLogDialog(self.repo, path)
 
 def renamefromto(repo, deleted, unknown):
     repo[None].copy(deleted, unknown)