Skip to content
Permalink
Browse files

gdal tools: use native file dialogs (fixes #5500)

(cherry picked from commit 2c112f9)
  • Loading branch information
jef-n committed Jun 20, 2016
1 parent f52d27b commit ca865711f76e67a4412f4c0a6227f2f662d8a2e5
Showing with 24 additions and 4 deletions.
  1. +24 −4 python/plugins/GdalTools/tools/GdalTools_utils.py
@@ -444,19 +444,39 @@ def getDialog(self, parent=None, caption='', acceptMode=QFileDialog.AcceptOpen,

@classmethod
def getOpenFileNames(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding)
res = QFileDialog.getOpenFileNames(parent, caption, getLastUsedDir(), filter)
if len(res) > 0:
setLastUsedDir(res[-1])
return res

@classmethod
def getOpenFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFile, filter, selectedFilter, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFile, filter, selectedFilter, useEncoding)
res = QFileDialog.getOpenFileName(parent, caption, getLastUsedDir(), filter)
if res:
setLastUsedDir(res)
return res

@classmethod
def getSaveFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptSave, QFileDialog.AnyFile, filter, selectedFilter, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptSave, QFileDialog.AnyFile, filter, selectedFilter, useEncoding)
res = QFileDialog.getSaveFileName(parent, caption, getLastUsedDir(), filter)
if res:
setLastUsedDir(res)
return res

@classmethod
def getExistingDirectory(self, parent=None, caption='', useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.DirectoryOnly, '', None, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.DirectoryOnly, '', None, useEncoding)
res = QFileDialog.getExistingDirectory(parent, caption, getLastUsedDir(), QFileDialog.ShowDirsOnly)
if res:
setLastUsedDir(res)
return res


class FileFilter:

0 comments on commit ca86571

Please sign in to comment.
You can’t perform that action at this time.