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

repowidget: accept patch files by drag and drop

Currently it accepts any files as patches. But it should get to know
file types, when it need to support another type of dropped files.

Changeset 60e4e0c9b8e1

Parent 392a90a93a2f

by Yuya Nishihara

Changes to one file · Browse files at 60e4e0c9b8e1 Showing diff from parent 392a90a93a2f Diff from another changeset...

 
11
12
13
 
 
14
15
16
 
41
42
43
44
 
45
46
47
 
257
258
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
261
262
263
264
265
266
 
267
268
 
 
269
270
271
 
11
12
13
14
15
16
17
18
 
43
44
45
 
46
47
48
49
 
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
 
282
283
284
285
286
287
288
289
@@ -11,6 +11,8 @@
 import binascii  import os   +from mercurial import util +  from tortoisehg.util import shlib, hglib    from tortoisehg.hgqt.i18n import _ @@ -41,7 +43,7 @@
  makeLogVisible = pyqtSignal(bool)     def __init__(self, repo, workbench): - QWidget.__init__(self) + QWidget.__init__(self, acceptDrops=True)     self.repo = repo   repo.repositoryChanged.connect(self.repositoryChanged) @@ -257,15 +259,31 @@
  act.triggered.connect(cb)   self.addAction(act)   + def dragEnterEvent(self, event): + paths = [unicode(u.toLocalFile()) for u in event.mimeData().urls()] + if util.any(os.path.isfile(p) for p in paths): + event.setDropAction(Qt.CopyAction) + event.accept() + + def dropEvent(self, event): + paths = [unicode(u.toLocalFile()) for u in event.mimeData().urls()] + filepaths = [p for p in paths if os.path.isfile(p)] + if filepaths: + self.thgimport(filepaths) + event.setDropAction(Qt.CopyAction) + event.accept() +   def back(self):   self.repoview.back()     def forward(self):   self.repoview.forward()   - def thgimport(self): + def thgimport(self, paths=None):   dlg = thgimport.ImportDialog(repo=self.repo, parent=self)   dlg.repoInvalidated.connect(self.reload) + if paths: + dlg.setfilepaths(paths)   dlg.exec_()     def verify(self):