Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

workbench: implement folder drag to open repos

Just drag a folder or a file on the workbench window and it opens the enclosing repo
in a new repo tab!

The drag is accepted only if the path is inside a repo.

Strangely, I had to strip the first character (a '/') from the path. I only tried on
Windows. Maybe someone else can test this (and please tweak if needed) on Linux.

Changeset 1da90a31f6b6

Parent 7d9e03b70418

by Adrian Buehlmann

Changes to one file · Browse files at 1da90a31f6b6 Showing diff from parent 7d9e03b70418 Diff from another changeset...

 
102
103
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
106
107
 
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
@@ -102,6 +102,34 @@
  getattr(self, n).restoreState(s.value(wb + n).toByteArray())   '''   + self.setAcceptDrops(True) + + def find_root(self, url): + p = str(url.path()) + if os.name == 'nt': + p = p[1:] # skip leading slash (needed on Windows) + return paths.find_root(p) + + def dragEnterEvent(self, event): + d = event.mimeData() + for u in d.urls(): + root = self.find_root(u) + if root: + event.acceptProposedAction() + break + + def dropEvent(self, event): + accept = False + d = event.mimeData() + for u in d.urls(): + root = self.find_root(u) + if root: + repo = hg.repository(self.ui, path=root) + self.addRepoTab(repo) + accept = True + if accept: + event.acceptProposedAction() +   def repoTabCloseRequested(self, index):   tw = self.repoTabsWidget   tw.removeTab(index)