1. Graham Helliwell
  2. thg

Commits

chris.moore  committed 3e24602

Change Repository Registry so single click closes current tab and opens clicked repository.
Middle clicking opens new tab and preserves existing
(and some refactoring of mousePress method!)

  • Participants
  • Parent commits 18a1762
  • Branches default

Comments (0)

Files changed (2)

File tortoisehg/hgqt/reporegistry.py

View file
     showMessage = pyqtSignal(QString)
     menuRequested = pyqtSignal(object, object)
     openRepo = pyqtSignal(QString, bool)
+    closeCurrentTab = pyqtSignal()
     dropAccepted = pyqtSignal()
     updateSettingsFile = pyqtSignal()
 
         if self.msg != '':
             self.showMessage.emit('')
 
-    def mouseDoubleClickEvent(self, event):
-        if self.selitem and self.selitem.internalPointer().isRepo():
-            # We can only open mercurial repositories and subrepositories
-            repotype = self.selitem.internalPointer().repotype()
-            if repotype == 'hg':
-                self.showFirstTabOrOpen()
-            else:
-                qtlib.WarningMsgBox(
-                    _('Unsupported repository type (%s)') % repotype,
-                    _('Cannot open non mercurial repositories or subrepositories'),
-                    parent=self)
-        else:
-            # a double-click on non-repo rows opens an editor
-            super(RepoTreeView, self).mouseDoubleClickEvent(event)
+    def mousePressEvent(self, event):
+        super(RepoTreeView, self).mousePressEvent(event)
+        isLeftButton = (event.buttons() == Qt.LeftButton)
+        isMiddleButton = (event.buttons() == Qt.MiddleButton)
+        if not isLeftButton and not isMiddleButton: return
+        isMercurialRepo = self.selitem and self.selitem.internalPointer().isRepo() and self.selitem.internalPointer().repotype() == 'hg'
+        if isMercurialRepo:
+            if isLeftButton: self.closeCurrentTab.emit()
+            self.showFirstTabOrOpen()
 
     def selectionChanged(self, selected, deselected):
         selection = self.selectedIndexes()
 
     showMessage = pyqtSignal(QString)
     openRepo = pyqtSignal(QString, bool)
+    closeCurrentTab = pyqtSignal()
     removeRepo = pyqtSignal(QString)
     progressReceived = pyqtSignal(QString, object, QString, QString, object)
 
         tv.showMessage.connect(self.showMessage)
         tv.menuRequested.connect(self.onMenuRequest)
         tv.openRepo.connect(self.openRepo)
+        tv.closeCurrentTab.connect(self.closeCurrentTab)
         tv.updateSettingsFile.connect(self.updateSettingsFile)
         tv.dropAccepted.connect(self.dropAccepted)
 

File tortoisehg/hgqt/workbench.py

View file
         rr.setObjectName('RepoRegistryView')
         rr.showMessage.connect(self.showMessage)
         rr.openRepo.connect(self.openRepo)
+        rr.closeCurrentTab.connect(self.closeCurrentTab)
         rr.removeRepo.connect(self.removeRepo)
         rr.progressReceived.connect(self.progress)
         rr.hide()
         if actionlist:
             contextmenu.exec_(self.repoTabsWidget.mapToGlobal(point))
 
+    @pyqtSlot()
+    def closeCurrentTab(self):
+        if self.repoTabsWidget.currentIndex() > -1:
+            self.repoTabCloseRequested(self.repoTabsWidget.currentIndex())
+
     def closeLastClickedTab(self):
         if self.repoTabsWidget.lastClickedTab > -1:
             self.repoTabCloseRequested(self.repoTabsWidget.lastClickedTab)